civics-cdf-validator 1.66.dev3__tar.gz → 1.66.dev5__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.66.dev3/civics_cdf_validator.egg-info → civics_cdf_validator-1.66.dev5}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/office_utils.py +1 -0
  4. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/rules.py +28 -0
  5. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/version.py +1 -1
  6. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/CONTRIBUTING.md +0 -0
  7. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/LICENSE-2.0.txt +0 -0
  8. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/MANIFEST.in +0 -0
  9. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/README.md +0 -0
  10. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/__init__.py +0 -0
  11. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/base.py +0 -0
  12. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  13. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  14. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  15. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/civics_cdf_validator.egg-info/requires.txt +0 -0
  16. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  17. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/gpunit_rules.py +0 -0
  18. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/loggers.py +0 -0
  19. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/setup.cfg +0 -0
  20. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/setup.py +0 -0
  21. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/stats.py +0 -0
  22. {civics_cdf_validator-1.66.dev3 → civics_cdf_validator-1.66.dev5}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.66.dev3
3
+ Version: 1.66.dev5
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.66.dev3
3
+ Version: 1.66.dev5
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
@@ -57,6 +57,7 @@ VALID_OFFICE_ROLES = frozenset([
57
57
  "criminal court at law",
58
58
  "deputy head of government",
59
59
  "deputy state executive",
60
+ "diplomat",
60
61
  "district attorney",
61
62
  "district clerk",
62
63
  "district court",
@@ -474,6 +474,8 @@ class ValidIDREF(base.BaseRule):
474
474
 
475
475
  _REFERENCE_TYPE_OVERRIDES = {
476
476
  # ID refs to GpUnits
477
+ "DiplomatReceivingStateId": "GpUnit",
478
+ "DiplomatSendingStateId": "GpUnit",
477
479
  "ElectoralDistrictId": "GpUnit",
478
480
  "ElectionScopeId": "GpUnit",
479
481
  "ScopeLevel": "GpUnit",
@@ -2609,6 +2611,31 @@ class OfficesHaveValidOfficeRole(base.BaseRule):
2609
2611
  )
2610
2612
 
2611
2613
 
2614
+ class DiplomaticOfficesHaveCorrespondingGpUnitsSet(base.BaseRule):
2615
+ """Offices with the 'diplomat' role must have a sending or receiving state."""
2616
+
2617
+ def elements(self):
2618
+ return ["Office"]
2619
+
2620
+ def check(self, element):
2621
+ office_roles = (
2622
+ role.text.strip()
2623
+ for role in element.findall("Role")
2624
+ if element_has_text(role)
2625
+ )
2626
+ if "diplomat" not in office_roles:
2627
+ return
2628
+
2629
+ if not element_has_text(
2630
+ element.find("DiplomatSendingStateId")
2631
+ ) and not element_has_text(element.find("DiplomatReceivingStateId")):
2632
+ raise loggers.ElectionError.from_message(
2633
+ "Office with role 'diplomat' must have at least one of"
2634
+ " DiplomatSendingStateId or DiplomatReceivingStateId set.",
2635
+ [element],
2636
+ )
2637
+
2638
+
2612
2639
  class ContestHasValidContestStage(base.BaseRule):
2613
2640
  """Each Contest must have a valid contest-stage."""
2614
2641
 
@@ -5524,6 +5551,7 @@ COMMON_RULES = (
5524
5551
  BadCharactersInPersonFullName,
5525
5552
  CandidateImageInContactInformation,
5526
5553
  DeprecatedPartyLeadershipSchema,
5554
+ DiplomaticOfficesHaveCorrespondingGpUnitsSet,
5527
5555
  DuplicateGpUnits,
5528
5556
  DuplicateID,
5529
5557
  DuplicatedGpUnitOcdId,
@@ -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.66.dev3'
8
+ __version__ = '1.66.dev5'