civics-cdf-validator 1.61.dev6__tar.gz → 1.62.dev0__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 (22) hide show
  1. {civics_cdf_validator-1.61.dev6/civics_cdf_validator.egg-info → civics_cdf_validator-1.62.dev0}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  3. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/rules.py +27 -0
  4. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/version.py +1 -1
  5. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/CONTRIBUTING.md +0 -0
  6. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/LICENSE-2.0.txt +0 -0
  7. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/MANIFEST.in +0 -0
  8. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/README.md +0 -0
  9. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/__init__.py +0 -0
  10. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/base.py +0 -0
  11. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  12. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  13. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  14. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/civics_cdf_validator.egg-info/requires.txt +0 -0
  15. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  16. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/gpunit_rules.py +0 -0
  17. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/loggers.py +0 -0
  18. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/office_utils.py +0 -0
  19. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/setup.cfg +0 -0
  20. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/setup.py +0 -0
  21. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/stats.py +0 -0
  22. {civics_cdf_validator-1.61.dev6 → civics_cdf_validator-1.62.dev0}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.61.dev6
3
+ Version: 1.62.dev0
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.61.dev6
3
+ Version: 1.62.dev0
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
@@ -25,6 +25,7 @@ from civics_cdf_validator import base
25
25
  from civics_cdf_validator import gpunit_rules
26
26
  from civics_cdf_validator import loggers
27
27
  from civics_cdf_validator import office_utils
28
+ import dateutil
28
29
  from frozendict import frozendict
29
30
  import language_tags
30
31
  from lxml import etree
@@ -4830,6 +4831,31 @@ class FeedHasValidCountryCode(base.BaseRule):
4830
4831
  )
4831
4832
 
4832
4833
 
4834
+ class FeedInactiveDateNotOlderThanOneYear(base.BaseRule):
4835
+ """Feeds should not have a FeedInactiveDate older than 1 year."""
4836
+
4837
+ def elements(self):
4838
+ return ["Feed"]
4839
+
4840
+ def check(self, element):
4841
+ feed_inactive_date_element = element.find("FeedInactiveDate")
4842
+ if not element_has_text(feed_inactive_date_element):
4843
+ return
4844
+ feed_inactive_date = datetime.date.fromisoformat(
4845
+ feed_inactive_date_element.text
4846
+ )
4847
+ one_year_ago = datetime.date.today() - dateutil.relativedelta.relativedelta(
4848
+ years=1
4849
+ )
4850
+ if feed_inactive_date < one_year_ago:
4851
+ feed_id_element = element.find("FeedId")
4852
+ raise loggers.ElectionError.from_message(
4853
+ f"FeedInactiveDate '{feed_inactive_date_element.text}' is older than"
4854
+ f" 1 year for feed '{feed_id_element.text}'.",
4855
+ [element],
4856
+ )
4857
+
4858
+
4833
4859
  class FeedInactiveDateSetForNonEvergreenFeed(base.BaseRule):
4834
4860
  """All non-evergreen feeds should have a FeedInactiveDate set."""
4835
4861
 
@@ -5663,6 +5689,7 @@ METADATA_RULES = (
5663
5689
  FeedHasValidCountryCode,
5664
5690
  FeedIdsAreUnique,
5665
5691
  FeedInactiveDateIsLatestDate,
5692
+ FeedInactiveDateNotOlderThanOneYear,
5666
5693
  FeedInactiveDateSetForNonEvergreenFeed,
5667
5694
  FeedTypeHasValidFeedLongevity,
5668
5695
  OfficeholderSubFeedDatesAreSequential,
@@ -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.61.dev6'
8
+ __version__ = '1.62.dev0'