civics-cdf-validator 1.68.dev7__py3-none-any.whl → 1.68.dev9__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.
- civics_cdf_validator/base.py +7 -13
- civics_cdf_validator/rulesets/committee_rules.py +2 -2
- civics_cdf_validator/rulesets/common_rules.py +19 -23
- civics_cdf_validator/rulesets/election_rules.py +3 -5
- civics_cdf_validator/rulesets/officeholder_rules.py +5 -5
- civics_cdf_validator/version.py +1 -1
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/METADATA +1 -1
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/RECORD +12 -12
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/WHEEL +0 -0
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/entry_points.txt +0 -0
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/licenses/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/top_level.txt +0 -0
civics_cdf_validator/base.py
CHANGED
|
@@ -64,7 +64,9 @@ class SchemaHandler(object):
|
|
|
64
64
|
class BaseRule(SchemaHandler):
|
|
65
65
|
"""Base class for rules."""
|
|
66
66
|
|
|
67
|
-
def __init__(
|
|
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
|
-
|
|
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,
|
|
173
|
-
super(DateRule, self).__init__(
|
|
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
|
|
@@ -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,
|
|
62
|
-
super(EinMatchesFormat, self).__init__(
|
|
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,
|
|
186
|
-
super(OptionalAndEmpty, self).__init__(
|
|
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,
|
|
290
|
-
super(ValidIDREF, self).__init__(
|
|
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,
|
|
386
|
-
super(ValidStableID, self).__init__(
|
|
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,
|
|
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,
|
|
608
|
-
super(UniqueLabel, self).__init__(
|
|
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,
|
|
1045
|
+
def __init__(self, *args, **kwargs):
|
|
1048
1046
|
super(PartyLeadershipMustExist, self).__init__(
|
|
1049
|
-
|
|
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,
|
|
1380
|
+
def __init__(self, *args, **kwargs):
|
|
1383
1381
|
super(ValidJurisdictionID, self).__init__(
|
|
1384
|
-
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
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(
|
|
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:
|
civics_cdf_validator/version.py
CHANGED
{civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/RECORD
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
civics_cdf_validator/base.py,sha256=
|
|
2
|
+
civics_cdf_validator/base.py,sha256=Jc9FbgFUH1fD0dMWBxtDjYKCLzf3TjMPdgERVz1YmkI,17449
|
|
3
3
|
civics_cdf_validator/gpunit_rules.py,sha256=yY04IIhI1AzA_rM_IPPMg1CiGvTuXmYJYIgH23UAFL0,12711
|
|
4
4
|
civics_cdf_validator/loggers.py,sha256=ZfWFd9yskcd2-qb83EPz7eqa1iGO8BRFMtDZeE1hofA,6921
|
|
5
5
|
civics_cdf_validator/office_utils.py,sha256=4r0zc6-UB2YdqmUnGznEn5K5WLFRsQNQr-QMrFPo-xc,2721
|
|
6
6
|
civics_cdf_validator/rules.py,sha256=pFNjypzFO9ErXHui7vbPXypWL90-c8j2_gBN3OBRuXQ,2043
|
|
7
7
|
civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
|
|
8
8
|
civics_cdf_validator/validator.py,sha256=cnPwMDo4fZK4kIG_HDxJ_wxJooNuzciM6gsc0PxMmuc,12988
|
|
9
|
-
civics_cdf_validator/version.py,sha256=
|
|
9
|
+
civics_cdf_validator/version.py,sha256=PFdkF2KnFj8Q4AbZzppfSiC-a0wirBssuCED3J7gN9g,188
|
|
10
10
|
civics_cdf_validator/rulesets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
civics_cdf_validator/rulesets/committee_rules.py,sha256=
|
|
12
|
-
civics_cdf_validator/rulesets/common_rules.py,sha256=
|
|
11
|
+
civics_cdf_validator/rulesets/committee_rules.py,sha256=uffLyvSLm_lvy7XHsfDTx4uOif4Qaaqgfso35SnsQT8,3430
|
|
12
|
+
civics_cdf_validator/rulesets/common_rules.py,sha256=XQ5hYMftPkiIJjECoKphXtGZby2Cq28jnPb21QmrKv0,71892
|
|
13
13
|
civics_cdf_validator/rulesets/election_dates_rules.py,sha256=mIOKroJ2z5QI5C_i8JR2fNUuZ_e8DJ3juEB07v8tONY,1363
|
|
14
|
-
civics_cdf_validator/rulesets/election_rules.py,sha256=
|
|
14
|
+
civics_cdf_validator/rulesets/election_rules.py,sha256=qIEV0fkBPeOZfkA01TZ-1zWX1AlHCkcs6v6_6wkull4,86496
|
|
15
15
|
civics_cdf_validator/rulesets/metadata_rules.py,sha256=qkD_8gONLb6XWz9mY9ZutT6ZGgeFySJwbiog8mjdgB8,16171
|
|
16
|
-
civics_cdf_validator/rulesets/officeholder_rules.py,sha256=
|
|
16
|
+
civics_cdf_validator/rulesets/officeholder_rules.py,sha256=We472oJaGywm2XnjpmgEtG74fP4BnDhiIjpVVXzeeCc,17101
|
|
17
17
|
civics_cdf_validator/rulesets/rule_util.py,sha256=FWi09R7XWDfZwuHl-k2vhsFHlKuOrD5MD5YQ4QUQyVo,4431
|
|
18
18
|
civics_cdf_validator/rulesets/voter_information_rules.py,sha256=F5Kk2xndDIhh_bBUUJrk8JSCnGwTotdNdcZiCl1BKnw,4783
|
|
19
|
-
civics_cdf_validator-1.68.
|
|
20
|
-
civics_cdf_validator-1.68.
|
|
21
|
-
civics_cdf_validator-1.68.
|
|
22
|
-
civics_cdf_validator-1.68.
|
|
23
|
-
civics_cdf_validator-1.68.
|
|
24
|
-
civics_cdf_validator-1.68.
|
|
19
|
+
civics_cdf_validator-1.68.dev9.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
20
|
+
civics_cdf_validator-1.68.dev9.dist-info/METADATA,sha256=7ikntpBUvh97PRiKuMq1oMkMLhgtz4Oa_DqmHIGVBTo,1280
|
|
21
|
+
civics_cdf_validator-1.68.dev9.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
22
|
+
civics_cdf_validator-1.68.dev9.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
|
|
23
|
+
civics_cdf_validator-1.68.dev9.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
|
|
24
|
+
civics_cdf_validator-1.68.dev9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.68.dev7.dist-info → civics_cdf_validator-1.68.dev9.dist-info}/top_level.txt
RENAMED
|
File without changes
|