civics-cdf-validator 1.67.dev16__tar.gz → 1.67.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.
Files changed (31) hide show
  1. {civics_cdf_validator-1.67.dev16/civics_cdf_validator.egg-info → civics_cdf_validator-1.67.dev18}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/common_rules.py +58 -0
  4. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/election_rules.py +0 -57
  5. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/version.py +1 -1
  6. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/CONTRIBUTING.md +0 -0
  7. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/LICENSE-2.0.txt +0 -0
  8. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/MANIFEST.in +0 -0
  9. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/README.md +0 -0
  10. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/__init__.py +0 -0
  11. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/base.py +0 -0
  12. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  13. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  14. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  15. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/civics_cdf_validator.egg-info/requires.txt +0 -0
  16. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  17. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/gpunit_rules.py +0 -0
  18. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/loggers.py +0 -0
  19. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/office_utils.py +0 -0
  20. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rules.py +0 -0
  21. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/__init__.py +0 -0
  22. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/committee_rules.py +0 -0
  23. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/election_dates_rules.py +0 -0
  24. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/metadata_rules.py +0 -0
  25. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/officeholder_rules.py +0 -0
  26. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/rule_util.py +0 -0
  27. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/rulesets/voter_information_rules.py +0 -0
  28. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/setup.cfg +0 -0
  29. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/setup.py +0 -0
  30. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/stats.py +0 -0
  31. {civics_cdf_validator-1.67.dev16 → civics_cdf_validator-1.67.dev18}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.67.dev16
3
+ Version: 1.67.dev18
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.dev16
3
+ Version: 1.67.dev18
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
@@ -83,6 +83,31 @@ _UNTYPED_URI_PLATFORMS = frozenset([
83
83
 
84
84
  _ALL_URI_PLATFORMS = _TYPED_URI_PLATFORMS | _UNTYPED_URI_PLATFORMS
85
85
 
86
+ _INTERNATIONALIZED_TEXT_ELEMENTS_WITH_ONLY_ONE_TEXT_PER_LANGUAGE = [
87
+ # go/keep-sorted start
88
+ "BallotName",
89
+ "BallotSubTitle",
90
+ "BallotText",
91
+ "BallotTitle",
92
+ "ConStatement",
93
+ "Directions",
94
+ "DisplayName",
95
+ "EffectOfAbstain",
96
+ "FullName",
97
+ "FullText",
98
+ "InternationalizedAbbreviation",
99
+ "InternationalizedName",
100
+ "Name",
101
+ "PartyLabel",
102
+ "PassageThreshold",
103
+ "ProStatement",
104
+ "Profession",
105
+ "Selection",
106
+ "SummaryText",
107
+ "Title",
108
+ # go/keep-sorted end
109
+ ]
110
+
86
111
 
87
112
  def _get_office_roles(element, is_post_office_split_feed=False):
88
113
  if is_post_office_split_feed:
@@ -1707,6 +1732,23 @@ class AllInternationalizedTextHaveEnVersion(base.BaseRule):
1707
1732
  )
1708
1733
 
1709
1734
 
1735
+ class MultipleInternationalizedTextWithSameLanguageCode(base.BaseRule):
1736
+ """Checks for multiple InternationalizedText with the same language code."""
1737
+
1738
+ def elements(self):
1739
+ return _INTERNATIONALIZED_TEXT_ELEMENTS_WITH_ONLY_ONE_TEXT_PER_LANGUAGE
1740
+
1741
+ def check(self, element):
1742
+ language_map = rule_util.get_language_to_text_map(element)
1743
+
1744
+ for language, texts in language_map.items():
1745
+ if len(texts) > 1:
1746
+ raise loggers.ElectionError.from_message(
1747
+ f'Multiple "{language}" texts found for "{texts[0].strip()}"',
1748
+ [element],
1749
+ )
1750
+
1751
+
1710
1752
  class DeprecatedPartyLeadershipSchema(base.BaseRule):
1711
1753
  """Errors if the deprecated party leadership schema is used."""
1712
1754
 
@@ -1816,6 +1858,20 @@ class UnreferencedEntitiesBase(base.TreeRule):
1816
1858
  )
1817
1859
 
1818
1860
 
