civics-cdf-validator 1.49.dev5__tar.gz → 1.49.dev6__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.dev5/civics_cdf_validator.egg-info → civics_cdf_validator-1.49.dev6}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/rules.py +42 -0
  4. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/version.py +1 -1
  5. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/CONTRIBUTING.md +0 -0
  6. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/LICENSE-2.0.txt +0 -0
  7. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/MANIFEST.in +0 -0
  8. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/README.md +0 -0
  9. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/__init__.py +0 -0
  10. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/base.py +0 -0
  11. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  12. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  13. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  14. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/civics_cdf_validator.egg-info/requires.txt +0 -0
  15. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  16. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/gpunit_rules.py +0 -0
  17. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/loggers.py +0 -0
  18. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/office_utils.py +0 -0
  19. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/setup.cfg +0 -0
  20. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/setup.py +0 -0
  21. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/stats.py +0 -0
  22. {civics_cdf_validator-1.49.dev5 → civics_cdf_validator-1.49.dev6}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev5
3
+ Version: 1.49.dev6
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.49.dev5
3
+ Version: 1.49.dev6
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
@@ -2857,6 +2857,47 @@ class DateStatusMatches(base.DateRule):
2857
2857
  raise loggers.ElectionInfo.from_message(msg, [election_elem])
2858
2858
 
2859
2859
 
2860
+ class OfficeSelectionMethodMatch(base.BaseRule):
2861
+ """Office and OfficeHolderTenure need to have matching selection methods.
2862
+
2863
+ Ensure that the OfficeSelectionMethod of a given OfficeHolderTenure is
2864
+ also
2865
+ present in the list of SelectionMethods of the Office it points to.
2866
+ """
2867
+
2868
+ def __init__(self, election_tree, schema_tree, **kwargs):
2869
+ self.office_selection_methods = {}
2870
+ officeholder_tenure_elements = self.get_elements_by_class(
2871
+ election_tree, "OfficeHolderTenure"
2872
+ )
2873
+ office_elements = self.get_elements_by_class(election_tree, "Office")
2874
+ if officeholder_tenure_elements:
2875
+ for element in office_elements:
2876
+ office_id = element.get("objectId")
2877
+ selection_methods = {
2878
+ selection_method.text
2879
+ for selection_method in element.findall("SelectionMethod")
2880
+ }
2881
+ self.office_selection_methods[office_id] = selection_methods
2882
+
2883
+ def elements(self):
2884
+ return ["OfficeHolderTenure"]
2885
+
2886
+ def check(self, element):
2887
+ office_id = element.find("OfficeId").text
2888
+ office_selection_method = element.find("OfficeSelectionMethod").text
2889
+ if (
2890
+ office_id not in self.office_selection_methods
2891
+ or office_selection_method
2892
+ not in self.office_selection_methods[office_id]
2893
+ ):
2894
+ raise loggers.ElectionError.from_message(
2895
+ "OfficeSelectionMethod does not have a matching SelectionMethod"
2896
+ " in the corresponding Office element.",
2897
+ [element],
2898
+ )
2899
+
2900
+
2860
2901
  class OfficeTermDates(base.DateRule):
2861
2902
  """Office elements should contain valid term dates.
2862
2903
 
@@ -4546,6 +4587,7 @@ ELECTION_RESULTS_RULES = ELECTION_RULES + (
4546
4587
  OFFICEHOLDER_RULES = COMMON_RULES + (
4547
4588
  # go/keep-sorted start
4548
4589
  DateOfBirthIsInPast,
4590
+ OfficeSelectionMethodMatch,
4549
4591
  OfficeTermDates,
4550
4592
  PersonHasOffice,
4551
4593
  ProhibitElectionData,
@@ -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.dev5'
8
+ __version__ = '1.49.dev6'