civics-cdf-validator 1.67.dev5__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 +4 -206
- civics_cdf_validator/rulesets/committee_rules.py +107 -0
- civics_cdf_validator/rulesets/voter_information_rules.py +143 -0
- civics_cdf_validator/version.py +1 -1
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/METADATA +1 -1
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/RECORD +10 -8
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/WHEEL +0 -0
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/entry_points.txt +0 -0
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/licenses/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.67.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/top_level.txt +0 -0
civics_cdf_validator/rules.py
CHANGED
|
@@ -17,16 +17,17 @@ from __future__ import print_function
|
|
|
17
17
|
|
|
18
18
|
import datetime
|
|
19
19
|
import enum
|
|
20
|
-
import re
|
|
21
20
|
|
|
22
21
|
from botocore import utils as botocore_utils
|
|
23
22
|
from civics_cdf_validator import base
|
|
24
23
|
from civics_cdf_validator import loggers
|
|
24
|
+
from civics_cdf_validator.rulesets import committee_rules
|
|
25
25
|
from civics_cdf_validator.rulesets import common_rules
|
|
26
26
|
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
|
|
|
@@ -40,79 +41,6 @@ _VALID_FEED_LONGEVITY_BY_FEED_TYPE = frozendict({
|
|
|
40
41
|
})
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
class CommitteeClassificationEndDateOccursAfterStartDate(base.DateRule):
|
|
44
|
-
"""CommitteeClassification elements should have end dates that occur after the start dates."""
|
|
45
|
-
|
|
46
|
-
def elements(self):
|
|
47
|
-
return ["CommitteeClassification"]
|
|
48
|
-
|
|
49
|
-
def check(self, element):
|
|
50
|
-
self.reset_instance_vars()
|
|
51
|
-
self.gather_dates(element)
|
|
52
|
-
|
|
53
|
-
if self.end_date and self.start_date:
|
|
54
|
-
self.check_end_after_start()
|
|
55
|
-
if self.error_log:
|
|
56
|
-
raise loggers.ElectionError(self.error_log)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class AffiliationEndDateOccursAfterStartDate(base.DateRule):
|
|
60
|
-
"""Affiliation elements should have end dates that occur after the start dates."""
|
|
61
|
-
|
|
62
|
-
def elements(self):
|
|
63
|
-
return ["Affiliation"]
|
|
64
|
-
|
|
65
|
-
def check(self, element):
|
|
66
|
-
self.reset_instance_vars()
|
|
67
|
-
self.gather_dates(element)
|
|
68
|
-
|
|
69
|
-
if self.end_date and self.start_date:
|
|
70
|
-
self.check_end_after_start()
|
|
71
|
-
if self.error_log:
|
|
72
|
-
raise loggers.ElectionError(self.error_log)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class EinMatchesFormat(base.BaseRule):
|
|
76
|
-
"""EIN id should be in the following format: XX-XXXXXXX."""
|
|
77
|
-
|
|
78
|
-
def __init__(self, election_tree, schema_tree, **kwargs):
|
|
79
|
-
super(EinMatchesFormat, self).__init__(election_tree, schema_tree, **kwargs)
|
|
80
|
-
regex = r"\d{2}(-\d{7})?"
|
|
81
|
-
self.ein_id_matcher = re.compile(regex, flags=re.U)
|
|
82
|
-
|
|
83
|
-
def elements(self):
|
|
84
|
-
return ["Committee"]
|
|
85
|
-
|
|
86
|
-
def check(self, element):
|
|
87
|
-
external_identifiers = element.find("ExternalIdentifiers")
|
|
88
|
-
if external_identifiers is not None:
|
|
89
|
-
ein_ids = rule_util.get_external_id_values(external_identifiers, "ein")
|
|
90
|
-
if ein_ids:
|
|
91
|
-
e_id = ein_ids.pop()
|
|
92
|
-
if not self.ein_id_matcher.match(e_id):
|
|
93
|
-
raise loggers.ElectionError.from_message(
|
|
94
|
-
"EIN id '{}' is not in the correct format.".format(e_id),
|
|
95
|
-
[element],
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
class AffiliationHasEitherPartyOrPerson(base.BaseRule):
|
|
100
|
-
"""Affiliation should contain either a Party or a Person objectId."""
|
|
101
|
-
|
|
102
|
-
def elements(self):
|
|
103
|
-
return ["Affiliation"]
|
|
104
|
-
|
|
105
|
-
def check(self, element):
|
|
106
|
-
party_id = element.find("PartyId")
|
|
107
|
-
person_id = element.find("PersonId")
|
|
108
|
-
if not ((party_id is None) ^ (person_id is None)):
|
|
109
|
-
raise loggers.ElectionError.from_message(
|
|
110
|
-
"Affiliation must have one of: PartyId, PersonId. Cannot include"
|
|
111
|
-
" both.",
|
|
112
|
-
[element],
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
44
|
class FeedTypeHasValidFeedLongevity(base.BaseRule):
|
|
117
45
|
"""Feeds types should have valid corresponding FeedLongevity."""
|
|
118
46
|
|
|
@@ -490,118 +418,6 @@ class FeedInactiveDateSetForNonEvergreenFeed(base.BaseRule):
|
|
|
490
418
|
)
|
|
491
419
|
|
|
492
420
|
|
|
493
|
-
class ElectoralCommissionCollectionExists(base.BaseRule):
|
|
494
|
-
"""ElectoralCommissionCollection should exist."""
|
|
495
|
-
|
|
496
|
-
def elements(self):
|
|
497
|
-
return ["ElectionReport"]
|
|
498
|
-
|
|
499
|
-
def check(self, element):
|
|
500
|
-
if element.find("ElectoralCommissionCollection") is None:
|
|
501
|
-
raise loggers.ElectionError.from_message(
|
|
502
|
-
"ElectoralCommissionCollection should exist."
|
|
503
|
-
)
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
class VoterInformationCollectionExists(base.BaseRule):
|
|
507
|
-
"""Warn if there is no VoterInformationCollection."""
|
|
508
|
-
|
|
509
|
-
def elements(self):
|
|
510
|
-
return ["ElectionReport"]
|
|
511
|
-
|
|
512
|
-
def check(self, element):
|
|
513
|
-
if element.find("VoterInformationCollection") is None:
|
|
514
|
-
raise loggers.ElectionWarning.from_message(
|
|
515
|
-
"VoterInformationCollection should exist."
|
|
516
|
-
)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
class NoExtraElectionElements(base.BaseRule):
|
|
520
|
-
"""Elections for voter information feeds should not have certain elements.
|
|
521
|
-
|
|
522
|
-
BallotStyleCollection, CandidateCollection, ContestCollection, CountStatus
|
|
523
|
-
should all be excluded.
|
|
524
|
-
"""
|
|
525
|
-
|
|
526
|
-
def elements(self):
|
|
527
|
-
return ["Election"]
|
|
528
|
-
|
|
529
|
-
def check(self, element):
|
|
530
|
-
if element.find("BallotStyleCollection") is not None:
|
|
531
|
-
raise loggers.ElectionError.from_message(
|
|
532
|
-
"BallotStyleCollection should not exist."
|
|
533
|
-
)
|
|
534
|
-
|
|
535
|
-
if element.find("CandidateCollection") is not None:
|
|
536
|
-
raise loggers.ElectionError.from_message(
|
|
537
|
-
"CandidateCollection should not exist."
|
|
538
|
-
)
|
|
539
|
-
if element.find("ContestCollection") is not None:
|
|
540
|
-
raise loggers.ElectionError.from_message(
|
|
541
|
-
"ContestCollection should not exist."
|
|
542
|
-
)
|
|
543
|
-
|
|
544
|
-
if element.find("CountStatus") is not None:
|
|
545
|
-
raise loggers.ElectionError.from_message("CountStatus should not exist.")
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
class WarnOnElementsNotRecommendedForElection(base.BaseRule):
|
|
549
|
-
"""Warn on ContactInformation on an Election for voter information feeds."""
|
|
550
|
-
|
|
551
|
-
def elements(self):
|
|
552
|
-
return ["Election"]
|
|
553
|
-
|
|
554
|
-
def check(self, element):
|
|
555
|
-
if element.find("ContactInformation") is not None:
|
|
556
|
-
raise loggers.ElectionWarning.from_message(
|
|
557
|
-
"ContactInformation is not recommended for Election, prefer using an"
|
|
558
|
-
" ElectionAdministration."
|
|
559
|
-
)
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
class NoExtraElectionReportCollections(base.BaseRule):
|
|
563
|
-
"""ElectionReports for voter information feeds should not have certain elements.
|
|
564
|
-
|
|
565
|
-
CommitteeCollection, GovernmentBodyCollection, OfficeCollection,
|
|
566
|
-
OfficeHolderTenureCollection, PartyCollection, PersonCollection should all be
|
|
567
|
-
excluded.
|
|
568
|
-
"""
|
|
569
|
-
|
|
570
|
-
def elements(self):
|
|
571
|
-
return ["ElectionReport"]
|
|
572
|
-
|
|
573
|
-
def check(self, element):
|
|
574
|
-
if element.find("CommitteeCollection") is not None:
|
|
575
|
-
raise loggers.ElectionError.from_message(
|
|
576
|
-
"CommitteeCollection should not exist."
|
|
577
|
-
)
|
|
578
|
-
|
|
579
|
-
if element.find("GovernmentBodyCollection") is not None:
|
|
580
|
-
raise loggers.ElectionError.from_message(
|
|
581
|
-
"GovernmentBodyCollection should not exist."
|
|
582
|
-
)
|
|
583
|
-
|
|
584
|
-
if element.find("OfficeCollection") is not None:
|
|
585
|
-
raise loggers.ElectionError.from_message(
|
|
586
|
-
"OfficeCollection should not exist."
|
|
587
|
-
)
|
|
588
|
-
|
|
589
|
-
if element.find("OfficeHolderTenureCollection") is not None:
|
|
590
|
-
raise loggers.ElectionError.from_message(
|
|
591
|
-
"OfficeHolderTenureCollection should not exist."
|
|
592
|
-
)
|
|
593
|
-
|
|
594
|
-
if element.find("PartyCollection") is not None:
|
|
595
|
-
raise loggers.ElectionError.from_message(
|
|
596
|
-
"PartyCollection should not exist."
|
|
597
|
-
)
|
|
598
|
-
|
|
599
|
-
if element.find("PersonCollection") is not None:
|
|
600
|
-
raise loggers.ElectionError.from_message(
|
|
601
|
-
"PersonCollection should not exist."
|
|
602
|
-
)
|
|
603
|
-
|
|
604
|
-
|
|
605
421
|
class FeedElementsShouldHaveSubElementsBasedOnType(base.BaseRule):
|
|
606
422
|
"""Feeds should have certain elements based on feed type.
|
|
607
423
|
|
|
@@ -659,17 +475,8 @@ COMMON_RULES = common_rules.COMMON_RULES
|
|
|
659
475
|
OFFICEHOLDER_RULES = officeholder_rules.OFFICEHOLDER_RULES
|
|
660
476
|
ELECTION_RULES = election_rules.ELECTION_RULES
|
|
661
477
|
ELECTION_DATES_RULES = election_dates_rules.ELECTION_DATES_RULES
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
COMMITTEE_RULES = COMMON_RULES + (
|
|
665
|
-
# go/keep-sorted start
|
|
666
|
-
AffiliationEndDateOccursAfterStartDate,
|
|
667
|
-
AffiliationHasEitherPartyOrPerson,
|
|
668
|
-
CommitteeClassificationEndDateOccursAfterStartDate,
|
|
669
|
-
EinMatchesFormat,
|
|
670
|
-
common_rules.ProhibitElectionData,
|
|
671
|
-
# go/keep-sorted end
|
|
672
|
-
)
|
|
478
|
+
COMMITTEE_RULES = committee_rules.COMMITTEE_RULES
|
|
479
|
+
VOTER_INFORMATION_RULES = voter_information_rules.VOTER_INFORMATION_RULES
|
|
673
480
|
|
|
674
481
|
|
|
675
482
|
METADATA_RULES = (
|
|
@@ -697,15 +504,6 @@ METADATA_RULES = (
|
|
|
697
504
|
# go/keep-sorted end
|
|
698
505
|
)
|
|
699
506
|
|
|
700
|
-
VOTER_INFORMATION_RULES = COMMON_RULES + (
|
|
701
|
-
# go/keep-sorted start
|
|
702
|
-
ElectoralCommissionCollectionExists,
|
|
703
|
-
NoExtraElectionElements,
|
|
704
|
-
NoExtraElectionReportCollections,
|
|
705
|
-
VoterInformationCollectionExists,
|
|
706
|
-
WarnOnElementsNotRecommendedForElection,
|
|
707
|
-
# go/keep-sorted end
|
|
708
|
-
)
|
|
709
507
|
|
|
710
508
|
ALL_RULES = frozenset(
|
|
711
509
|
COMMON_RULES
|
|
@@ -0,0 +1,107 @@
|
|
|
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 committee feeds of the CDF XML validator."""
|
|
15
|
+
|
|
16
|
+
from __future__ import print_function
|
|
17
|
+
|
|
18
|
+
import re
|
|
19
|
+
|
|
20
|
+
from civics_cdf_validator import base
|
|
21
|
+
from civics_cdf_validator import loggers
|
|
22
|
+
from civics_cdf_validator.rulesets import common_rules
|
|
23
|
+
from civics_cdf_validator.rulesets import rule_util
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CommitteeClassificationEndDateOccursAfterStartDate(base.DateRule):
|
|
27
|
+
"""CommitteeClassification elements should have end dates that occur after the start dates."""
|
|
28
|
+
|
|
29
|
+
def elements(self):
|
|
30
|
+
return ["CommitteeClassification"]
|
|
31
|
+
|
|
32
|
+
def check(self, element):
|
|
33
|
+
self.reset_instance_vars()
|
|
34
|
+
self.gather_dates(element)
|
|
35
|
+
|
|
36
|
+
if self.end_date and self.start_date:
|
|
37
|
+
self.check_end_after_start()
|
|
38
|
+
if self.error_log:
|
|
39
|
+
raise loggers.ElectionError(self.error_log)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class AffiliationEndDateOccursAfterStartDate(base.DateRule):
|
|
43
|
+
"""Affiliation elements should have end dates that occur after the start dates."""
|
|
44
|
+
|
|
45
|
+
def elements(self):
|
|
46
|
+
return ["Affiliation"]
|
|
47
|
+
|
|
48
|
+
def check(self, element):
|
|
49
|
+
self.reset_instance_vars()
|
|
50
|
+
self.gather_dates(element)
|
|
51
|
+
|
|
52
|
+
if self.end_date and self.start_date:
|
|
53
|
+
self.check_end_after_start()
|
|
54
|
+
if self.error_log:
|
|
55
|
+
raise loggers.ElectionError(self.error_log)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class EinMatchesFormat(base.BaseRule):
|
|
59
|
+
"""EIN id should be in the following format: XX-XXXXXXX."""
|
|
60
|
+
|
|
61
|
+
def __init__(self, election_tree, schema_tree, **kwargs):
|
|
62
|
+
super(EinMatchesFormat, self).__init__(election_tree, schema_tree, **kwargs)
|
|
63
|
+
regex = r"\d{2}(-\d{7})?"
|
|
64
|
+
self.ein_id_matcher = re.compile(regex, flags=re.U)
|
|
65
|
+
|
|
66
|
+
def elements(self):
|
|
67
|
+
return ["Committee"]
|
|
68
|
+
|
|
69
|
+
def check(self, element):
|
|
70
|
+
external_identifiers = element.find("ExternalIdentifiers")
|
|
71
|
+
if external_identifiers is not None:
|
|
72
|
+
ein_ids = rule_util.get_external_id_values(external_identifiers, "ein")
|
|
73
|
+
if ein_ids:
|
|
74
|
+
e_id = ein_ids.pop()
|
|
75
|
+
if not self.ein_id_matcher.match(e_id):
|
|
76
|
+
raise loggers.ElectionError.from_message(
|
|
77
|
+
"EIN id '{}' is not in the correct format.".format(e_id),
|
|
78
|
+
[element],
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class AffiliationHasEitherPartyOrPerson(base.BaseRule):
|
|
83
|
+
"""Affiliation should contain either a Party or a Person objectId."""
|
|
84
|
+
|
|
85
|
+
def elements(self):
|
|
86
|
+
return ["Affiliation"]
|
|
87
|
+
|
|
88
|
+
def check(self, element):
|
|
89
|
+
party_id = element.find("PartyId")
|
|
90
|
+
person_id = element.find("PersonId")
|
|
91
|
+
if not ((party_id is None) ^ (person_id is None)):
|
|
92
|
+
raise loggers.ElectionError.from_message(
|
|
93
|
+
"Affiliation must have one of: PartyId, PersonId. Cannot include"
|
|
94
|
+
" both.",
|
|
95
|
+
[element],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
COMMITTEE_RULES = common_rules.COMMON_RULES + (
|
|
100
|
+
# go/keep-sorted start
|
|
101
|
+
AffiliationEndDateOccursAfterStartDate,
|
|
102
|
+
AffiliationHasEitherPartyOrPerson,
|
|
103
|
+
CommitteeClassificationEndDateOccursAfterStartDate,
|
|
104
|
+
EinMatchesFormat,
|
|
105
|
+
common_rules.ProhibitElectionData,
|
|
106
|
+
# go/keep-sorted end
|
|
107
|
+
)
|
|
@@ -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.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/RECORD
RENAMED
|
@@ -3,19 +3,21 @@ 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
|
+
civics_cdf_validator/rulesets/committee_rules.py,sha256=0hNnpzI-ptZDxErbH2D2r66IiIiioqVXSV3YxgXlhrE,3472
|
|
11
12
|
civics_cdf_validator/rulesets/common_rules.py,sha256=vCcodXrykZBx-RHCX8J-zsUxwEFCEIl0WARkn4cm6fE,59417
|
|
12
13
|
civics_cdf_validator/rulesets/election_dates_rules.py,sha256=mIOKroJ2z5QI5C_i8JR2fNUuZ_e8DJ3juEB07v8tONY,1363
|
|
13
14
|
civics_cdf_validator/rulesets/election_rules.py,sha256=ldLXfYgJ3YbapIVZclQPmDemki-txOTOqrp_k8WgSS0,95874
|
|
14
15
|
civics_cdf_validator/rulesets/officeholder_rules.py,sha256=N5G5Gum685ACXnb0Kwd5DseaCHOOpg3gpYK_uivAegQ,17766
|
|
15
16
|
civics_cdf_validator/rulesets/rule_util.py,sha256=FWi09R7XWDfZwuHl-k2vhsFHlKuOrD5MD5YQ4QUQyVo,4431
|
|
16
|
-
civics_cdf_validator
|
|
17
|
-
civics_cdf_validator-1.67.
|
|
18
|
-
civics_cdf_validator-1.67.
|
|
19
|
-
civics_cdf_validator-1.67.
|
|
20
|
-
civics_cdf_validator-1.67.
|
|
21
|
-
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.dev5.dist-info → civics_cdf_validator-1.67.dev7.dist-info}/top_level.txt
RENAMED
|
File without changes
|