civics-cdf-validator 1.49.dev4__py3-none-any.whl → 1.49.dev6__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.
@@ -1941,8 +1941,20 @@ class PersonHasOffice(base.ValidReferenceRule):
1941
1941
  if leader_id.text:
1942
1942
  person_reference_ids.add(leader_id.text)
1943
1943
 
1944
+ office_holder_tenure_collection = root.find("OfficeHolderTenureCollection")
1945
+ if office_holder_tenure_collection is not None:
1946
+ for office_holder_tenure in office_holder_tenure_collection.findall(
1947
+ "OfficeHolderTenure"
1948
+ ):
1949
+ id_obj = office_holder_tenure.find("OfficeHolderPersonId")
1950
+ if id_obj is not None and id_obj.text:
1951
+ person_reference_ids.add(id_obj.text.strip())
1952
+
1944
1953
  office_collection = root.find("OfficeCollection")
1945
- if office_collection is not None:
1954
+ if (
1955
+ office_holder_tenure_collection is None
1956
+ and office_collection is not None
1957
+ ):
1946
1958
  for office in office_collection.findall("Office"):
1947
1959
  id_obj = office.find("OfficeHolderPersonIds")
1948
1960
  if id_obj is not None and id_obj.text:
@@ -2845,6 +2857,47 @@ class DateStatusMatches(base.DateRule):
2845
2857
  raise loggers.ElectionInfo.from_message(msg, [election_elem])
2846
2858
 
2847
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
+
2848
2901
  class OfficeTermDates(base.DateRule):
2849
2902
  """Office elements should contain valid term dates.
2850
2903
 
@@ -4534,6 +4587,7 @@ ELECTION_RESULTS_RULES = ELECTION_RULES + (
4534
4587
  OFFICEHOLDER_RULES = COMMON_RULES + (
4535
4588
  # go/keep-sorted start
4536
4589
  DateOfBirthIsInPast,
4590
+ OfficeSelectionMethodMatch,
4537
4591
  OfficeTermDates,
4538
4592
  PersonHasOffice,
4539
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.dev4'
8
+ __version__ = '1.49.dev6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev4
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
@@ -3,13 +3,13 @@ civics_cdf_validator/base.py,sha256=E1Tp15P-zJl7-4YmFpxB4OEbWbFbQWpT9NW0XT98C_c,
3
3
  civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
4
4
  civics_cdf_validator/loggers.py,sha256=LS6U9YWzu72V2Q0PwyE9xE03Ul392UAPRnrp2uRBMLA,6923
5
5
  civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
6
- civics_cdf_validator/rules.py,sha256=8sMV8VL8eWFNhqDBtsh5r-5Jd5jRSm1bJ4OMGWe02zs,151896
6
+ civics_cdf_validator/rules.py,sha256=iofXrU1QLmgvwb9kBr_bca8z6z7AM_P7VB5rT3W2QQg,153888
7
7
  civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
8
8
  civics_cdf_validator/validator.py,sha256=SXPsYLu0G_JT2B03i24-yJFh41YzaSYecan4LQ_Xqm4,12553
9
- civics_cdf_validator/version.py,sha256=6C8Z4BVJHdzi0RW5shiztdupmQNW-pNC_XjrjfKroMg,188
10
- civics_cdf_validator-1.49.dev4.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
- civics_cdf_validator-1.49.dev4.dist-info/METADATA,sha256=fb1wKnepxYMS3JdoA2eLVD-6i3MbdUgIXFFtX2mD82Y,1008
12
- civics_cdf_validator-1.49.dev4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
13
- civics_cdf_validator-1.49.dev4.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
- civics_cdf_validator-1.49.dev4.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
- civics_cdf_validator-1.49.dev4.dist-info/RECORD,,
9
+ civics_cdf_validator/version.py,sha256=ON0Bvzu35yVJTLI3YHWpiJzQKOkGV4ppGiLCitAeFA8,188
10
+ civics_cdf_validator-1.49.dev6.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
+ civics_cdf_validator-1.49.dev6.dist-info/METADATA,sha256=xxY41oXrwGPc_NZEIguT9tuB5kvbYSC66MgHqP_q6C8,1008
12
+ civics_cdf_validator-1.49.dev6.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
13
+ civics_cdf_validator-1.49.dev6.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
+ civics_cdf_validator-1.49.dev6.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
+ civics_cdf_validator-1.49.dev6.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5