civics-cdf-validator 1.69.dev16__tar.gz → 1.69.dev18__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.
- {civics_cdf_validator-1.69.dev16/civics_cdf_validator.egg-info → civics_cdf_validator-1.69.dev18}/PKG-INFO +1 -1
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/committee_rules.py +0 -18
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/election_rules.py +39 -4
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/rule_util.py +10 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/version.py +1 -1
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/CONTRIBUTING.md +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/MANIFEST.in +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/README.md +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/__init__.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/base.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/civics_cdf_validator.egg-info/requires.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/civics_cdf_validator.egg-info/top_level.txt +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/gpunit_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/loggers.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/office_utils.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/__init__.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/common_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/election_dates_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/election_results_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/metadata_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/officeholder_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/voter_information_rules.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/setup.cfg +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/setup.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/stats.py +0 -0
- {civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/validator.py +0 -0
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/committee_rules.py
RENAMED
|
@@ -80,27 +80,9 @@ class EinMatchesFormat(base.BaseRule):
|
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
class AffiliationHasEitherPartyOrPerson(base.BaseRule):
|
|
84
|
-
"""Affiliation should contain either a Party or a Person objectId."""
|
|
85
|
-
|
|
86
|
-
def elements(self) -> list[str]:
|
|
87
|
-
return ["Affiliation"]
|
|
88
|
-
|
|
89
|
-
def check(self, element: etree._Element) -> None:
|
|
90
|
-
party_id = element.find("PartyId")
|
|
91
|
-
person_id = element.find("PersonId")
|
|
92
|
-
if not ((party_id is None) ^ (person_id is None)):
|
|
93
|
-
raise loggers.ElectionError.from_message(
|
|
94
|
-
"Affiliation must have one of: PartyId, PersonId. Cannot include"
|
|
95
|
-
" both.",
|
|
96
|
-
[element],
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
83
|
COMMITTEE_RULES = common_rules.COMMON_RULES + (
|
|
101
84
|
# go/keep-sorted start
|
|
102
85
|
AffiliationEndDateOccursAfterStartDate,
|
|
103
|
-
AffiliationHasEitherPartyOrPerson,
|
|
104
86
|
CommitteeClassificationEndDateOccursAfterStartDate,
|
|
105
87
|
EinMatchesFormat,
|
|
106
88
|
common_rules.ProhibitElectionData,
|
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/election_rules.py
RENAMED
|
@@ -42,6 +42,13 @@ _WINNER_POST_ELECTION_STATUSES = frozenset([
|
|
|
42
42
|
])
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
_SEATS_DELTA_VOTE_COUNT_TYPES = frozenset([
|
|
46
|
+
"seats-delta",
|
|
47
|
+
"seats-delta-institutional",
|
|
48
|
+
"seats-delta-mandate",
|
|
49
|
+
])
|
|
50
|
+
|
|
51
|
+
|
|
45
52
|
def _get_type_or_other_type(element: etree._Element) -> str:
|
|
46
53
|
"""Returns the OtherType text if Type is "other", else the Type text."""
|
|
47
54
|
type_element = element.find("Type")
|
|
@@ -90,7 +97,9 @@ class PercentSum(base.SchemaRule):
|
|
|
90
97
|
):
|
|
91
98
|
other_type = vote_counts.find("OtherType")
|
|
92
99
|
if other_type is not None and other_type.text == "total-percent":
|
|
93
|
-
|
|
100
|
+
count = rule_util.get_float(vote_counts.find("Count"))
|
|
101
|
+
if count is not None:
|
|
102
|
+
sum_percents += count
|
|
94
103
|
if not PercentSum.fuzzy_equals(
|
|
95
104
|
sum_percents, 0
|
|
96
105
|
) and not PercentSum.fuzzy_equals(sum_percents, 100):
|
|
@@ -777,6 +786,32 @@ class VoteCountValidSeatsDeltaTypes(base.SchemaRule):
|
|
|
777
786
|
)
|
|
778
787
|
|
|
779
788
|
|
|
789
|
+
class VoteCountsNotNegative(base.BaseRule):
|
|
790
|
+
"""Checks that every VoteCounts has a Count of zero or more.
|
|
791
|
+
|
|
792
|
+
Only seats-delta, seats-delta-mandate, and seats-delta-institutional
|
|
793
|
+
VoteCounts can be negative, since they report a change in the number of seats.
|
|
794
|
+
"""
|
|
795
|
+
|
|
796
|
+
def elements(self) -> list[str]:
|
|
797
|
+
return ["VoteCounts"]
|
|
798
|
+
|
|
799
|
+
def check(self, element: etree._Element) -> None:
|
|
800
|
+
count_element = element.find("Count")
|
|
801
|
+
count = rule_util.get_float(count_element)
|
|
802
|
+
if count is None:
|
|
803
|
+
return
|
|
804
|
+
vote_count_type = _get_type_or_other_type(element)
|
|
805
|
+
if count < 0 and vote_count_type not in _SEATS_DELTA_VOTE_COUNT_TYPES:
|
|
806
|
+
raise loggers.ElectionError.from_message(
|
|
807
|
+
f"VoteCounts of type '{vote_count_type}' has a negative Count of"
|
|
808
|
+
f" {count_element.text.strip()}. Only"
|
|
809
|
+
f" {', '.join(sorted(_SEATS_DELTA_VOTE_COUNT_TYPES))} VoteCounts"
|
|
810
|
+
" can be negative.",
|
|
811
|
+
[element],
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
|
|
780
815
|
class OfficeHasjurisdictionSameAsElectoralDistrict(base.BaseRule):
|
|
781
816
|
"""In election feeds, office has the electoral district same as jurisdiction."""
|
|
782
817
|
|
|
@@ -2335,10 +2370,9 @@ class ValidateIncludeInAggregationBallotSelections(base.BaseRule):
|
|
|
2335
2370
|
return count_by_type_and_gp_unit
|
|
2336
2371
|
|
|
2337
2372
|
for vote_counts in vote_counts_collection.findall("VoteCounts"):
|
|
2338
|
-
|
|
2339
|
-
if
|
|
2373
|
+
count = rule_util.get_float(vote_counts.find("Count"))
|
|
2374
|
+
if count is None:
|
|
2340
2375
|
continue
|
|
2341
|
-
count = float(count_element.text)
|
|
2342
2376
|
|
|
2343
2377
|
vote_count_type = _get_type_or_other_type(vote_counts)
|
|
2344
2378
|
gp_unit_id_element = vote_counts.find("GpUnitId")
|
|
@@ -2463,6 +2497,7 @@ ELECTION_RULES = common_rules.COMMON_RULES + (
|
|
|
2463
2497
|
ValidateSpecialBallotSelectionCountedInTotal,
|
|
2464
2498
|
VoteCountTypesCoherency,
|
|
2465
2499
|
VoteCountValidSeatsDeltaTypes,
|
|
2500
|
+
VoteCountsNotNegative,
|
|
2466
2501
|
WinnerCountLimit,
|
|
2467
2502
|
# go/keep-sorted end
|
|
2468
2503
|
)
|
|
@@ -148,6 +148,16 @@ def element_has_text(element: etree._Element | None) -> bool:
|
|
|
148
148
|
)
|
|
149
149
|
|
|
150
150
|
|
|
151
|
+
def get_float(element: etree._Element | None) -> float | None:
|
|
152
|
+
"""Returns the element's text as a float, or None if it isn't one."""
|
|
153
|
+
if not element_has_text(element):
|
|
154
|
+
return None
|
|
155
|
+
try:
|
|
156
|
+
return float(element.text.strip())
|
|
157
|
+
except ValueError:
|
|
158
|
+
return None
|
|
159
|
+
|
|
160
|
+
|
|
151
161
|
def country_code_is_valid(country_code: str) -> bool:
|
|
152
162
|
# EU is part of ISO 3166/MA
|
|
153
163
|
return (
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/common_rules.py
RENAMED
|
File without changes
|
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/election_dates_rules.py
RENAMED
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/metadata_rules.py
RENAMED
|
File without changes
|
{civics_cdf_validator-1.69.dev16 → civics_cdf_validator-1.69.dev18}/rulesets/officeholder_rules.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|