1861
+ class CoalitionParties(base.BaseRule):
1862
+ """Coalitions should always define the Party IDs."""
1863
+
1864
+ def elements(self):
1865
+ return ["Coalition"]
1866
+
1867
+ def check(self, element):
1868
+ party_id = element.find("PartyIds")
1869
+ if party_id is None or not party_id.text or not party_id.text.strip():
1870
+ raise loggers.ElectionError.from_message(
1871
+ "Coalition must define PartyIDs", [element]
1872
+ )
1873
+
1874
+
1819
1875
  COMMON_RULES = (
1820
1876
  # go/keep-sorted start
1821
1877
  AllCaps,
@@ -1823,6 +1879,7 @@ COMMON_RULES = (
1823
1879
  AllLanguages,
1824
1880
  BadCharactersInPersonFullName,
1825
1881
  CandidateImageInContactInformation,
1882
+ CoalitionParties,
1826
1883
  DeprecatedPartyLeadershipSchema,
1827
1884
  DiplomaticOfficesHaveCorrespondingGpUnitsSet,
1828
1885
  DuplicateGpUnits,
@@ -1842,6 +1899,7 @@ COMMON_RULES = (
1842
1899
  MissingFieldsWarning,
1843
1900
  MissingOfficeSelectionMethod,
1844
1901
  MissingStableIds,
1902
+ MultipleInternationalizedTextWithSameLanguageCode,
1845
1903
  NonExecutiveOfficeShouldHaveGovernmentBody,
1846
1904
  OfficesHaveJurisdictionID,
1847
1905
  OfficesHaveValidOfficeLevel,
@@ -35,31 +35,6 @@ _CONTEST_STAGE_TYPES = frozenset([
35
35
  "unnamed",
36
36
  ])
37
37
 
38
- _INTERNATIONALIZED_TEXT_ELEMENTS_WITH_ONLY_ONE_TEXT_PER_LANGUAGE = [
39
- # go/keep-sorted start
40
- "BallotName",
41
- "BallotSubTitle",
42
- "BallotText",
43
- "BallotTitle",
44
- "ConStatement",
45
- "Directions",
46
- "DisplayName",
47
- "EffectOfAbstain",
48
- "FullName",
49
- "FullText",
50
- "InternationalizedAbbreviation",
51
- "InternationalizedName",
52
- "Name",
53
- "PartyLabel",
54
- "PassageThreshold",
55
- "ProStatement",
56
- "Profession",
57
- "Selection",
58
- "SummaryText",
59
- "Title",
60
- # go/keep-sorted end
61
- ]
62
-
63
38
 
64
39
  _WINNER_POST_ELECTION_STATUSES = frozenset([
65
40
  "winner",
@@ -245,20 +220,6 @@ class PartisanPrimaryHeuristic(base.BaseRule):
245
220
  raise loggers.ElectionWarning.from_message(msg, [contest_elem])
246
221
 
247
222
 
248
- class CoalitionParties(base.BaseRule):
249
- """Coalitions should always define the Party IDs."""
250
-
251
- def elements(self):
252
- return ["Coalition"]
253
-
254
- def check(self, element):
255
- party_id = element.find("PartyIds")
256
- if party_id is None or not party_id.text or not party_id.text.strip():
257
- raise loggers.ElectionError.from_message(
258
- "Coalition must define PartyIDs", [element]
259
- )
260
-
261
-
262
223
  class CandidatesReferencedInRelatedContests(base.BaseRule):
263
224
  """Candidate should not be referred to by multiple unrelated contests.
264
225
 
@@ -1847,22 +1808,6 @@ class ComposingContestIdsAreValidRelatedContests(base.BaseRule):
1847
1808
  raise loggers.ElectionError(error_log)
1848
1809
 
1849
1810
 
1850
- class MultipleInternationalizedTextWithSameLanguageCode(base.BaseRule):
1851
- """Checks for multiple InternationalizedText with the same language code."""
1852
-
1853
- def elements(self):
1854
- return _INTERNATIONALIZED_TEXT_ELEMENTS_WITH_ONLY_ONE_TEXT_PER_LANGUAGE
1855
-
1856
- def check(self, element):
1857
- language_map = rule_util.get_language_to_text_map(element)
1858
-
1859
- for language, texts in language_map.items():
1860
- if len(texts) > 1:
1861
- raise loggers.ElectionError.from_message(
1862
- 'Multiple "%s" texts found for "%s"' % (language, texts[0].strip())
1863
- )
1864
-
1865
-
1866
1811
  class ContestContainsValidStartDate(base.DateRule):
1867
1812
  """Contest elements should contain valid start dates.
1868
1813
 
@@ -2680,7 +2625,6 @@ ELECTION_RULES = common_rules.COMMON_RULES + (
2680
2625
  BallotTitle,
2681
2626
  CandidateContestTypesAreCompatible,
2682
2627
  CandidatesReferencedInRelatedContests,
2683
- CoalitionParties,
2684
2628
  ComposingContestIdsAreValidRelatedContests,
2685
2629
  ContestContainsValidEndDate,
2686
2630
  ContestContainsValidStartDate,
@@ -2709,7 +2653,6 @@ ELECTION_RULES = common_rules.COMMON_RULES + (
2709
2653
  MissingPartyAbbreviationTranslation,
2710
2654
  MissingPartyNameTranslation,
2711
2655
  MultipleCandidatesPointToTheSamePersonInTheSameContest,
2712
- MultipleInternationalizedTextWithSameLanguageCode,
2713
2656
  NotEmptyUniqueDataSourceUris,
2714
2657
  OfficeHasjurisdictionSameAsElectoralDistrict,
2715
2658
  PartisanPrimary,
@@ -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.dev16'
8
+ __version__ = '1.67.dev18'