civics-cdf-validator 1.69.dev6__tar.gz → 1.69.dev8__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 (32) hide show
  1. {civics_cdf_validator-1.69.dev6/civics_cdf_validator.egg-info → civics_cdf_validator-1.69.dev8}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/base.py +3 -2
  3. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  4. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/common_rules.py +17 -11
  5. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/election_rules.py +5 -3
  6. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/version.py +1 -1
  7. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/CONTRIBUTING.md +0 -0
  8. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/LICENSE-2.0.txt +0 -0
  9. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/MANIFEST.in +0 -0
  10. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/README.md +0 -0
  11. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/__init__.py +0 -0
  12. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  13. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  14. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  15. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/civics_cdf_validator.egg-info/requires.txt +0 -0
  16. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  17. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/gpunit_rules.py +0 -0
  18. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/loggers.py +0 -0
  19. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/office_utils.py +0 -0
  20. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rules.py +0 -0
  21. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/__init__.py +0 -0
  22. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/committee_rules.py +0 -0
  23. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/election_dates_rules.py +0 -0
  24. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/election_results_rules.py +0 -0
  25. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/metadata_rules.py +0 -0
  26. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/officeholder_rules.py +0 -0
  27. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/rule_util.py +0 -0
  28. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/rulesets/voter_information_rules.py +0 -0
  29. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/setup.cfg +0 -0
  30. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/setup.py +0 -0
  31. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/stats.py +0 -0
  32. {civics_cdf_validator-1.69.dev6 → civics_cdf_validator-1.69.dev8}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.69.dev6
3
+ Version: 1.69.dev8
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
@@ -423,13 +423,14 @@ class MissingFieldRule(BaseRule):
423
423
  def check(self, element: etree._Element) -> None:
424
424
  error_log = []
425
425
 
426
- required_field_tags = self.element_field_mapping()[element.tag]
426
+ element_class = self.get_element_class(element)
427
+ required_field_tags = self.element_field_mapping()[element_class]
427
428
  for field_tag in required_field_tags:
428
429
  required_field = element.find(field_tag)
429
430
  if (required_field is None or required_field.text is None
430
431
  or not required_field.text.strip()):
431
432
  error_log.append(loggers.LogEntry(
432
- f"The element {element.tag} is missing field {field_tag}.",
433
+ f"The element {element_class} is missing field {field_tag}.",
433
434
  [element]))
434
435
 
435
436
  if error_log:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.69.dev6
3
+ Version: 1.69.dev8
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
@@ -409,16 +409,16 @@ class ValidStableID(base.BaseRule):
409
409
  raise loggers.ElectionError(error_log)
410
410
 
411
411
 
412
- class GpUnitOcdId(base.BaseRule):
412
+ class GpUnitOcdId(base.SchemaRule):
413
413
  """All GpUnits MUST have a valid OCD ID."""
414
414
 
415
- def elements(self):
416
- return ["GpUnit", "ReportingUnit"]
415
+ def elements(self) -> list[str]:
416
+ # ReportingDevices are not expected to have OCD IDs.
417
+ return ["GpUnit"] + list(
418
+ self.get_all_subtypes("GpUnit") - {"ReportingDevice"}
419
+ )
417
420
 
418
421
  def check(self, element: etree._Element) -> None:
419
- # ReportingDevices are not expected to have OCD IDs.
420
- if self.get_element_class(element) == "ReportingDevice":
421
- return
422
422
  type_element = element.find("Type")
423
423
  if (
424
424
  rule_util.element_has_text(type_element)
@@ -777,7 +777,7 @@ class UniqueStableID(base.TreeRule):
777
777
 
778
778
 
779
779
  class MissingStableIds(base.BaseRule):
780
- """Check that each NIST object in the feed have a stable Id.
780
+ """Check that each CDF object in the feed have a stable Id.
781
781
 
782
782
  Add an error message if stable id is missing from the object.
783
783
  """
@@ -797,6 +797,7 @@ class MissingStableIds(base.BaseRule):
797
797
  "PartyContest",
798
798
  "Person",
799
799
  "ReportingUnit",
800
+ "RetentionContest",
800
801
  ]
801
802
 
802
803
  def elements(self) -> list[str]:
@@ -922,10 +923,12 @@ class AllCaps(base.BaseRule):
922
923
  """
923
924
 
924
925
  _element_field_mapping = {
926
+ "BallotMeasureContest": ["Name"],
925
927
  "Candidate": ["BallotName//Text"],
926
928
  "CandidateContest": ["Name"],
927
929
  "PartyContest": ["Name"],
928
930
  "Person": ["FullName//Text"],
931
+ "RetentionContest": ["Name"],
929
932
  }
930
933
 
931
934
  def elements(self) -> list[str]:
@@ -1505,7 +1508,7 @@ class ValidPartyLeadershipDates(base.DateRule):
1505
1508
  """
1506
1509
 
1507
1510
  def elements(self) -> list[str]:
1508
- return ["PartyLeadership"]
1511
+ return ["Leadership"]
1509
1512
 
1510
1513
  def check(self, element: etree._Element) -> None:
1511
1514
  self.reset_instance_vars()
@@ -1515,11 +1518,11 @@ class ValidPartyLeadershipDates(base.DateRule):
1515
1518
  raise loggers.ElectionError(self.error_log)
1516
1519
 
1517
1520
 
1518
- class GpUnitsHaveInternationalizedName(base.BaseRule):
1521
+ class GpUnitsHaveInternationalizedName(base.SchemaRule):
1519
1522
  """GpUnits must have at least one non-empty InternationlizedName element."""
1520
1523
 
1521
- def elements(self):
1522
- return ["GpUnit"]
1524
+ def elements(self) -> list[str]:
1525
+ return ["GpUnit"] + list(self.get_all_subtypes("GpUnit"))
1523
1526
 
1524
1527
  def check(self, element: etree._Element) -> None:
1525
1528
  intl_names = element.findall("InternationalizedName")
@@ -1578,6 +1581,9 @@ class MissingFieldsError(base.MissingFieldRule):
1578
1581
  "Party": [
1579
1582
  "PartyScopeGpUnitIds",
1580
1583
  ],
1584
+ "Coalition": [
1585
+ "PartyScopeGpUnitIds",
1586
+ ],
1581
1587
  }
1582
1588
 
1583
1589
 
@@ -1221,11 +1221,13 @@ class FullTextOrBallotText(base.SchemaRule):
1221
1221
  raise loggers.ElectionWarning.from_message(msg, [element])
1222
1222
 
1223
1223
 
1224
- class BallotTitle(base.BaseRule):
1224
+ class BallotTitle(base.SchemaRule):
1225
1225
  """BallotTitle must exist and should usually be shorter than BallotText."""
1226
1226
 
1227
- def elements(self):
1228
- return ["BallotMeasureContest"]
1227
+ def elements(self) -> list[str]:
1228
+ return ["BallotMeasureContest"] + list(
1229
+ self.get_all_subtypes("BallotMeasureContest")
1230
+ )
1229
1231
 
1230
1232
  def check(self, element: etree._Element) -> None:
1231
1233
  ballot_title_map = rule_util.get_language_to_text_map(
@@ -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.69.dev6'
8
+ __version__ = '1.69.dev8'