civics-cdf-validator 1.49.dev10__py3-none-any.whl → 1.49.dev11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4490,6 +4490,118 @@ class UnsupportedOfficeHolderTenureSchema(base.BaseRule):
4490
4490
  )
4491
4491
 
4492
4492
 
4493
+ class ElectoralCommissionCollectionExists(base.BaseRule):
4494
+ """ElectoralCommissionCollection should exist."""
4495
+
4496
+ def elements(self):
4497
+ return ["ElectionReport"]
4498
+
4499
+ def check(self, element):
4500
+ if element.find("ElectoralCommissionCollection") is None:
4501
+ raise loggers.ElectionError.from_message(
4502
+ "ElectoralCommissionCollection should exist."
4503
+ )
4504
+
4505
+
4506
+ class VoterInformationCollectionExists(base.BaseRule):
4507
+ """Warn if there is no VoterInformationCollection."""
4508
+
4509
+ def elements(self):
4510
+ return ["ElectionReport"]
4511
+
4512
+ def check(self, element):
4513
+ if element.find("VoterInformationCollection") is None:
4514
+ raise loggers.ElectionWarning.from_message(
4515
+ "VoterInformationCollection should exist."
4516
+ )
4517
+
4518
+
4519
+ class NoExtraElectionElements(base.BaseRule):
4520
+ """Elections for voter information feeds should not have certain elements.
4521
+
4522
+ BallotStyleCollection, CandidateCollection, ContestCollection, CountStatus
4523
+ should all be excluded.
4524
+ """
4525
+
4526
+ def elements(self):
4527
+ return ["Election"]
4528
+
4529
+ def check(self, element):
4530
+ if element.find("BallotStyleCollection") is not None:
4531
+ raise loggers.ElectionError.from_message(
4532
+ "BallotStyleCollection should not exist."
4533
+ )
4534
+
4535
+ if element.find("CandidateCollection") is not None:
4536
+ raise loggers.ElectionError.from_message(
4537
+ "CandidateCollection should not exist."
4538
+ )
4539
+ if element.find("ContestCollection") is not None:
4540
+ raise loggers.ElectionError.from_message(
4541
+ "ContestCollection should not exist."
4542
+ )
4543
+
4544
+ if element.find("CountStatus") is not None:
4545
+ raise loggers.ElectionError.from_message("CountStatus should not exist.")
4546
+
4547
+
4548
+ class WarnOnElementsNotRecommendedForElection(base.BaseRule):
4549
+ """Warn on ContactInformation on an Election for voter information feeds."""
4550
+
4551
+ def elements(self):
4552
+ return ["Election"]
4553
+
4554
+ def check(self, element):
4555
+ if element.find("ContactInformation") is not None:
4556
+ raise loggers.ElectionWarning.from_message(
4557
+ "ContactInformation is not recommended for Election, prefer using an"
4558
+ " ElectionAdministration."
4559
+ )
4560
+
4561
+
4562
+ class NoExtraElectionReportCollections(base.BaseRule):
4563
+ """ElectionReports for voter information feeds should not have certain elements.
4564
+
4565
+ CommitteeCollection, GovernmentBodyCollection, OfficeCollection,
4566
+ OfficeHolderTenureCollection, PartyCollection, PersonCollection should all be
4567
+ excluded.
4568
+ """
4569
+
4570
+ def elements(self):
4571
+ return ["ElectionReport"]
4572
+
4573
+ def check(self, element):
4574
+ if element.find("CommitteeCollection") is not None:
4575
+ raise loggers.ElectionError.from_message(
4576
+ "CommitteeCollection should not exist."
4577
+ )
4578
+
4579
+ if element.find("GovernmentBodyCollection") is not None:
4580
+ raise loggers.ElectionError.from_message(
4581
+ "GovernmentBodyCollection should not exist."
4582
+ )
4583
+
4584
+ if element.find("OfficeCollection") is not None:
4585
+ raise loggers.ElectionError.from_message(
4586
+ "OfficeCollection should not exist."
4587
+ )
4588
+
4589
+ if element.find("OfficeHolderTenureCollection") is not None:
4590
+ raise loggers.ElectionError.from_message(
4591
+ "OfficeHolderTenureCollection should not exist."
4592
+ )
4593
+
4594
+ if element.find("PartyCollection") is not None:
4595
+ raise loggers.ElectionError.from_message(
4596
+ "PartyCollection should not exist."
4597
+ )
4598
+
4599
+ if element.find("PersonCollection") is not None:
4600
+ raise loggers.ElectionError.from_message(
4601
+ "PersonCollection should not exist."
4602
+ )
4603
+
4604
+
4493
4605
  class RuleSet(enum.Enum):
4494
4606
  """Names for sets of rules used to validate a particular feed type."""
4495
4607
 
@@ -4499,6 +4611,7 @@ class RuleSet(enum.Enum):
4499
4611
  ELECTION_DATES = 4
4500
4612
  ELECTION_RESULTS = 5
4501
4613
  METADATA = 6
