civics-cdf-validator 1.49.dev8__tar.gz → 1.49.dev9__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.49.dev8/civics_cdf_validator.egg-info → civics_cdf_validator-1.49.dev9}/PKG-INFO +1 -1
  2. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/base.py +9 -0
  3. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9/civics_cdf_validator.egg-info}/PKG-INFO +1 -1
  4. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/rules.py +15 -24
  5. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/version.py +1 -1
  6. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/CONTRIBUTING.md +0 -0
  7. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/LICENSE-2.0.txt +0 -0
  8. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/MANIFEST.in +0 -0
  9. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/README.md +0 -0
  10. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/__init__.py +0 -0
  11. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/civics_cdf_validator.egg-info/SOURCES.txt +0 -0
  12. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/civics_cdf_validator.egg-info/dependency_links.txt +0 -0
  13. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/civics_cdf_validator.egg-info/entry_points.txt +0 -0
  14. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/civics_cdf_validator.egg-info/requires.txt +0 -0
  15. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/civics_cdf_validator.egg-info/top_level.txt +0 -0
  16. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/gpunit_rules.py +0 -0
  17. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/loggers.py +0 -0
  18. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/office_utils.py +0 -0
  19. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/setup.cfg +0 -0
  20. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/setup.py +0 -0
  21. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/stats.py +0 -0
  22. {civics_cdf_validator-1.49.dev8 → civics_cdf_validator-1.49.dev9}/validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev8
3
+ Version: 1.49.dev9
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
@@ -17,7 +17,9 @@ limitations under the License.
17
17
  from __future__ import print_function
18
18
 
19
19
  import datetime
20
+ import functools
20
21
  import re
22
+
21
23
  from civics_cdf_validator import loggers
22
24
  from civics_cdf_validator import stats
23
25
  from lxml import etree
@@ -235,6 +237,7 @@ class DateRule(BaseRule):
235
237
  self.error_log.append(loggers.LogEntry(error_message, [self.end_elem]))
236
238
 
237
239
 
240
+ @functools.total_ordering
238
241
  class PartialDate():
239
242
  """Check for PartialDate."""
240
243
 
@@ -257,6 +260,12 @@ class PartialDate():
257
260
  else:
258
261
  return "Not defined"
259
262
 
263
+ def __lt__(self, other):
264
+ return self.is_older_than(other) > 0
265
+
266
+ def __eq__(self, other):
267
+ return self.is_older_than(other) == 0
268
+
260
269
  @classmethod
261
270
  def init_partial_date(cls, date_string):
