civics-cdf-validator 1.68.dev7__tar.gz → 1.68.dev9__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 (31) hide show
  1. {civics_cdf_validator-1.68.dev7/civics_cdf_validator.egg-info → civics_cdf_validator-1.68.dev9}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/base.py +7 -13
  3. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  4. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/committee_rules.py +2 -2
  5. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/common_rules.py +19 -23
  6. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/election_rules.py +3 -5
  7. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/officeholder_rules.py +5 -5
  8. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/version.py +1 -1
  9. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/CONTRIBUTING.md +0 -0
  10. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/LICENSE-2.0.txt +0 -0
  11. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/MANIFEST.in +0 -0
  12. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/README.md +0 -0
  13. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/__init__.py +0 -0
  14. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  15. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  16. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  17. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/civics_cdf_validator.egg-info/requires.txt +0 -0
  18. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  19. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/gpunit_rules.py +0 -0
  20. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/loggers.py +0 -0
  21. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/office_utils.py +0 -0
  22. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rules.py +0 -0
  23. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/__init__.py +0 -0
  24. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/election_dates_rules.py +0 -0
  25. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/metadata_rules.py +0 -0
  26. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/rule_util.py +0 -0
  27. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/rulesets/voter_information_rules.py +0 -0
  28. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/setup.cfg +0 -0
  29. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/setup.py +0 -0
  30. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/stats.py +0 -0
  31. {civics_cdf_validator-1.68.dev7 → civics_cdf_validator-1.68.dev9}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.68.dev7
3
+ Version: 1.68.dev9
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
@@ -64,7 +64,9 @@ class SchemaHandler(object):
64
64
  class BaseRule(SchemaHandler):
65
65
  """Base class for rules."""
66
66
 
67
- def __init__(self, election_tree, schema_tree, ocd_id_validator=None):
67
+ def __init__(
68
+ self, election_tree=None, schema_tree=None, ocd_id_validator=None
69
+ ):
68
70
  super(BaseRule, self).__init__()
69
71
  self.election_tree = election_tree
70
72
  self.schema_tree = schema_tree
@@ -123,16 +125,8 @@ class TreeRule(BaseRule):
123
125
  class ValidReferenceRule(TreeRule):
124
126
  """Rule that makes sure reference values are properly defined."""
125
127
 
126
- def __init__(
127
- self,
128
- election_tree,
129
- schema_tree,
130
- missing_element="data",
131
- **kwargs,
132
- ):
133
- super(ValidReferenceRule, self).__init__(
134
- election_tree, schema_tree, **kwargs
135
- )
128
+ def __init__(self, *args, missing_element="data", **kwargs):
129
+ super(ValidReferenceRule, self).__init__(*args, **kwargs)
136
130
  self.missing_element = missing_element
137
131
 
138
132
  def _gather_reference_values(self):
@@ -169,8 +163,8 @@ class DateRule(BaseRule):
169
163
  end date values.
170
164
  """
171
165
 
172
- def __init__(self, election_tree, schema_file, **kwargs):
173
- super(DateRule, self).__init__(election_tree, schema_file, **kwargs)
166
+ def __init__(self, *args, **kwargs):
167
+ super(DateRule, self).__init__(*args, **kwargs)
174
168
  self.start_elem = None
175
169
  self.start_date = None
176
170
  self.end_elem = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.68.dev7
3
+ Version: 1.68.dev9
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
@@ -58,8 +58,8 @@ class AffiliationEndDateOccursAfterStartDate(base.DateRule):
58
58
  class EinMatchesFormat(base.BaseRule):
59
59
  """EIN id should be in the following format: XX-XXXXXXX."""
60
60
 
61
- def __init__(self, election_tree, schema_tree, **kwargs):
62
- super(EinMatchesFormat, self).__init__(election_tree, schema_tree, **kwargs)
61
+ def __init__(self, *args, **kwargs):
62
+ super(EinMatchesFormat, self).__init__(*args, **kwargs)
63
63
  regex = r"\d{2}(-\d{7})?"
64
64
  self.ein_id_matcher = re.compile(regex, flags=re.U)
65
65
 
@@ -182,8 +182,8 @@ class Schema(base.TreeRule):
182
182
  class OptionalAndEmpty(base.BaseRule):
183
183
  """Checks for optional and empty fields."""
184
184
 
185
- def __init__(self, election_tree, schema_tree, **kwargs):
186
- super(OptionalAndEmpty, self).__init__(election_tree, schema_tree, **kwargs)
185
+ def __init__(self, *args, **kwargs):
186
+ super(OptionalAndEmpty, self).__init__(*args, **kwargs)
187
187
  self.previous = None
188
188
 
189
189
  def elements(self):
@@ -286,8 +286,8 @@ class ValidIDREF(base.BaseRule):
286
286
  of the proper reference type for the given field.
287
287
  """
