civics-cdf-validator 1.67.dev6__tar.gz → 1.67.dev8__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.
Files changed (31) hide show
  1. {civics_cdf_validator-1.67.dev6/civics_cdf_validator.egg-info → civics_cdf_validator-1.67.dev8}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/civics_cdf_validator.egg-info/SOURCES.txt +2 -0
  4. civics_cdf_validator-1.67.dev8/rules.py +59 -0
  5. civics_cdf_validator-1.67.dev6/rules.py → civics_cdf_validator-1.67.dev8/rulesets/metadata_rules.py +1 -159
  6. civics_cdf_validator-1.67.dev8/rulesets/voter_information_rules.py +143 -0
  7. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/version.py +1 -1
  8. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/CONTRIBUTING.md +0 -0
  9. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/LICENSE-2.0.txt +0 -0
  10. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/MANIFEST.in +0 -0
  11. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/README.md +0 -0
  12. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/__init__.py +0 -0
  13. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/base.py +0 -0
  14. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  15. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  16. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/civics_cdf_validator.egg-info/requires.txt +0 -0
  17. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  18. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/gpunit_rules.py +0 -0
  19. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/loggers.py +0 -0
  20. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/office_utils.py +0 -0
  21. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/__init__.py +0 -0
  22. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/committee_rules.py +0 -0
  23. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/common_rules.py +0 -0
  24. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/election_dates_rules.py +0 -0
  25. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/election_rules.py +0 -0
  26. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/officeholder_rules.py +0 -0
  27. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/rulesets/rule_util.py +0 -0
  28. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/setup.cfg +0 -0
  29. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/setup.py +0 -0
  30. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/stats.py +0 -0
  31. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev8}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.67.dev6
3
+ Version: 1.67.dev8
4
4
  Summary: Checks if an election feed follows best practices
5
5
  Home-page: https://github.com/google/civics_cdf_validator
6
6
  Author: Google Civics
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.67.dev6
3
+ Version: 1.67.dev8
4
4
  Summary: Checks if an election feed follows best practices
5
5
  Home-page: https://github.com/google/civics_cdf_validator
6
6
  Author: Google Civics
@@ -20,8 +20,10 @@ setup.py
20
20
  ./rulesets/common_rules.py
21
21
  ./rulesets/election_dates_rules.py
22
22
  ./rulesets/election_rules.py
23
+ ./rulesets/metadata_rules.py
23
24
  ./rulesets/officeholder_rules.py
24
25
  ./rulesets/rule_util.py
26
+ ./rulesets/voter_information_rules.py
25
27
  civics_cdf_validator.egg-info/PKG-INFO
26
28
  civics_cdf_validator.egg-info/SOURCES.txt
27
29
  civics_cdf_validator.egg-info/dependency_links.txt