4614
+ VOTER_INFORMATION = 7
4502
4615
 
4503
4616
 
4504
4617
  # To add new rules, create a new class, inherit the base rule,
@@ -4660,6 +4773,16 @@ METADATA_RULES = (
4660
4773
  # go/keep-sorted end
4661
4774
  )
4662
4775
 
4776
+ VOTER_INFORMATION_RULES = COMMON_RULES + (
4777
+ # go/keep-sorted start
4778
+ ElectoralCommissionCollectionExists,
4779
+ NoExtraElectionElements,
4780
+ NoExtraElectionReportCollections,
4781
+ VoterInformationCollectionExists,
4782
+ WarnOnElementsNotRecommendedForElection,
4783
+ # go/keep-sorted end
4784
+ )
4785
+
4663
4786
  ALL_RULES = frozenset(
4664
4787
  COMMON_RULES
4665
4788
  + ELECTION_RULES
@@ -4667,5 +4790,6 @@ ALL_RULES = frozenset(
4667
4790
  + OFFICEHOLDER_RULES
4668
4791
  + COMMITTEE_RULES
4669
4792
  + ELECTION_DATES_RULES
4793
+ + VOTER_INFORMATION_RULES
4670
4794
  + METADATA_RULES
4671
4795
  )
@@ -260,6 +260,8 @@ def filter_all_rules_using_user_arg(rules_allowlist, rule_set, rules_blocklist):
260
260
  rule_names = [x.__name__ for x in rules.ELECTION_RESULTS_RULES]
261
261
  elif rule_set == rules.RuleSet.METADATA:
262
262
  rule_names = [x.__name__ for x in rules.METADATA_RULES]
263
+ elif rule_set == rules.RuleSet.VOTER_INFORMATION:
264
+ rule_names = [x.__name__ for x in rules.VOTER_INFORMATION_RULES]
263
265
  else:
264
266
  raise AssertionError("Invalid rule_set: " + rule_set)
265
267
  if rules_blocklist:
@@ -5,4 +5,4 @@ No dependencies should be added to this module.
5
5
  See https://packaging.python.org/guides/single-sourcing-package-version/
6
6
  """
7
7
 
8
- __version__ = '1.49.dev10'
8
+ __version__ = '1.49.dev11'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev10
3
+ Version: 1.49.dev11
4
4
  Summary: Checks if an election feed follows best practices
5
5
  Home-page: https://github.com/google/civics_cdf_validator
6
6
  Author: Google Civics
@@ -0,0 +1,15 @@
1
+ civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,16954
3
+ civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
4
+ civics_cdf_validator/loggers.py,sha256=LS6U9YWzu72V2Q0PwyE9xE03Ul392UAPRnrp2uRBMLA,6923
5
+ civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
6
+ civics_cdf_validator/rules.py,sha256=Hn7qk3qLhidhQrb15iq1ZwN4XLJ4HVhY4VHBbNGY9u4,158898
7
+ civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
8
+ civics_cdf_validator/validator.py,sha256=2nwlFfQ9AmpTaO5n5ekaO845Rm0JPjNF-Il6FJW_50k,12678
9
+ civics_cdf_validator/version.py,sha256=5WTRUaJiARj_r2UPhcMKa9SSvt8tRFJt6pCR0zFyGpc,189
10
+ civics_cdf_validator-1.49.dev11.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
+ civics_cdf_validator-1.49.dev11.dist-info/METADATA,sha256=9odJ6J0QGbWLOgkjRweufw1myU5Tg_CX3ts5z_zLbCI,1009
12
+ civics_cdf_validator-1.49.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ civics_cdf_validator-1.49.dev11.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
+ civics_cdf_validator-1.49.dev11.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
+ civics_cdf_validator-1.49.dev11.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,15 +0,0 @@
1
- civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,16954
3
- civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
4
- civics_cdf_validator/loggers.py,sha256=LS6U9YWzu72V2Q0PwyE9xE03Ul392UAPRnrp2uRBMLA,6923
5
- civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
6
- civics_cdf_validator/rules.py,sha256=KS6IysBUQCuJ0-kI9i-OI-EMKNbHF5-9ausUu6NljRo,155073
7
- civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
8
- civics_cdf_validator/validator.py,sha256=SXPsYLu0G_JT2B03i24-yJFh41YzaSYecan4LQ_Xqm4,12553
9
- civics_cdf_validator/version.py,sha256=yFDctiE6ZSXjuLRmFHikXVoxvpmN1kjktktb3OcI2fc,189
10
- civics_cdf_validator-1.49.dev10.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
- civics_cdf_validator-1.49.dev10.dist-info/METADATA,sha256=mN_OGtEBeCJD4lLCCNRfS1GkDWnPHSNlBHZIO-MB2v4,1009
12
- civics_cdf_validator-1.49.dev10.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
13
- civics_cdf_validator-1.49.dev10.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
- civics_cdf_validator-1.49.dev10.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
- civics_cdf_validator-1.49.dev10.dist-info/RECORD,,