civics-cdf-validator 1.52.dev5__py3-none-any.whl → 1.53__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/rules.py +45 -19
- civics_cdf_validator/version.py +1 -1
- {civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/METADATA +1 -1
- civics_cdf_validator-1.53.dist-info/RECORD +15 -0
- civics_cdf_validator-1.52.dev5.dist-info/RECORD +0 -15
- {civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/WHEEL +0 -0
- {civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/entry_points.txt +0 -0
- {civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/licenses/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/top_level.txt +0 -0
civics_cdf_validator/rules.py
CHANGED
|
@@ -118,9 +118,29 @@ def _has_government_body(element):
|
|
|
118
118
|
return bool(governmental_body or government_body)
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
def get_external_id_values(
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
def get_external_id_values(
|
|
122
|
+
element, value_type, return_elements=False, search_subelements=True
|
|
123
|
+
):
|
|
124
|
+
"""Helper to gather all Values of external ids for a given type.
|
|
125
|
+
|
|
126
|
+
If search_subelements is True, will search all subelements, if False, will
|
|
127
|
+
only search child elements.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
element: element to be processed
|
|
131
|
+
value_type: external id value type
|
|
132
|
+
return_elements: Boolean if True return elements, if False return values.
|
|
133
|
+
search_subelements: Boolean to instruct the function to recursively search
|
|
134
|
+
subelements.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
A list of external id values or external identifier elements
|
|
138
|
+
"""
|
|
139
|
+
external_ids = []
|
|
140
|
+
if search_subelements:
|
|
141
|
+
external_ids = element.findall(".//ExternalIdentifier")
|
|
142
|
+
else:
|
|
143
|
+
external_ids = element.findall("ExternalIdentifiers/ExternalIdentifier")
|
|
124
144
|
values = []
|
|
125
145
|
for extern_id in external_ids:
|
|
126
146
|
id_type = extern_id.find("Type")
|
|
@@ -1608,26 +1628,23 @@ class UniqueStableID(base.TreeRule):
|
|
|
1608
1628
|
Add an error message if stable id is not unique
|
|
1609
1629
|
"""
|
|
1610
1630
|
|
|
1611
|
-
_TOP_LEVEL_ENTITIES = frozenset(
|
|
1612
|
-
["Party", "GpUnit", "Office", "Person", "Candidate", "Contest"]
|
|
1613
|
-
)
|
|
1614
|
-
|
|
1615
1631
|
def check(self):
|
|
1616
1632
|
error_log = []
|
|
1617
1633
|
stable_obj_dict = dict()
|
|
1618
1634
|
for _, element in etree.iterwalk(self.election_tree, events=("end",)):
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1635
|
+
stable_ids = get_external_id_values(
|
|
1636
|
+
element, "stable", search_subelements=False
|
|
1637
|
+
)
|
|
1638
|
+
if not stable_ids:
|
|
1639
|
+
continue
|
|
1640
|
+
elem_id = self._get_object_id_or_name(element)
|
|
1641
|
+
for stable_id in stable_ids:
|
|
1642
|
+
if stable_id in stable_obj_dict.keys():
|
|
1643
|
+
stable_obj_dict.get(stable_id).append(elem_id)
|
|
1644
|
+
else:
|
|
1645
|
+
elem_id_list = []
|
|
1646
|
+
elem_id_list.append(elem_id)
|
|
1647
|
+
stable_obj_dict[stable_id] = elem_id_list
|
|
1631
1648
|
for k, v in stable_obj_dict.items():
|
|
1632
1649
|
if len(v) > 1:
|
|
1633
1650
|
error_message = (
|
|
@@ -1637,6 +1654,15 @@ class UniqueStableID(base.TreeRule):
|
|
|
1637
1654
|
if error_log:
|
|
1638
1655
|
raise loggers.ElectionError(error_log)
|
|
1639
1656
|
|
|
1657
|
+
def _get_object_id_or_name(self, element):
|
|
1658
|
+
if "objectId" in element.attrib:
|
|
1659
|
+
return element.get("objectId")
|
|
1660
|
+
names_by_language = get_language_to_text_map(element.find("Name"))
|
|
1661
|
+
if "en" in names_by_language:
|
|
1662
|
+
return names_by_language["en"][0]
|
|
1663
|
+
for names in names_by_language.values():
|
|
1664
|
+
return names[0]
|
|
1665
|
+
|
|
1640
1666
|
|
|
1641
1667
|
class MissingStableIds(base.BaseRule):
|
|
1642
1668
|
"""Check that each NIST object in the feed have a stable Id.
|
civics_cdf_validator/version.py
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,16954
|
|
3
|
+
civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
|
|
4
|
+
civics_cdf_validator/loggers.py,sha256=ZfWFd9yskcd2-qb83EPz7eqa1iGO8BRFMtDZeE1hofA,6921
|
|
5
|
+
civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
|
|
6
|
+
civics_cdf_validator/rules.py,sha256=hgqv23VXT9ULdQPZyVhpETZIADxCAaNm0Pntv9OZXQ8,165601
|
|
7
|
+
civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
|
|
8
|
+
civics_cdf_validator/validator.py,sha256=2nwlFfQ9AmpTaO5n5ekaO845Rm0JPjNF-Il6FJW_50k,12678
|
|
9
|
+
civics_cdf_validator/version.py,sha256=bfUj9c5TbEisoS1bLYVa1gFNUROEk2zqnuLGPVDfoQU,183
|
|
10
|
+
civics_cdf_validator-1.53.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
11
|
+
civics_cdf_validator-1.53.dist-info/METADATA,sha256=HOlyWI9aHO282KaX0WwoCrLFrAKXHwDIwNbxL1qjLuQ,1003
|
|
12
|
+
civics_cdf_validator-1.53.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
civics_cdf_validator-1.53.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
|
|
14
|
+
civics_cdf_validator-1.53.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
|
|
15
|
+
civics_cdf_validator-1.53.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
civics_cdf_validator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,16954
|
|
3
|
-
civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
|
|
4
|
-
civics_cdf_validator/loggers.py,sha256=ZfWFd9yskcd2-qb83EPz7eqa1iGO8BRFMtDZeE1hofA,6921
|
|
5
|
-
civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
|
|
6
|
-
civics_cdf_validator/rules.py,sha256=5A4q8CKeKmYYIK7KvjTQ9hN-F1A8RUY6fd_CB_OCn54,164869
|
|
7
|
-
civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
|
|
8
|
-
civics_cdf_validator/validator.py,sha256=2nwlFfQ9AmpTaO5n5ekaO845Rm0JPjNF-Il6FJW_50k,12678
|
|
9
|
-
civics_cdf_validator/version.py,sha256=zGZfykrA4a3AI2f--8fdnTV_gvJ1dYrr_tfIq1AKcwA,188
|
|
10
|
-
civics_cdf_validator-1.52.dev5.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
11
|
-
civics_cdf_validator-1.52.dev5.dist-info/METADATA,sha256=Gub889J6BJZDtPiiZzqdjRHL5lHNovA9my6W0biH9Ng,1008
|
|
12
|
-
civics_cdf_validator-1.52.dev5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
-
civics_cdf_validator-1.52.dev5.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
|
|
14
|
-
civics_cdf_validator-1.52.dev5.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
|
|
15
|
-
civics_cdf_validator-1.52.dev5.dist-info/RECORD,,
|
|
File without changes
|
{civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.52.dev5.dist-info → civics_cdf_validator-1.53.dist-info}/top_level.txt
RENAMED
|
File without changes
|