civics-cdf-validator 1.49.dev15__py3-none-any.whl → 1.49.dev17__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.
@@ -84,7 +84,6 @@ class ElectionInfo(ElectionException):
84
84
 
85
85
  def get_parent_hierarchy_object_id_str(elt):
86
86
  """Get the elt path from the 1st parent with an objectId / ElectionReport."""
87
-
88
87
  elt_hierarchy = []
89
88
  current_elt = elt
90
89
  while current_elt is not None:
@@ -203,4 +202,3 @@ def severities_names():
203
202
  for exp in ExceptionListWrapper.SUPPORTED_SEVERITIES:
204
203
  names.append(exp.description.lower())
205
204
  return names
206
-
@@ -3018,8 +3018,10 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
3018
3018
  self.election_tree, "OfficeHolderTenure"
3019
3019
  )
3020
3020
  for officeholder_tenure in officeholder_tenures:
3021
- person_id = officeholder_tenure.find("OfficeHolderPersonId").text
3022
- object_id = officeholder_tenure.get("objectId")
3021
+ office_holder_person_elem = officeholder_tenure.find(
3022
+ "OfficeHolderPersonId"
3023
+ )
3024
+ person_id = office_holder_person_elem.text
3023
3025
  date_validator = base.DateRule(None, None)
3024
3026
  date_validator.gather_dates(officeholder_tenure)
3025
3027
  end_date = date_validator.end_date
@@ -3033,13 +3035,15 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
3033
3035
  sixty_days_earlier.day,
3034
3036
  )
3035
3037
  if end_date < partial_date_sixty_days:
3036
- outdated_officeholder_tenures.append(object_id)
3038
+ outdated_officeholder_tenures.append(officeholder_tenure)
3037
3039
  if person_id in outdated_officetenure_persons.keys():
3038
3040
  outdated_officetenure_persons[person_id].append(
3039
- (object_id, end_date)
3041
+ (office_holder_person_elem, end_date)
3040
3042
  )
3041
3043
  else:
3042
- outdated_officetenure_persons[person_id] = [(object_id, end_date)]
3044
+ outdated_officetenure_persons[person_id] = [
3045
+ (office_holder_person_elem, end_date)
3046
+ ]
3043
3047
  for outdated_officeholder_tenure in outdated_officeholder_tenures:
3044
3048
  info_message = (
3045
3049
  "The officeholder tenure end date is more than 60 days"
@@ -3051,7 +3055,9 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
3051
3055
  )
3052
3056
  for person_id, value_list in outdated_officetenure_persons.items():
3053
3057
  has_recent_tenure = False
3058
+ office_holder_person_elem = None
3054
3059
  for value in value_list:
3060
+ office_holder_person_elem = value[0]
3055
3061
  end_date = value[1]
3056
3062
  sixty_days_earlier = datetime.datetime.now() + datetime.timedelta(
3057
3063
  days=-60
@@ -3063,13 +3069,15 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
3063
3069
  )
3064
3070
  if end_date > partial_date_sixty_days:
3065
3071
  has_recent_tenure = True
3066
- if not has_recent_tenure:
3072
+ if not has_recent_tenure and office_holder_person_elem is not None:
3067
3073
  info_message = (
3068
3074
  "All officeholder tenures ended more than 60 days ago. "
3069
- "Therefore, you can remove the person and the related "
3070
- "officeholder tenures from the feed."
3075
+ "Therefore, you can remove the person and the "
3076
+ "related officeholder tenures from the feed."
3077
+ )
3078
+ info_log.append(
3079
+ loggers.LogEntry(info_message, [office_holder_person_elem])
3071
3080
  )
3072
- info_log.append(loggers.LogEntry(info_message, [person_id]))
3073
3081
  else:
3074
3082
  for office in offices:
3075
3083
  person_id = office.find("OfficeHolderPersonIds").text
@@ -3481,9 +3489,6 @@ class MissingFieldsInfo(base.MissingFieldRule):
3481
3489
 
3482
3490
  def element_field_mapping(self):
3483
3491
  return {
3484
- "Office": [
3485
- "ElectoralDistrictId",
3486
- ],
3487
3492
  }
3488
3493
 
3489
3494
 
@@ -4503,10 +4508,20 @@ class UnreferencedEntitiesOfficeholders(UnreferencedEntitiesBase):
4503
4508
  """
4504
4509
 
4505
4510
  def __init__(self, election_tree, schema_tree, **kwargs):
4511
+ office_holder_tenure_collection = self.get_elements_by_class(
4512
+ election_tree, "OfficeHolderTenure"
4513
+ )
4514
+ is_post_office_split = False
4515
+ if office_holder_tenure_collection:
4516
+ is_post_office_split = True
4506
4517
  super(UnreferencedEntitiesOfficeholders, self).__init__(
4507
4518
  election_tree,
4508
4519
  schema_tree,
4509
- frozenset(["Office", "Leadership"]),
4520
+ (
4521
+ frozenset(["OfficeHolderTenure", "Leadership"])
4522
+ if is_post_office_split
4523
+ else frozenset(["Office", "Leadership"])
4524
+ ),
4510
4525
  frozenset(["Party"]),
4511
4526
  **kwargs,
4512
4527
  )
@@ -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.dev15'
8
+ __version__ = '1.49.dev17'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev15
3
+ Version: 1.49.dev17
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,15 +1,15 @@
1
1
  civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,16954
3
3
  civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
4
- civics_cdf_validator/loggers.py,sha256=LS6U9YWzu72V2Q0PwyE9xE03Ul392UAPRnrp2uRBMLA,6923
4
+ civics_cdf_validator/loggers.py,sha256=ZfWFd9yskcd2-qb83EPz7eqa1iGO8BRFMtDZeE1hofA,6921
5
5
  civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
6
- civics_cdf_validator/rules.py,sha256=MfNt3RnztLEUuf6-Ksd9O484Ihrn5GzE3rlWIF6KzFc,163372
6
+ civics_cdf_validator/rules.py,sha256=m_6wmnv7osSzwovnGYnfrwWC_MJ5gu9NIAk05FOshXw,163926
7
7
  civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
8
8
  civics_cdf_validator/validator.py,sha256=2nwlFfQ9AmpTaO5n5ekaO845Rm0JPjNF-Il6FJW_50k,12678
9
- civics_cdf_validator/version.py,sha256=-opmfDTRJeiPpxkg4oi9RUmaqlgTkt2qPKUoiRXDQVc,189
10
- civics_cdf_validator-1.49.dev15.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
- civics_cdf_validator-1.49.dev15.dist-info/METADATA,sha256=2FV0eKQ4cTQXIIGfsB8jI45EdmXqxv1pS0KvEkcZ1uA,1009
12
- civics_cdf_validator-1.49.dev15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- civics_cdf_validator-1.49.dev15.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
- civics_cdf_validator-1.49.dev15.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
- civics_cdf_validator-1.49.dev15.dist-info/RECORD,,
9
+ civics_cdf_validator/version.py,sha256=WLrSpq7U81dytfS7H3E2IaTVsV4NmW3ya1aL4650vSg,189
10
+ civics_cdf_validator-1.49.dev17.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
+ civics_cdf_validator-1.49.dev17.dist-info/METADATA,sha256=lUep_VsVfQHH1waP5IY0-4PK_o-GimjoT1sPeF8oTWw,1009
12
+ civics_cdf_validator-1.49.dev17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ civics_cdf_validator-1.49.dev17.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
+ civics_cdf_validator-1.49.dev17.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
+ civics_cdf_validator-1.49.dev17.dist-info/RECORD,,