civics-cdf-validator 1.67.dev6__py3-none-any.whl → 1.67.dev7__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 +2 -121
- civics_cdf_validator/rulesets/voter_information_rules.py +143 -0
- civics_cdf_validator/version.py +1 -1
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/METADATA +1 -1
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/RECORD +9 -8
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/WHEEL +0 -0
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/entry_points.txt +0 -0
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/licenses/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/top_level.txt +0 -0
civics_cdf_validator/rules.py
CHANGED
|
@@ -27,6 +27,7 @@ from civics_cdf_validator.rulesets import election_dates_rules
|
|
|
27
27
|
from civics_cdf_validator.rulesets import election_rules
|
|
28
28
|
from civics_cdf_validator.rulesets import officeholder_rules
|
|
29
29
|
from civics_cdf_validator.rulesets import rule_util
|
|
30
|
+
from civics_cdf_validator.rulesets import voter_information_rules
|
|
30
31
|
import dateutil
|
|
31
32
|
from frozendict import frozendict
|
|
32
33
|
|
|
@@ -417,118 +418,6 @@ class FeedInactiveDateSetForNonEvergreenFeed(base.BaseRule):
|
|
|
417
418
|
)
|
|
418
419
|
|
|
419
420
|
|
|
420
|
-
class ElectoralCommissionCollectionExists(base.BaseRule):
|
|
421
|
-
"""ElectoralCommissionCollection should exist."""
|
|
422
|
-
|
|
423
|
-
def elements(self):
|
|
424
|
-
return ["ElectionReport"]
|
|
425
|
-
|
|
426
|
-
def check(self, element):
|
|
427
|
-
if element.find("ElectoralCommissionCollection") is None:
|
|
428
|
-
raise loggers.ElectionError.from_message(
|
|
429
|
-
"ElectoralCommissionCollection should exist."
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
class VoterInformationCollectionExists(base.BaseRule):
|
|
434
|
-
"""Warn if there is no VoterInformationCollection."""
|
|
435
|
-
|
|
436
|
-
def elements(self):
|
|
437
|
-
return ["ElectionReport"]
|
|
438
|
-
|
|
439
|
-
def check(self, element):
|
|
440
|
-
if element.find("VoterInformationCollection") is None:
|
|
441
|
-
raise loggers.ElectionWarning.from_message(
|
|
442
|
-
"VoterInformationCollection should exist."
|
|
443
|
-
)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
class NoExtraElectionElements(base.BaseRule):
|
|
447
|
-
"""Elections for voter information feeds should not have certain elements.
|
|
448
|
-
|
|
449
|
-
BallotStyleCollection, CandidateCollection, ContestCollection, CountStatus
|
|
450
|
-
should all be excluded.
|
|
451
|
-
"""
|
|
452
|
-
|
|
453
|
-
def elements(self):
|
|
454
|
-
return ["Election"]
|
|
455
|
-
|
|
456
|
-
def check(self, element):
|
|
457
|
-
if element.find("BallotStyleCollection") is not None:
|
|
458
|
-
raise loggers.ElectionError.from_message(
|
|
459
|
-
"BallotStyleCollection should not exist."
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
if element.find("CandidateCollection") is not None:
|
|
463
|
-
raise loggers.ElectionError.from_message(
|
|
464
|
-
"CandidateCollection should not exist."
|
|
465
|
-
)
|
|
466
|
-
if element.find("ContestCollection") is not None:
|
|
467
|
-
raise loggers.ElectionError.from_message(
|
|
468
|
-
"ContestCollection should not exist."
|
|
469
|
-
)
|
|
470
|
-
|
|
471
|
-
if element.find("CountStatus") is not None:
|
|
472
|
-
raise loggers.ElectionError.from_message("CountStatus should not exist.")
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
class WarnOnElementsNotRecommendedForElection(base.BaseRule):
|
|
476
|
-
"""Warn on ContactInformation on an Election for voter information feeds."""
|
|
477
|
-
|
|
478
|
-
def elements(self):
|
|
479
|
-
return ["Election"]
|
|
480
|
-
|
|
481
|
-
def check(self, element):
|
|
482
|
-
if element.find("ContactInformation") is not None:
|
|
483
|
-
raise loggers.ElectionWarning.from_message(
|
|
484
|
-
"ContactInformation is not recommended for Election, prefer using an"
|
|
485
|
-
" ElectionAdministration."
|
|
486
|
-
)
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
class NoExtraElectionReportCollections(base.BaseRule):
|
|
490
|
-
"""ElectionReports for voter information feeds should not have certain elements.
|
|
491
|
-
|
|
492
|
-
CommitteeCollection, GovernmentBodyCollection, OfficeCollection,
|
|
493
|
-
OfficeHolderTenureCollection, PartyCollection, PersonCollection should all be
|
|
494
|
-
excluded.
|
|
495
|
-
"""
|
|
496
|
-
|
|
497
|
-
def elements(self):
|
|
498
|
-
return ["ElectionReport"]
|
|
499
|
-
|
|
500
|
-
def check(self, element):
|
|
501
|
-
if element.find("CommitteeCollection") is not None:
|
|
502
|
-
raise loggers.ElectionError.from_message(
|
|
503
|
-
"CommitteeCollection should not exist."
|
|
504
|
-
)
|
|
505
|
-
|
|
506
|
-
if element.find("GovernmentBodyCollection") is not None:
|
|
507
|
-
raise loggers.ElectionError.from_message(
|
|
508
|
-
"GovernmentBodyCollection should not exist."
|
|
509
|
-
)
|
|
510
|
-
|
|
511
|
-
if element.find("OfficeCollection") is not None:
|
|
512
|
-
raise loggers.ElectionError.from_message(
|
|
513
|
-
"OfficeCollection should not exist."
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
if element.find("OfficeHolderTenureCollection") is not None:
|
|
517
|
-
raise loggers.ElectionError.from_message(
|
|
518
|
-
"OfficeHolderTenureCollection should not exist."
|
|
519
|
-
)
|
|
520
|
-
|
|
521
|
-
if element.find("PartyCollection") is not None:
|
|
522
|
-
raise loggers.ElectionError.from_message(
|
|
523
|
-
"PartyCollection should not exist."
|
|
524
|
-
)
|
|
525
|
-
|
|
526
|
-
if element.find("PersonCollection") is not None:
|
|
527
|
-
raise loggers.ElectionError.from_message(
|
|
528
|
-
"PersonCollection should not exist."
|
|
529
|
-
)
|
|
530
|
-
|
|
531
|
-
|
|
532
421
|
class FeedElementsShouldHaveSubElementsBasedOnType(base.BaseRule):
|
|
533
422
|
"""Feeds should have certain elements based on feed type.
|
|
534
423
|
|
|
@@ -587,6 +476,7 @@ OFFICEHOLDER_RULES = officeholder_rules.OFFICEHOLDER_RULES
|
|
|
587
476
|
ELECTION_RULES = election_rules.ELECTION_RULES
|
|
588
477
|
ELECTION_DATES_RULES = election_dates_rules.ELECTION_DATES_RULES
|
|
589
478
|
COMMITTEE_RULES = committee_rules.COMMITTEE_RULES
|
|
479
|
+
VOTER_INFORMATION_RULES = voter_information_rules.VOTER_INFORMATION_RULES
|
|
590
480
|
|
|
591
481
|
|
|
592
482
|
METADATA_RULES = (
|
|
@@ -614,15 +504,6 @@ METADATA_RULES = (
|
|
|
614
504
|
# go/keep-sorted end
|
|
615
505
|
)
|
|
616
506
|
|
|
617
|
-
VOTER_INFORMATION_RULES = COMMON_RULES + (
|
|
618
|
-
# go/keep-sorted start
|
|
619
|
-
ElectoralCommissionCollectionExists,
|
|
620
|
-
NoExtraElectionElements,
|
|
621
|
-
NoExtraElectionReportCollections,
|
|
622
|
-
VoterInformationCollectionExists,
|
|
623
|
-
WarnOnElementsNotRecommendedForElection,
|
|
624
|
-
# go/keep-sorted end
|
|
625
|
-
)
|
|
626
507
|
|
|
627
508
|
ALL_RULES = frozenset(
|
|
628
509
|
COMMON_RULES
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Copyright 2020 Google LLC
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
"""Validation rules for voter information feeds of the CDF XML validator."""
|
|
15
|
+
|
|
16
|
+
from __future__ import print_function
|
|
17
|
+
|
|
18
|
+
from civics_cdf_validator import base
|
|
19
|
+
from civics_cdf_validator import loggers
|
|
20
|
+
from civics_cdf_validator.rulesets import common_rules
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ElectoralCommissionCollectionExists(base.BaseRule):
|
|
24
|
+
"""ElectoralCommissionCollection should exist."""
|
|
25
|
+
|
|
26
|
+
def elements(self):
|
|
27
|
+
return ["ElectionReport"]
|
|
28
|
+
|
|
29
|
+
def check(self, element):
|
|
30
|
+
if element.find("ElectoralCommissionCollection") is None:
|
|
31
|
+
raise loggers.ElectionError.from_message(
|
|
32
|
+
"ElectoralCommissionCollection should exist."
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class VoterInformationCollectionExists(base.BaseRule):
|
|
37
|
+
"""Warn if there is no VoterInformationCollection."""
|
|
38
|
+
|
|
39
|
+
def elements(self):
|
|
40
|
+
return ["ElectionReport"]
|
|
41
|
+
|
|
42
|
+
def check(self, element):
|
|
43
|
+
if element.find("VoterInformationCollection") is None:
|
|
44
|
+
raise loggers.ElectionWarning.from_message(
|
|
45
|
+
"VoterInformationCollection should exist."
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class NoExtraElectionElements(base.BaseRule):
|
|
50
|
+
"""Elections for voter information feeds should not have certain elements.
|
|
51
|
+
|
|
52
|
+
BallotStyleCollection, CandidateCollection, ContestCollection, CountStatus
|
|
53
|
+
should all be excluded.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def elements(self):
|
|
57
|
+
return ["Election"]
|
|
58
|
+
|
|
59
|
+
def check(self, element):
|
|
60
|
+
if element.find("BallotStyleCollection") is not None:
|
|
61
|
+
raise loggers.ElectionError.from_message(
|
|
62
|
+
"BallotStyleCollection should not exist."
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if element.find("CandidateCollection") is not None:
|
|
66
|
+
raise loggers.ElectionError.from_message(
|
|
67
|
+
"CandidateCollection should not exist."
|
|
68
|
+
)
|
|
69
|
+
if element.find("ContestCollection") is not None:
|
|
70
|
+
raise loggers.ElectionError.from_message(
|
|
71
|
+
"ContestCollection should not exist."
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if element.find("CountStatus") is not None:
|
|
75
|
+
raise loggers.ElectionError.from_message("CountStatus should not exist.")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class WarnOnElementsNotRecommendedForElection(base.BaseRule):
|
|
79
|
+
"""Warn on ContactInformation on an Election for voter information feeds."""
|
|
80
|
+
|
|
81
|
+
def elements(self):
|
|
82
|
+
return ["Election"]
|
|
83
|
+
|
|
84
|
+
def check(self, element):
|
|
85
|
+
if element.find("ContactInformation") is not None:
|
|
86
|
+
raise loggers.ElectionWarning.from_message(
|
|
87
|
+
"ContactInformation is not recommended for Election, prefer using an"
|
|
88
|
+
" ElectionAdministration."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class NoExtraElectionReportCollections(base.BaseRule):
|
|
93
|
+
"""ElectionReports for voter information feeds should not have certain elements.
|
|
94
|
+
|
|
95
|
+
CommitteeCollection, GovernmentBodyCollection, OfficeCollection,
|
|
96
|
+
OfficeHolderTenureCollection, PartyCollection, PersonCollection should all be
|
|
97
|
+
excluded.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def elements(self):
|
|
101
|
+
return ["ElectionReport"]
|
|
102
|
+
|
|
103
|
+
def check(self, element):
|
|
104
|
+
if element.find("CommitteeCollection") is not None:
|
|
105
|
+
raise loggers.ElectionError.from_message(
|
|
106
|
+
"CommitteeCollection should not exist."
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if element.find("GovernmentBodyCollection") is not None:
|
|
110
|
+
raise loggers.ElectionError.from_message(
|
|
111
|
+
"GovernmentBodyCollection should not exist."
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
if element.find("OfficeCollection") is not None:
|
|
115
|
+
raise loggers.ElectionError.from_message(
|
|
116
|
+
"OfficeCollection should not exist."
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if element.find("OfficeHolderTenureCollection") is not None:
|
|
120
|
+
raise loggers.ElectionError.from_message(
|
|
121
|
+
"OfficeHolderTenureCollection should not exist."
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
if element.find("PartyCollection") is not None:
|
|
125
|
+
raise loggers.ElectionError.from_message(
|
|
126
|
+
"PartyCollection should not exist."
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
if element.find("PersonCollection") is not None:
|
|
130
|
+
raise loggers.ElectionError.from_message(
|
|
131
|
+
"PersonCollection should not exist."
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
VOTER_INFORMATION_RULES = common_rules.COMMON_RULES + (
|
|
136
|
+
# go/keep-sorted start
|
|
137
|
+
ElectoralCommissionCollectionExists,
|
|
138
|
+
NoExtraElectionElements,
|
|
139
|
+
NoExtraElectionReportCollections,
|
|
140
|
+
VoterInformationCollectionExists,
|
|
141
|
+
WarnOnElementsNotRecommendedForElection,
|
|
142
|
+
# go/keep-sorted end
|
|
143
|
+
)
|
civics_cdf_validator/version.py
CHANGED
{civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/RECORD
RENAMED
|
@@ -3,10 +3,10 @@ civics_cdf_validator/base.py,sha256=o2dbEJ4haD4ddA6tGHuV_VApe_7DaslFspDb2IZ3GsY,
|
|
|
3
3
|
civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
|
|
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
|
-
civics_cdf_validator/rules.py,sha256=
|
|
6
|
+
civics_cdf_validator/rules.py,sha256=2IOVEhAmeX8zKldt3itgcZgjzHzlSfVQVCb6JYOleEA,17263
|
|
7
7
|
civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
|
|
8
8
|
civics_cdf_validator/validator.py,sha256=OHXg-VngDdovYyBh0ON5M_vvA8PyKTzvfzR8SwZbEf8,12770
|
|
9
|
-
civics_cdf_validator/version.py,sha256=
|
|
9
|
+
civics_cdf_validator/version.py,sha256=S-qf3HD4Ry2zAaOiXaFqS8ANuGOM8EjHNOikmQXvKz4,188
|
|
10
10
|
civics_cdf_validator/rulesets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
civics_cdf_validator/rulesets/committee_rules.py,sha256=0hNnpzI-ptZDxErbH2D2r66IiIiioqVXSV3YxgXlhrE,3472
|
|
12
12
|
civics_cdf_validator/rulesets/common_rules.py,sha256=vCcodXrykZBx-RHCX8J-zsUxwEFCEIl0WARkn4cm6fE,59417
|
|
@@ -14,9 +14,10 @@ civics_cdf_validator/rulesets/election_dates_rules.py,sha256=mIOKroJ2z5QI5C_i8JR
|
|
|
14
14
|
civics_cdf_validator/rulesets/election_rules.py,sha256=ldLXfYgJ3YbapIVZclQPmDemki-txOTOqrp_k8WgSS0,95874
|
|
15
15
|
civics_cdf_validator/rulesets/officeholder_rules.py,sha256=N5G5Gum685ACXnb0Kwd5DseaCHOOpg3gpYK_uivAegQ,17766
|
|
16
16
|
civics_cdf_validator/rulesets/rule_util.py,sha256=FWi09R7XWDfZwuHl-k2vhsFHlKuOrD5MD5YQ4QUQyVo,4431
|
|
17
|
-
civics_cdf_validator
|
|
18
|
-
civics_cdf_validator-1.67.
|
|
19
|
-
civics_cdf_validator-1.67.
|
|
20
|
-
civics_cdf_validator-1.67.
|
|
21
|
-
civics_cdf_validator-1.67.
|
|
22
|
-
civics_cdf_validator-1.67.
|
|
17
|
+
civics_cdf_validator/rulesets/voter_information_rules.py,sha256=9IyZRoSgaTF87K_NYJQ43C9wotwz6Wf0XOobJwv5lG8,4611
|
|
18
|
+
civics_cdf_validator-1.67.dev7.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
19
|
+
civics_cdf_validator-1.67.dev7.dist-info/METADATA,sha256=YTOeR-weNZDjWNPIiogRGKNYfJjpJqPFRm5yZcW5bF8,1280
|
|
20
|
+
civics_cdf_validator-1.67.dev7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
21
|
+
civics_cdf_validator-1.67.dev7.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
|
|
22
|
+
civics_cdf_validator-1.67.dev7.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
|
|
23
|
+
civics_cdf_validator-1.67.dev7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.67.dev6.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/top_level.txt
RENAMED
|
File without changes
|