288
288
 
289
- def __init__(self, election_tree, schema_tree, **kwargs):
290
- super(ValidIDREF, self).__init__(election_tree, schema_tree, **kwargs)
289
+ def __init__(self, *args, **kwargs):
290
+ super(ValidIDREF, self).__init__(*args, **kwargs)
291
291
  self.object_id_mapping = {}
292
292
  self.element_reference_mapping = {}
293
293
 
@@ -382,8 +382,8 @@ class ValidIDREF(base.BaseRule):
382
382
  class ValidStableID(base.BaseRule):
383
383
  """Ensure stable-ids are in the correct format."""
384
384
 
385
- def __init__(self, election_tree, schema_tree, **kwargs):
386
- super(ValidStableID, self).__init__(election_tree, schema_tree, **kwargs)
385
+ def __init__(self, *args, **kwargs):
386
+ super(ValidStableID, self).__init__(*args, **kwargs)
387
387
  regex = r"^[a-zA-Z0-9_-]+$"
388
388
  self.stable_id_matcher = re.compile(regex, flags=re.U)
389
389
 
@@ -505,10 +505,8 @@ class DuplicateGpUnits(base.BaseRule):
505
505
  class GpUnitsCyclesRefsValidation(base.TreeRule):
506
506
  """Ensure that GpUnits form a valid tree and no cycles are present."""
507
507
 
508
- def __init__(self, election_tree, schema_tree, **kwargs):
509
- super(GpUnitsCyclesRefsValidation, self).__init__(
510
- election_tree, schema_tree, **kwargs
511
- )
508
+ def __init__(self, *args, **kwargs):
509
+ super(GpUnitsCyclesRefsValidation, self).__init__(*args, **kwargs)
512
510
  self.edges = dict() # Used to maintain the record of connected edges
513
511
  self.visited = {} # Used to store status of the nodes as visited or not.
514
512
  self.error_log = []
@@ -604,8 +602,8 @@ class OtherType(base.BaseRule):
604
602
  class UniqueLabel(base.BaseRule):
605
603
  """Labels should be unique within a file."""
606
604
 
607
- def __init__(self, election_tree, schema_tree, **kwargs):
608
- super(UniqueLabel, self).__init__(election_tree, schema_tree, **kwargs)
605
+ def __init__(self, *args, **kwargs):
606
+ super(UniqueLabel, self).__init__(*args, **kwargs)
609
607
  self.labels = set()
610
608
 
611
609
  def elements(self):
@@ -1044,9 +1042,9 @@ class ValidateOcdidLowerCase(base.BaseRule):
1044
1042
  class PartyLeadershipMustExist(base.ValidReferenceRule):
1045
1043
  """Each party leader or party chair should refer to a person in the feed."""
1046
1044
 
1047
- def __init__(self, election_tree, schema_tree, **kwargs):
1045
+ def __init__(self, *args, **kwargs):
1048
1046
  super(PartyLeadershipMustExist, self).__init__(
1049
- election_tree, schema_tree, "Person", **kwargs
1047
+ *args, missing_element="Person", **kwargs
1050
1048
  )
1051
1049
 
1052
1050
  def _gather_reference_values(self):
@@ -1379,9 +1377,9 @@ class OfficesHaveJurisdictionID(base.BaseRule):
1379
1377
  class ValidJurisdictionID(base.ValidReferenceRule):
1380
1378
  """Each jurisdiction id should refer to a valid GpUnit."""
1381
1379
 
1382
- def __init__(self, election_tree, schema_tree, **kwargs):
1380
+ def __init__(self, *args, **kwargs):
1383
1381
  super(ValidJurisdictionID, self).__init__(
1384
- election_tree, schema_tree, "GpUnit", **kwargs
1382
+ *args, missing_element="GpUnit", **kwargs
1385
1383
  )
1386
1384
 
1387
1385
  def _gather_reference_values(self):
@@ -1624,7 +1622,7 @@ class PartySpanMultipleCountries(base.BaseRule):
1624
1622
  sometimes correct, but we should flag it to double check.
