civics-cdf-validator 1.49.dev10__tar.gz → 1.49.dev11__tar.gz

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.
Files changed (22) hide show
  1. {civics_cdf_validator-1.49.dev10/civics_cdf_validator.egg-info → civics_cdf_validator-1.49.dev11}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/README.md +1 -2
  3. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  4. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/rules.py +124 -0
  5. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/validator.py +2 -0
  6. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/version.py +1 -1
  7. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/CONTRIBUTING.md +0 -0
  8. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/LICENSE-2.0.txt +0 -0
  9. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/MANIFEST.in +0 -0
  10. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/__init__.py +0 -0
  11. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/base.py +0 -0
  12. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  13. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  14. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  15. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/civics_cdf_validator.egg-info/requires.txt +0 -0
  16. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  17. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/gpunit_rules.py +0 -0
  18. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/loggers.py +0 -0
  19. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/office_utils.py +0 -0
  20. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/setup.cfg +0 -0
  21. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/setup.py +0 -0
  22. {civics_cdf_validator-1.49.dev10 → civics_cdf_validator-1.49.dev11}/stats.py +0 -0
@@ -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
@@ -15,7 +15,6 @@ civics_cdf_validator relies on lxml which will be installed if it
15
15
  isn't already installed. You may need to install libxslt development libraries
16
16
  in order to build lxml.
17
17
 
18
-
19
18
  # USAGE
20
19
 
21
20
  ## Branch Definitions
@@ -23,7 +22,6 @@ in order to build lxml.
23
22
  * `staging` - Branch that contains next version of production code, typically available one month in advance of a production push.
24
23
  * `dev` - Branch that contains development code with latest changes changes to the validator. This branch is rolled into staging on a monthly basis.
25
24
 
26
-
27
25
  ## Supported feeds
28
26
  You can use `civics_cdf_validator` to check different types of feed:
29
27
 
@@ -33,6 +31,7 @@ You can use `civics_cdf_validator` to check different types of feed:
33
31
  * Committee
34
32
  * Election Dates
35
33
  * Metadata
34
+ * Voter information
36
35
 
37
36
  ## List rules
38
37
 
@@ -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
@@ -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'