@@ -0,0 +1,59 @@
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 the CDF XML validator."""
15
+
16
+ from __future__ import print_function
17
+
18
+ import enum
19
+
20
+ from civics_cdf_validator.rulesets import committee_rules
21
+ from civics_cdf_validator.rulesets import common_rules
22
+ from civics_cdf_validator.rulesets import election_dates_rules
23
+ from civics_cdf_validator.rulesets import election_rules
24
+ from civics_cdf_validator.rulesets import metadata_rules
25
+ from civics_cdf_validator.rulesets import officeholder_rules
26
+ from civics_cdf_validator.rulesets import voter_information_rules
27
+
28
+
29
+ class RuleSet(enum.Enum):
30
+ """Names for sets of rules used to validate a particular feed type."""
31
+
32
+ ELECTION = 1
33
+ OFFICEHOLDER = 2
34
+ COMMITTEE = 3
35
+ ELECTION_DATES = 4
36
+ ELECTION_RESULTS = 5
37
+ METADATA = 6
38
+ VOTER_INFORMATION = 7
39
+
40
+
41
+ # To add new rules, create a new class in the matching file under rulesets/,
42
+ # inherit the base rule, and add it to that file's rule list.
43
+ COMMON_RULES = common_rules.COMMON_RULES
44
+ ELECTION_RULES = election_rules.ELECTION_RULES
45
+ OFFICEHOLDER_RULES = officeholder_rules.OFFICEHOLDER_RULES
46
+ COMMITTEE_RULES = committee_rules.COMMITTEE_RULES
47
+ ELECTION_DATES_RULES = election_dates_rules.ELECTION_DATES_RULES
48
+ METADATA_RULES = metadata_rules.METADATA_RULES
49
+ VOTER_INFORMATION_RULES = voter_information_rules.VOTER_INFORMATION_RULES
50
+
51
+ ALL_RULES = frozenset(
52
+ COMMON_RULES
53
+ + ELECTION_RULES
54
+ + OFFICEHOLDER_RULES
55
+ + COMMITTEE_RULES
56
+ + ELECTION_DATES_RULES
57
+ + VOTER_INFORMATION_RULES
58
+ + METADATA_RULES
59
+ )
@@ -11,21 +11,16 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- """Validation rules for the CDF XML validator."""
14
+ """Validation rules for metadata feeds of the CDF XML validator."""
15
15
 
16
16
  from __future__ import print_function
17
17
 
18
18
  import datetime
19
- import enum
20
19
 
21
20
  from botocore import utils as botocore_utils
22
21
  from civics_cdf_validator import base
23
22
  from civics_cdf_validator import loggers
24
- from civics_cdf_validator.rulesets import committee_rules
25
23
  from civics_cdf_validator.rulesets import common_rules
26
- from civics_cdf_validator.rulesets import election_dates_rules
27
- from civics_cdf_validator.rulesets import election_rules
28
- from civics_cdf_validator.rulesets import officeholder_rules
29
24
  from civics_cdf_validator.rulesets import rule_util
30
25
  import dateutil
31
26
  from frozendict import frozendict
@@ -417,118 +412,6 @@ class FeedInactiveDateSetForNonEvergreenFeed(base.BaseRule):
417
412
  )
418
413
 
419
414
 
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
415
  class FeedElementsShouldHaveSubElementsBasedOnType(base.BaseRule):
533
416
  """Feeds should have certain elements based on feed type.
534
417
 
@@ -568,27 +451,6 @@ class FeedElementsShouldHaveSubElementsBasedOnType(base.BaseRule):
568
451
  )
569
452
 
570
453
 
571
- class RuleSet(enum.Enum):
572
- """Names for sets of rules used to validate a particular feed type."""
573
-
574
- ELECTION = 1
575
- OFFICEHOLDER = 2
576
- COMMITTEE = 3
577
- ELECTION_DATES = 4
578
- ELECTION_RESULTS = 5
579
- METADATA = 6
580
- VOTER_INFORMATION = 7
581
-
582
-
583
- # To add new rules, create a new class, inherit the base rule,
584
- # and add it to the correct rule list.
585
- COMMON_RULES = common_rules.COMMON_RULES
586
- OFFICEHOLDER_RULES = officeholder_rules.OFFICEHOLDER_RULES
587
- ELECTION_RULES = election_rules.ELECTION_RULES
588
- ELECTION_DATES_RULES = election_dates_rules.ELECTION_DATES_RULES
589
- COMMITTEE_RULES = committee_rules.COMMITTEE_RULES
590
-
591
-
592
454
  METADATA_RULES = (
593
455
  # go/keep-sorted start
594
456
  ElectionEventDatesAreSequential,
@@ -613,23 +475,3 @@ METADATA_RULES = (
613
475
  common_rules.UniqueLabel,
614
476
  # go/keep-sorted end
615
477
  )
616
-
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
-
627
- ALL_RULES = frozenset(
628
- COMMON_RULES
629
- + ELECTION_RULES
630
- + OFFICEHOLDER_RULES
631
- + COMMITTEE_RULES
632
- + ELECTION_DATES_RULES
633
- + VOTER_INFORMATION_RULES
634
- + METADATA_RULES
635
- )
@@ -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
+ )
@@ -5,4 +5,4 @@ No dependencies should be added to this module.
5
5
  See https://packaging.python.org/guides/single-sourcing-package-version/
6
6
  """
7
7
 
8
- __version__ = '1.67.dev6'
8
+ __version__ = '1.67.dev8'