civics-cdf-validator 1.67.dev6__tar.gz → 1.67.dev7__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 (30) hide show
  1. {civics_cdf_validator-1.67.dev6/civics_cdf_validator.egg-info → civics_cdf_validator-1.67.dev7}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/civics_cdf_validator.egg-info/SOURCES.txt +1 -0
  4. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rules.py +2 -121
  5. civics_cdf_validator-1.67.dev7/rulesets/voter_information_rules.py +143 -0
  6. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/version.py +1 -1
  7. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/CONTRIBUTING.md +0 -0
  8. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/LICENSE-2.0.txt +0 -0
  9. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/MANIFEST.in +0 -0
  10. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/README.md +0 -0
  11. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/__init__.py +0 -0
  12. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/base.py +0 -0
  13. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  14. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  15. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/civics_cdf_validator.egg-info/requires.txt +0 -0
  16. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  17. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/gpunit_rules.py +0 -0
  18. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/loggers.py +0 -0
  19. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/office_utils.py +0 -0
  20. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/__init__.py +0 -0
  21. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/committee_rules.py +0 -0
  22. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/common_rules.py +0 -0
  23. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/election_dates_rules.py +0 -0
  24. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/election_rules.py +0 -0
  25. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/officeholder_rules.py +0 -0
  26. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/rulesets/rule_util.py +0 -0
  27. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/setup.cfg +0 -0
  28. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/setup.py +0 -0
  29. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/stats.py +0 -0
  30. {civics_cdf_validator-1.67.dev6 → civics_cdf_validator-1.67.dev7}/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.dev7
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.dev7
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
@@ -22,6 +22,7 @@ setup.py
22
22
  ./rulesets/election_rules.py
23
23
  ./rulesets/officeholder_rules.py
24
24
  ./rulesets/rule_util.py
25
+ ./rulesets/voter_information_rules.py
25
26
  civics_cdf_validator.egg-info/PKG-INFO
26
27
  civics_cdf_validator.egg-info/SOURCES.txt
27
28
  civics_cdf_validator.egg-info/dependency_links.txt
@@ -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
+ )
@@ -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.dev7'