1625
1623
  """
1626
1624
 
1627
- def __init__(self, election_tree, schema_tree, **kwargs):
1625
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
1628
1626
  super(PartySpanMultipleCountries, self).__init__(
1629
1627
  election_tree, schema_tree, **kwargs
1630
1628
  )
@@ -1670,7 +1668,7 @@ class PartySpanMultipleCountries(base.BaseRule):
1670
1668
  class NonExecutiveOfficeShouldHaveGovernmentBody(base.BaseRule):
1671
1669
  """Ensure non-Head of Government/State Office elements have a government body defined."""
1672
1670
 
1673
- def __init__(self, election_tree, schema_tree, **kwargs):
1671
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
1674
1672
  self.is_post_office_split_feed = False
1675
1673
  officeholder_tenure_collection_element = self.get_elements_by_class(
1676
1674
  election_tree, "OfficeHolderTenureCollection"
@@ -1696,7 +1694,7 @@ class NonExecutiveOfficeShouldHaveGovernmentBody(base.BaseRule):
1696
1694
  class ExecutiveOfficeShouldNotHaveGovernmentBody(base.BaseRule):
1697
1695
  """Ensure Head of Government/State Office elements do not have a government body defined."""
1698
1696
 
1699
- def __init__(self, election_tree, schema_tree, **kwargs):
1697
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
1700
1698
  self.is_post_office_split_feed = False
1701
1699
  officeholder_tenure_collection_element = self.get_elements_by_class(
1702
1700
  election_tree, "OfficeHolderTenureCollection"
@@ -2127,10 +2125,8 @@ class DateOfBirthIsInPast(base.DateRule):
2127
2125
  class GpUnitsHaveSingleRoot(base.TreeRule):
2128
2126
  """Ensure that GpUnits form a single-rooted tree."""
2129
2127
 
2130
- def __init__(self, election_tree, schema_tree, **kwargs):
2131
- super(GpUnitsHaveSingleRoot, self).__init__(
2132
- election_tree, schema_tree, **kwargs
2133
- )
2128
+ def __init__(self, *args, **kwargs):
2129
+ super(GpUnitsHaveSingleRoot, self).__init__(*args, **kwargs)
2134
2130
  self.error_log = []
2135
2131
 
2136
2132
  def check(self):
@@ -95,7 +95,7 @@ class PartisanPrimary(base.BaseRule):
95
95
 
96
96
  election_type = None
97
97
 
98
- def __init__(self, election_tree, schema_tree, **kwargs):
98
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
99
99
  super(PartisanPrimary, self).__init__(election_tree, schema_tree, **kwargs)
100
100
  # There can only be one election element in a file.
101
101
  election_elem = self.election_tree.find("Election")
@@ -177,10 +177,8 @@ class CandidatesReferencedInRelatedContests(base.BaseRule):
177
177
  can't span unrelated contests.
178
178
  """
179
179
 
180
- def __init__(self, election_tree, schema_tree, **kwargs):
181
- super(CandidatesReferencedInRelatedContests, self).__init__(
182
- election_tree, schema_tree, **kwargs
183
- )
180
+ def __init__(self, *args, **kwargs):
181
+ super(CandidatesReferencedInRelatedContests, self).__init__(*args, **kwargs)
184
182
  self.error_log = []
185
183
  self.contest_graph = networkx.Graph()
186
184
 
@@ -89,7 +89,7 @@ class OfficeSelectionMethodMatch(base.BaseRule):
89
89
  present in the list of SelectionMethods of the Office it points to.
90
90
  """
91
91
 
92
- def __init__(self, election_tree, schema_tree, **kwargs):
92
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
93
93
  self.office_selection_methods = {}
94
94
  officeholder_tenure_elements = self.get_elements_by_class(
95
95
  election_tree, "OfficeHolderTenure"
@@ -153,7 +153,7 @@ class OfficeTermDates(base.DateRule):
153
153
  not have a Term element.
154
154
  """
155
155
 
156
- def __init__(self, election_tree, schema_tree, **kwargs):
156
+ def __init__(self, election_tree, schema_tree=None, **kwargs):
157
157
  self.is_post_office_split_feed = False
158
158
  officeholder_tenure_collection_element = self.get_elements_by_class(
159
159
  election_tree, "OfficeHolderTenureCollection"
@@ -226,7 +226,7 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
226
226
  "OfficeHolderPersonId"
227
227
  )
228
228
  person_id = office_holder_person_elem.text
229
- date_validator = base.DateRule(None, None)
229
+ date_validator = base.DateRule()
230
230
  date_validator.gather_dates(officeholder_tenure)
231
231
  end_date = date_validator.end_date
232
232
  if end_date is not None:
@@ -291,7 +291,7 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
291
291
  person_office_dict[person_id] = [office.get("objectId")]
292
292
  term = office.find(".//Term")
293
293
  if term is not None:
294
- date_validator = base.DateRule(None, None)
294
+ date_validator = base.DateRule()
295
295
  date_validator.gather_dates(term)
296
296
  end_date_person = date_validator.end_date
297
297
  if end_date_person is not None:
@@ -337,7 +337,7 @@ class UniqueStartDatesForOfficeRoleAndJurisdiction(base.BaseRule):
337
337
  for office in offices:
338
338
  term = office.find(".//Term")
339
339
  if term is not None:
340
- date_validator = base.DateRule(None, None, ocd_id_validator=None)
340
+ date_validator = base.DateRule()
341
341
  try:
342
342
  date_validator.gather_dates(term)
343
343
  if date_validator.end_date is not None:
@@ -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.68.dev7'
8
+ __version__ = '1.68.dev9'