262
271
  """Initializing partial date."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.49.dev8
3
+ Version: 1.49.dev9
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
@@ -2683,7 +2683,7 @@ class ElectionDatesSpanContestDates(base.DateRule):
2683
2683
  if (
2684
2684
  election_end_date is not None
2685
2685
  and self.end_date is not None
2686
- and election_end_date.is_older_than(self.end_date) > 0
2686
+ and election_end_date < self.end_date
2687
2687
  # Only compare election end date to contests that are not canceled
2688
2688
  and (
2689
2689
  contest_date_status is None
@@ -2705,7 +2705,7 @@ class ElectionDatesSpanContestDates(base.DateRule):
2705
2705
  if (
2706
2706
  election_start_date is not None
2707
2707
  and self.start_date is not None
2708
- and self.start_date.is_older_than(election_start_date) > 0
2708
+ and self.start_date < election_start_date
2709
2709
  ):
2710
2710
  self.error_log.append(
2711
2711
  loggers.LogEntry(
@@ -2955,7 +2955,6 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
2955
2955
  term = office.find(".//Term")
2956
2956
  if term is not None:
2957
2957
  date_validator = base.DateRule(None, None)
2958
- limit_check = 0
2959
2958
  date_validator.gather_dates(term)
2960
2959
  end_date_person = date_validator.end_date
2961
2960
  if end_date_person is not None:
@@ -2967,8 +2966,7 @@ class RemovePersonAndOfficeHolderId60DaysAfterEndDate(base.TreeRule):
2967
2966
  sixty_days_earlier.month,
2968
2967
  sixty_days_earlier.day,
2969
2968
  )
2970
- limit_check = partial_date_sixty_days.is_older_than(end_date_person)
2971
- if limit_check < 0:
2969
+ if end_date_person < partial_date_sixty_days:
2972
2970
  outdated_offices.append(office.get("objectId"))
2973
2971
  for person in persons:
2974
2972
  pid = person.get("objectId")
@@ -3518,11 +3516,11 @@ class SubsequentContestIdIsValidRelatedContest(base.DateRule):
3518
3516
  subsequent_contest = contest_by_id[subsequent_contest_id]
3519
3517
  # Check that the subsequent contest has a later end date
3520
3518
  if subsequent_contest is not None and contest is not None:
3521
- end_delta = base.PartialDate.is_older_than(
3522
- contest_end_date_by_id[subsequent_contest_id],
3523
- contest_end_date_by_id[contest_id],
3524
- )
3525
- if end_delta > 0:
3519
+ contest_end_date = contest_end_date_by_id[contest_id]
3520
+ subsequent_contest_end_date = contest_end_date_by_id[
3521
+ subsequent_contest_id
3522
+ ]
3523
+ if subsequent_contest_end_date < contest_end_date:
3526
3524
  error_log.append(
3527
3525
  loggers.LogEntry(
3528
3526
  f"Contest {contest_id} references a subsequent contest with"
@@ -3839,8 +3837,7 @@ class ContestEndDateOccursBeforeSubsequentContestStartDate(base.DateRule):
3839
3837
  _, contest_end = dates_by_contest_id[contest_id]
3840
3838
  subsequent_contest_start, _ = dates_by_contest_id[subsequent_contest_id]
3841
3839
  if contest_end is not None and subsequent_contest_start is not None:
3842
- date_delta = contest_end.is_older_than(subsequent_contest_start)
3843
- if date_delta < 0:
3840
+ if subsequent_contest_start < contest_end:
3844
3841
  self.error_log.append(
3845
3842
  loggers.LogEntry(
3846
3843
  "Contest {} with end date {} does not occur before"
@@ -4092,8 +4089,7 @@ class ElectionEventDatesAreSequential(base.DateRule):
4092
4089
  full_delivery_date = base.PartialDate.init_partial_date(
4093
4090
  element.find("FullDeliveryDate").text
4094
4091
  )
4095
- date_delta = self.start_date.is_older_than(full_delivery_date)
4096
- if date_delta > 0:
4092
+ if self.start_date < full_delivery_date:
4097
4093
  self.error_log.append(
4098
4094
  loggers.LogEntry(
4099
4095
  "StartDate is older than FullDeliveryDate",
@@ -4109,8 +4105,7 @@ class ElectionEventDatesAreSequential(base.DateRule):
4109
4105
  full_delivery_date = base.PartialDate.init_partial_date(
4110
4106
  element.find("FullDeliveryDate").text
4111
4107
  )
4112
- date_delta = full_delivery_date.is_older_than(initial_delivery_date)
4113
- if date_delta > 0:
4108
+ if full_delivery_date < initial_delivery_date:
4114
4109
  self.error_log.append(
4115
4110
  loggers.LogEntry(
4116
4111
  "FullDeliveryDate is older than InitialDeliveryDate",
@@ -4143,10 +4138,7 @@ class NoSourceDirPathBeforeInitialDeliveryDate(base.BaseRule):
4143
4138
  if element_has_text(initial_delivery)
4144
4139
  else None
4145
4140
  )
4146
- if (
4147
- initial_delivery_date
4148
- and initial_delivery_date.is_older_than(today_partial_date) > 0
4149
- ):
4141
+ if initial_delivery_date and initial_delivery_date < today_partial_date:
4150
4142
  return
4151
4143
  raise loggers.ElectionWarning.from_message(
4152
4144
  "SourceDirPath is defined but all initialDeliveryDate are in the"
@@ -4171,8 +4163,7 @@ class OfficeHolderSubFeedDatesAreSequential(base.DateRule):
4171
4163
  full_delivery_date = base.PartialDate.init_partial_date(
4172
4164
  element.find("FullDeliveryDate").text
4173
4165
  )
4174
- date_delta = full_delivery_date.is_older_than(initial_delivery_date)
4175
- if date_delta > 0:
4166
+ if full_delivery_date < initial_delivery_date:
4176
4167
  raise loggers.ElectionError.from_message(
4177
4168
  "FullDeliveryDate is older than InitialDeliveryDate",
4178
4169
  [element],
@@ -4194,14 +4185,14 @@ class FeedInactiveDateIsLatestDate(base.BaseRule):
4194
4185
  full_delivery_date = base.PartialDate.init_partial_date(
4195
4186
  full_delivery_date_element.text
4196
4187
  )
4197
- if feed_inactive_date.is_older_than(full_delivery_date) > 0:
4188
+ if feed_inactive_date < full_delivery_date:
4198
4189
  raise loggers.ElectionError.from_message(
4199
4190
  "FeedInactiveDate is older than FullDeliveryDate",
4200
4191
  [element],
4201
4192
  )
4202
4193
  for end_date_element in element.iter("EndDate"):
4203
4194
  end_date = base.PartialDate.init_partial_date(end_date_element.text)
4204
- if feed_inactive_date.is_older_than(end_date) > 0:
4195
+ if feed_inactive_date < end_date:
4205
4196
  raise loggers.ElectionError.from_message(
4206
4197
  "FeedInactiveDate is older than EndDate",
4207
4198
  [element],
@@ -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.49.dev8'
8
+ __version__ = '1.49.dev9'