civics-cdf-validator 1.67.dev18__tar.gz → 1.67.dev19__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.
- {civics_cdf_validator-1.67.dev18/civics_cdf_validator.egg-info → civics_cdf_validator-1.67.dev19}/PKG-INFO +1 -1
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/common_rules.py +68 -1
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/election_rules.py +3 -66
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/version.py +1 -1
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/CONTRIBUTING.md +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/LICENSE-2.0.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/MANIFEST.in +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/README.md +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/__init__.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/base.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/civics_cdf_validator.egg-info/requires.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/civics_cdf_validator.egg-info/top_level.txt +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/gpunit_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/loggers.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/office_utils.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/__init__.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/committee_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/election_dates_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/metadata_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/officeholder_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/rule_util.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/voter_information_rules.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/setup.cfg +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/setup.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/stats.py +0 -0
- {civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/validator.py +0 -0
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/common_rules.py
RENAMED
|
@@ -26,7 +26,6 @@ import language_tags
|
|
|
26
26
|
from lxml import etree
|
|
27
27
|
from six.moves.urllib.parse import urlparse
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
_INDEPENDENT_PARTY_NAMES = frozenset(["independent", "nonpartisan"])
|
|
31
30
|
|
|
32
31
|
_GPUNIT_TYPES_WITHOUT_OCD_IDS = frozenset([
|
|
@@ -1872,6 +1871,73 @@ class CoalitionParties(base.BaseRule):
|
|
|
1872
1871
|
)
|
|
1873
1872
|
|
|
1874
1873
|
|
|
1874
|
+
class ValidatePartyCollection(base.BaseRule):
|
|
1875
|
+
"""Generic party collection validation rule.
|
|
1876
|
+
|
|
1877
|
+
All partyCollection validation rules can inherit from this class since it
|
|
1878
|
+
contains basic checks.
|
|
1879
|
+
"""
|
|
1880
|
+
|
|
1881
|
+
def elements(self):
|
|
1882
|
+
return ["PartyCollection"]
|
|
1883
|
+
|
|
1884
|
+
def check_specific(self, parties):
|
|
1885
|
+
"""Return a list of info log to be raised."""
|
|
1886
|
+
raise NotImplementedError
|
|
1887
|
+
|
|
1888
|
+
def check(self, element):
|
|
1889
|
+
info_log = []
|
|
1890
|
+
parties = element.findall("Party")
|
|
1891
|
+
if len(parties) < 1:
|
|
1892
|
+
info_message = "<PartyCollection> does not have <Party> objects"
|
|
1893
|
+
info_log.append(loggers.LogEntry(info_message, element))
|
|
1894
|
+
info_log.extend(self.check_specific(parties))
|
|
1895
|
+
if info_log:
|
|
1896
|
+
raise loggers.ElectionInfo(info_log)
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
class DuplicatedPartyAbbreviation(ValidatePartyCollection):
|
|
1900
|
+
"""Party abbreviation should be used once in a given language.
|
|
1901
|
+
|
|
1902
|
+
If an abbreviation is duplicated, the corresponding party should be picked up
|
|
1903
|
+
within this class and returned to the user as an Info message.
|
|
1904
|
+
"""
|
|
1905
|
+
|
|
1906
|
+
def check_specific(self, parties):
|
|
1907
|
+
info_log = []
|
|
1908
|
+
party_abbreviations_by_language = {}
|
|
1909
|
+
for party in parties:
|
|
1910
|
+
abbreviation_element = party.find("InternationalizedAbbreviation")
|
|
1911
|
+
if abbreviation_element is None:
|
|
1912
|
+
info_log.append(
|
|
1913
|
+
loggers.LogEntry(
|
|
1914
|
+
"<Party> does not have <InternationalizedAbbreviation> objects",
|
|
1915
|
+
[party],
|
|
1916
|
+
)
|
|
1917
|
+
)
|
|
1918
|
+
continue
|
|
1919
|
+
party_abbreviations = abbreviation_element.findall("Text")
|
|
1920
|
+
for party_abbreviation in party_abbreviations:
|
|
1921
|
+
language = party_abbreviation.get("language")
|
|
1922
|
+
abbreviation = party_abbreviation.text
|
|
1923
|
+
if language not in party_abbreviations_by_language:
|
|
1924
|
+
party_abbreviations_by_language[language] = {}
|
|
1925
|
+
if abbreviation in party_abbreviations_by_language[language]:
|
|
1926
|
+
party_abbreviations_by_language[language][abbreviation].append(party)
|
|
1927
|
+
else:
|
|
1928
|
+
party_abbreviations_by_language[language][abbreviation] = [party]
|
|
1929
|
+
|
|
1930
|
+
for language, abbreviations in party_abbreviations_by_language.items():
|
|
1931
|
+
for abbreviation, parties in abbreviations.items():
|
|
1932
|
+
if len(parties) > 1:
|
|
1933
|
+
info_log.append(
|
|
1934
|
+
loggers.LogEntry(
|
|
1935
|
+
f"Parties have the same abbreviation in {language}.", parties
|
|
1936
|
+
)
|
|
1937
|
+
)
|
|
1938
|
+
return info_log
|
|
1939
|
+
|
|
1940
|
+
|
|
1875
1941
|
COMMON_RULES = (
|
|
1876
1942
|
# go/keep-sorted start
|
|
1877
1943
|
AllCaps,
|
|
@@ -1885,6 +1951,7 @@ COMMON_RULES = (
|
|
|
1885
1951
|
DuplicateGpUnits,
|
|
1886
1952
|
DuplicateID,
|
|
1887
1953
|
DuplicatedGpUnitOcdId,
|
|
1954
|
+
DuplicatedPartyAbbreviation,
|
|
1888
1955
|
EmptyString,
|
|
1889
1956
|
EmptyText,
|
|
1890
1957
|
Encoding,
|
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/election_rules.py
RENAMED
|
@@ -464,31 +464,6 @@ class SingularPartySelection(base.BaseRule):
|
|
|
464
464
|
)
|
|
465
465
|
|
|
466
466
|
|
|
467
|
-
class ValidatePartyCollection(base.BaseRule):
|
|
468
|
-
"""Generic party collection validation rule.
|
|
469
|
-
|
|
470
|
-
All partyCollection validation rules can inherit from this class since it
|
|
471
|
-
contains basic checks.
|
|
472
|
-
"""
|
|
473
|
-
|
|
474
|
-
def elements(self):
|
|
475
|
-
return ["PartyCollection"]
|
|
476
|
-
|
|
477
|
-
def check_specific(self, parties):
|
|
478
|
-
"""Return a list of info log to be raised."""
|
|
479
|
-
raise NotImplementedError
|
|
480
|
-
|
|
481
|
-
def check(self, element):
|
|
482
|
-
info_log = []
|
|
483
|
-
parties = element.findall("Party")
|
|
484
|
-
if len(parties) < 1:
|
|
485
|
-
info_message = "<PartyCollection> does not have <Party> objects"
|
|
486
|
-
info_log.append(loggers.LogEntry(info_message, element))
|
|
487
|
-
info_log.extend(self.check_specific(parties))
|
|
488
|
-
if info_log:
|
|
489
|
-
raise loggers.ElectionInfo(info_log)
|
|
490
|
-
|
|
491
|
-
|
|
492
467
|
class ValidateDuplicateColors(base.TreeRule):
|
|
493
468
|
"""Parties under the same contest should have unique color.
|
|
494
469
|
|
|
@@ -566,44 +541,7 @@ class ValidateDuplicateColors(base.TreeRule):
|
|
|
566
541
|
raise loggers.ElectionWarning(warning_log)
|
|
567
542
|
|
|
568
543
|
|
|
569
|
-
class
|
|
570
|
-
"""Party abbreviation should be used once in a given language.
|
|
571
|
-
|
|
572
|
-
If an abbreviation is duplicated, the corresponding party should be picked up
|
|
573
|
-
within this class and returned to the user as an Info message.
|
|
574
|
-
"""
|
|
575
|
-
|
|
576
|
-
def check_specific(self, parties):
|
|
577
|
-
info_log = []
|
|
578
|
-
party_abbrs_by_language = {}
|
|
579
|
-
for party in parties:
|
|
580
|
-
abbr_element = party.find("InternationalizedAbbreviation")
|
|
581
|
-
if abbr_element is None:
|
|
582
|
-
info_message = (
|
|
583
|
-
"<Party> does not have <InternationalizedAbbreviation> objects"
|
|
584
|
-
)
|
|
585
|
-
info_log.append(loggers.LogEntry(info_message, [party]))
|
|
586
|
-
continue
|
|
587
|
-
party_abbrs = abbr_element.findall("Text")
|
|
588
|
-
for party_abbr in party_abbrs:
|
|
589
|
-
language = party_abbr.get("language")
|
|
590
|
-
abbr = party_abbr.text
|
|
591
|
-
if language not in party_abbrs_by_language:
|
|
592
|
-
party_abbrs_by_language[language] = {}
|
|
593
|
-
if abbr in party_abbrs_by_language[language]:
|
|
594
|
-
party_abbrs_by_language[language][abbr].append(party)
|
|
595
|
-
else:
|
|
596
|
-
party_abbrs_by_language[language][abbr] = [party]
|
|
597
|
-
|
|
598
|
-
for language, abbrs in party_abbrs_by_language.items():
|
|
599
|
-
for abbr, parties in abbrs.items():
|
|
600
|
-
if len(parties) > 1:
|
|
601
|
-
info_message = "Parties have the same abbreviation in %s." % language
|
|
602
|
-
info_log.append(loggers.LogEntry(info_message, parties))
|
|
603
|
-
return info_log
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
class DuplicatedPartyName(ValidatePartyCollection):
|
|
544
|
+
class DuplicatedPartyName(common_rules.ValidatePartyCollection):
|
|
607
545
|
"""Party name should be used once in a given language.
|
|
608
546
|
|
|
609
547
|
If a party name is duplicated, the corresponding party should be picked up
|
|
@@ -638,7 +576,7 @@ class DuplicatedPartyName(ValidatePartyCollection):
|
|
|
638
576
|
return info_log
|
|
639
577
|
|
|
640
578
|
|
|
641
|
-
class MissingPartyNameTranslation(ValidatePartyCollection):
|
|
579
|
+
class MissingPartyNameTranslation(common_rules.ValidatePartyCollection):
|
|
642
580
|
"""All Parties should have their name translated to the same languages.
|
|
643
581
|
|
|
644
582
|
If there is a party name that is not translated to all the feed languages,
|
|
@@ -680,7 +618,7 @@ class MissingPartyNameTranslation(ValidatePartyCollection):
|
|
|
680
618
|
return info_log
|
|
681
619
|
|
|
682
620
|
|
|
683
|
-
class MissingPartyAbbreviationTranslation(ValidatePartyCollection):
|
|
621
|
+
class MissingPartyAbbreviationTranslation(common_rules.ValidatePartyCollection):
|
|
684
622
|
"""Every party's abbreviation should be translated to the same languages.
|
|
685
623
|
|
|
686
624
|
If a party is missing a name translation, it should be picked up within this
|
|
@@ -2637,7 +2575,6 @@ ELECTION_RULES = common_rules.COMMON_RULES + (
|
|
|
2637
2575
|
DateStatusMatches,
|
|
2638
2576
|
DuplicateBallotTitleSeatPair,
|
|
2639
2577
|
DuplicateContestNames,
|
|
2640
|
-
DuplicatedPartyAbbreviation,
|
|
2641
2578
|
DuplicatedPartyName,
|
|
2642
2579
|
ElectionContainsStartAndEndDates,
|
|
2643
2580
|
ElectionDatesSpanContestDates,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/committee_rules.py
RENAMED
|
File without changes
|
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/election_dates_rules.py
RENAMED
|
File without changes
|
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/metadata_rules.py
RENAMED
|
File without changes
|
{civics_cdf_validator-1.67.dev18 → civics_cdf_validator-1.67.dev19}/rulesets/officeholder_rules.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|