Bump tempora from 4.1.2 to 5.0.0 (#1609)

* Bump tempora from 4.1.2 to 5.0.0

Bumps [tempora](https://github.com/jaraco/tempora) from 4.1.2 to 5.0.0.
- [Release notes](https://github.com/jaraco/tempora/releases)
- [Changelog](https://github.com/jaraco/tempora/blob/main/CHANGES.rst)
- [Commits](https://github.com/jaraco/tempora/compare/v4.1.2...v5.0.0)

---
updated-dependencies:
- dependency-name: tempora
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update tempora==5.0.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2022-01-25 11:07:56 -08:00 committed by GitHub
commit 2829041dc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 100 deletions

View file

@ -5,86 +5,20 @@ import time
import re import re
import numbers import numbers
import functools import functools
import warnings
import contextlib import contextlib
from jaraco.functools import once from jaraco.functools import once
class Parser:
"""
*deprecated*
Datetime parser: parses a date-time string using multiple possible
formats.
>>> p = Parser(('%H%M', '%H:%M'))
>>> tuple(p.parse('1319'))
(1900, 1, 1, 13, 19, 0, 0, 1, -1)
>>> dateParser = Parser(('%m/%d/%Y', '%Y-%m-%d', '%d-%b-%Y'))
>>> tuple(dateParser.parse('2003-12-20'))
(2003, 12, 20, 0, 0, 0, 5, 354, -1)
>>> tuple(dateParser.parse('16-Dec-1994'))
(1994, 12, 16, 0, 0, 0, 4, 350, -1)
>>> tuple(dateParser.parse('5/19/2003'))
(2003, 5, 19, 0, 0, 0, 0, 139, -1)
>>> dtParser = Parser(('%Y-%m-%d %H:%M:%S', '%a %b %d %H:%M:%S %Y'))
>>> tuple(dtParser.parse('2003-12-20 19:13:26'))
(2003, 12, 20, 19, 13, 26, 5, 354, -1)
>>> tuple(dtParser.parse('Tue Jan 20 16:19:33 2004'))
(2004, 1, 20, 16, 19, 33, 1, 20, -1)
Be forewarned, a ValueError will be raised if more than one format
matches:
>>> Parser(('%H%M', '%H%M%S')).parse('732')
Traceback (most recent call last):
...
ValueError: More than one format string matched target 732.
>>> Parser(('%H',)).parse('22:21')
Traceback (most recent call last):
...
ValueError: No format strings matched the target 22:21.
"""
formats = ('%m/%d/%Y', '%m/%d/%y', '%Y-%m-%d', '%d-%b-%Y', '%d-%b-%y')
"some common default formats"
def __init__(self, formats=None):
warnings.warn("Use dateutil.parser", DeprecationWarning)
if formats:
self.formats = formats
def parse(self, target):
self.target = target
results = tuple(filter(None, map(self._parse, self.formats)))
del self.target
if not results:
tmpl = "No format strings matched the target {target}."
raise ValueError(tmpl.format(**locals()))
if not len(results) == 1:
tmpl = "More than one format string matched target {target}."
raise ValueError(tmpl.format(**locals()))
return results[0]
def _parse(self, format):
try:
result = time.strptime(self.target, format)
except ValueError:
result = False
return result
# some useful constants # some useful constants
osc_per_year = 290091329207984000 osc_per_year = 290_091_329_207_984_000
""" """
mean vernal equinox year expressed in oscillations of atomic cesium at the mean vernal equinox year expressed in oscillations of atomic cesium at the
year 2000 (see http://webexhibits.org/calendars/timeline.html for more info). year 2000 (see http://webexhibits.org/calendars/timeline.html for more info).
""" """
osc_per_second = 9192631770 osc_per_second = 9_192_631_770
seconds_per_second = 1 seconds_per_second = 1
seconds_per_year = 31556940 seconds_per_year = 31_556_940
seconds_per_minute = 60 seconds_per_minute = 60
minutes_per_hour = 60 minutes_per_hour = 60
hours_per_day = 24 hours_per_day = 24
@ -376,21 +310,6 @@ def get_date_format_string(period):
return ''.join(format_pieces) return ''.join(format_pieces)
def divide_timedelta_float(td, divisor):
"""
Divide a timedelta by a float value
>>> one_day = datetime.timedelta(days=1)
>>> half_day = datetime.timedelta(days=.5)
>>> divide_timedelta_float(one_day, 2.0) == half_day
True
>>> divide_timedelta_float(one_day, 2) == half_day
True
"""
warnings.warn("Use native division", DeprecationWarning)
return td / divisor
def calculate_prorated_values(): def calculate_prorated_values():
""" """
>>> monkeypatch = getfixture('monkeypatch') >>> monkeypatch = getfixture('monkeypatch')
@ -461,6 +380,11 @@ def parse_timedelta(str):
>>> diff.seconds >>> diff.seconds
20940 20940
>>> parse_timedelta('foo')
Traceback (most recent call last):
...
ValueError: Unexpected 'foo'
>>> parse_timedelta('14 seconds foo') >>> parse_timedelta('14 seconds foo')
Traceback (most recent call last): Traceback (most recent call last):
... ...
@ -508,6 +432,13 @@ def parse_timedelta(str):
>>> parse_timedelta('.002 µs, 499 ns') >>> parse_timedelta('.002 µs, 499 ns')
datetime.timedelta(microseconds=1) datetime.timedelta(microseconds=1)
Expect ValueError for other invalid inputs.
>>> parse_timedelta('13 feet')
Traceback (most recent call last):
...
ValueError: Invalid unit feets
""" """
return _parse_timedelta_nanos(str).resolve() return _parse_timedelta_nanos(str).resolve()
@ -534,7 +465,7 @@ def _check_unmatched(matches, text):
check_unmatched(text[pos : match.start()]) check_unmatched(text[pos : match.start()])
yield match yield match
pos = match.end() pos = match.end()
check_unmatched(text[match.end() :]) check_unmatched(text[pos:])
_unit_lookup = { _unit_lookup = {
@ -618,7 +549,11 @@ class _Saved_NS:
if unit == 'nanoseconds': if unit == 'nanoseconds':
return _Saved_NS(nanoseconds=value) return _Saved_NS(nanoseconds=value)
res = _Saved_NS(td=datetime.timedelta(**{unit: value})) try:
raw_td = datetime.timedelta(**{unit: value})
except TypeError:
raise ValueError(f"Invalid unit {unit}")
res = _Saved_NS(td=raw_td)
with contextlib.suppress(KeyError): with contextlib.suppress(KeyError):
res.nanoseconds = int(value * cls.multiplier[unit]) % 1000 res.nanoseconds = int(value * cls.multiplier[unit]) % 1000
return res return res
@ -641,19 +576,6 @@ class _Saved_NS:
return f'_Saved_NS(td={self.td!r}, nanoseconds={self.nanoseconds!r})' return f'_Saved_NS(td={self.td!r}, nanoseconds={self.nanoseconds!r})'
def divide_timedelta(td1, td2):
"""
Get the ratio of two timedeltas
>>> one_day = datetime.timedelta(days=1)
>>> one_hour = datetime.timedelta(hours=1)
>>> divide_timedelta(one_hour, one_day) == 1 / 24
True
"""
warnings.warn("Use native division", DeprecationWarning)
return td1 / td2
def date_range(start=None, stop=None, step=None): def date_range(start=None, stop=None, step=None):
""" """
Much like the built-in function range, but works with dates Much like the built-in function range, but works with dates

View file

@ -41,7 +41,7 @@ rumps==0.3.0; platform_system == "Darwin"
simplejson==3.17.6 simplejson==3.17.6
six==1.16.0 six==1.16.0
soupsieve==2.3.1 soupsieve==2.3.1
tempora==4.1.2 tempora==5.0.0
tokenize-rt==4.2.1 tokenize-rt==4.2.1
tzdata==2021.5 tzdata==2021.5
tzlocal==2.1 # apscheduler==3.8.0 requires tzlocal~=2.0 tzlocal==2.1 # apscheduler==3.8.0 requires tzlocal~=2.0