civics-cdf-validator 1.49.dev11__py3-none-any.whl → 1.49.dev12__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 +31 -5
- civics_cdf_validator/version.py +1 -1
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/METADATA +1 -1
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/RECORD +8 -8
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/WHEEL +0 -0
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/entry_points.txt +0 -0
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/licenses/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/top_level.txt +0 -0
civics_cdf_validator/rules.py
CHANGED
|
@@ -96,8 +96,14 @@ _VALID_OFFICE_ROLE_COMBINATIONS = frozenset([
|
|
|
96
96
|
])
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
def
|
|
100
|
-
|
|
99
|
+
def _get_office_roles(element, is_post_office_split_feed=False):
|
|
100
|
+
if is_post_office_split_feed:
|
|
101
|
+
return [element.text for element in element.findall("OfficeRole")]
|
|
102
|
+
return get_entity_info_for_value_type(element, "office-role")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _is_executive_office(element, is_post_office_split_feed=False):
|
|
106
|
+
office_roles = _get_office_roles(element, is_post_office_split_feed)
|
|
101
107
|
return not _EXECUTIVE_OFFICE_ROLES.isdisjoint(office_roles)
|
|
102
108
|
|
|
103
109
|
|
|
@@ -3454,11 +3460,21 @@ class PartySpanMultipleCountries(base.BaseRule):
|
|
|
3454
3460
|
class NonExecutiveOfficeShouldHaveGovernmentBody(base.BaseRule):
|
|
3455
3461
|
"""Ensure non-executive Office elements have a government body defined."""
|
|
3456
3462
|
|
|
3463
|
+
def __init__(self, election_tree, schema_tree, **kwargs):
|
|
3464
|
+
self.is_post_office_split_feed = False
|
|
3465
|
+
officeholder_tenure_collection_element = self.get_elements_by_class(
|
|
3466
|
+
election_tree, "OfficeHolderTenureCollection"
|
|
3467
|
+
)
|
|
3468
|
+
if officeholder_tenure_collection_element:
|
|
3469
|
+
self.is_post_office_split_feed = True
|
|
3470
|
+
|
|
3457
3471
|
def elements(self):
|
|
3458
3472
|
return ["Office"]
|
|
3459
3473
|
|
|
3460
3474
|
def check(self, element):
|
|
3461
|
-
if not _is_executive_office(
|
|
3475
|
+
if not _is_executive_office(
|
|
3476
|
+
element, self.is_post_office_split_feed
|
|
3477
|
+
) and not _has_government_body(element):
|
|
3462
3478
|
raise loggers.ElectionInfo.from_message(
|
|
3463
3479
|
"Non-executive Office element is missing a government body.",
|
|
3464
3480
|
[element],
|
|
@@ -3468,12 +3484,22 @@ class NonExecutiveOfficeShouldHaveGovernmentBody(base.BaseRule):
|
|
|
3468
3484
|
class ExecutiveOfficeShouldNotHaveGovernmentBody(base.BaseRule):
|
|
3469
3485
|
"""Ensure executive Office elements do not have a government body defined."""
|
|
3470
3486
|
|
|
3487
|
+
def __init__(self, election_tree, schema_tree, **kwargs):
|
|
3488
|
+
self.is_post_office_split_feed = False
|
|
3489
|
+
officeholder_tenure_collection_element = self.get_elements_by_class(
|
|
3490
|
+
election_tree, "OfficeHolderTenureCollection"
|
|
3491
|
+
)
|
|
3492
|
+
if officeholder_tenure_collection_element:
|
|
3493
|
+
self.is_post_office_split_feed = True
|
|
3494
|
+
|
|
3471
3495
|
def elements(self):
|
|
3472
3496
|
return ["Office"]
|
|
3473
3497
|
|
|
3474
3498
|
def check(self, element):
|
|
3475
|
-
if _is_executive_office(
|
|
3476
|
-
|
|
3499
|
+
if _is_executive_office(
|
|
3500
|
+
element, self.is_post_office_split_feed
|
|
3501
|
+
) and _has_government_body(element):
|
|
3502
|
+
office_roles = _get_office_roles(element, self.is_post_office_split_feed)
|
|
3477
3503
|
raise loggers.ElectionError.from_message(
|
|
3478
3504
|
f"Executive Office element (roles: {','.join(office_roles)}) has a "
|
|
3479
3505
|
"government body. Executive offices should not have government "
|
civics_cdf_validator/version.py
CHANGED
{civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/RECORD
RENAMED
|
@@ -3,13 +3,13 @@ civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,
|
|
|
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=
|
|
6
|
+
civics_cdf_validator/rules.py,sha256=mQByCHxof6D0Ifw-SpfnlQcIbPLPaO7f6qPSTLIZGj8,159916
|
|
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=
|
|
10
|
-
civics_cdf_validator-1.49.
|
|
11
|
-
civics_cdf_validator-1.49.
|
|
12
|
-
civics_cdf_validator-1.49.
|
|
13
|
-
civics_cdf_validator-1.49.
|
|
14
|
-
civics_cdf_validator-1.49.
|
|
15
|
-
civics_cdf_validator-1.49.
|
|
9
|
+
civics_cdf_validator/version.py,sha256=XR8QyYKrxeV1eHqomROga81p7X4JpjgDXULUY7MGvQU,189
|
|
10
|
+
civics_cdf_validator-1.49.dev12.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
11
|
+
civics_cdf_validator-1.49.dev12.dist-info/METADATA,sha256=5cxrxIuKc_9jy4AY3mF2hlOt9br6zBmP57K8S-1xow0,1009
|
|
12
|
+
civics_cdf_validator-1.49.dev12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
13
|
+
civics_cdf_validator-1.49.dev12.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
|
|
14
|
+
civics_cdf_validator-1.49.dev12.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
|
|
15
|
+
civics_cdf_validator-1.49.dev12.dist-info/RECORD,,
|
{civics_cdf_validator-1.49.dev11.dist-info → civics_cdf_validator-1.49.dev12.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|