mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Bump tempora from 5.0.2 to 5.1.0 (#1902)
* Bump tempora from 5.0.2 to 5.1.0 Bumps [tempora](https://github.com/jaraco/tempora) from 5.0.2 to 5.1.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/v5.0.2...v5.1.0) --- updated-dependencies: - dependency-name: tempora dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update tempora==5.1.0 Signed-off-by: dependabot[bot] <support@github.com> 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:
parent
d736fab432
commit
0a5edebea3
5 changed files with 28 additions and 16 deletions
0
lib/more_itertools/more.py
Normal file → Executable file
0
lib/more_itertools/more.py
Normal file → Executable file
|
@ -6,6 +6,10 @@ import re
|
|||
import numbers
|
||||
import functools
|
||||
import contextlib
|
||||
from numbers import Number
|
||||
from typing import Union, Tuple, Iterable
|
||||
from typing import cast
|
||||
|
||||
|
||||
from jaraco.functools import once
|
||||
|
||||
|
@ -33,7 +37,7 @@ hours_per_month = hours_per_day * days_per_year / 12
|
|||
|
||||
|
||||
@once
|
||||
def _needs_year_help():
|
||||
def _needs_year_help() -> bool:
|
||||
"""
|
||||
Some versions of Python render %Y with only three characters :(
|
||||
https://bugs.python.org/issue39103
|
||||
|
@ -41,14 +45,19 @@ def _needs_year_help():
|
|||
return len(datetime.date(900, 1, 1).strftime('%Y')) != 4
|
||||
|
||||
|
||||
def ensure_datetime(ob):
|
||||
AnyDatetime = Union[datetime.datetime, datetime.date, datetime.time]
|
||||
StructDatetime = Union[Tuple[int, ...], time.struct_time]
|
||||
|
||||
|
||||
def ensure_datetime(ob: AnyDatetime) -> datetime.datetime:
|
||||
"""
|
||||
Given a datetime or date or time object from the ``datetime``
|
||||
module, always return a datetime using default values.
|
||||
"""
|
||||
if isinstance(ob, datetime.datetime):
|
||||
return ob
|
||||
date = time = ob
|
||||
date = cast(datetime.date, ob)
|
||||
time = cast(datetime.time, ob)
|
||||
if isinstance(ob, datetime.date):
|
||||
time = datetime.time()
|
||||
if isinstance(ob, datetime.time):
|
||||
|
@ -56,7 +65,13 @@ def ensure_datetime(ob):
|
|||
return datetime.datetime.combine(date, time)
|
||||
|
||||
|
||||
def strftime(fmt, t):
|
||||
def infer_datetime(ob: Union[AnyDatetime, StructDatetime]) -> datetime.datetime:
|
||||
if isinstance(ob, (time.struct_time, tuple)):
|
||||
ob = datetime.datetime(*ob[:6]) # type: ignore
|
||||
return ensure_datetime(ob)
|
||||
|
||||
|
||||
def strftime(fmt: str, t: Union[AnyDatetime, tuple, time.struct_time]) -> str:
|
||||
"""
|
||||
Portable strftime.
|
||||
|
||||
|
@ -115,15 +130,11 @@ def strftime(fmt, t):
|
|||
>>> strftime('%Y', datetime.time())
|
||||
'1900'
|
||||
"""
|
||||
if isinstance(t, (time.struct_time, tuple)):
|
||||
t = datetime.datetime(*t[:6])
|
||||
t = ensure_datetime(t)
|
||||
t = infer_datetime(t)
|
||||
subs = (
|
||||
('%s', '%03d' % (t.microsecond // 1000)),
|
||||
('%µ', '%03d' % (t.microsecond % 1000)),
|
||||
)
|
||||
if _needs_year_help(): # pragma: nocover
|
||||
subs += (('%Y', '%04d' % t.year),)
|
||||
) + (('%Y', '%04d' % t.year),) * _needs_year_help()
|
||||
|
||||
def doSub(s, sub):
|
||||
return s.replace(*sub)
|
||||
|
@ -324,10 +335,10 @@ def calculate_prorated_values():
|
|||
"""
|
||||
rate = input("Enter the rate (3/hour, 50/month)> ")
|
||||
for period, value in _prorated_values(rate):
|
||||
print("per {period}: {value}".format(**locals()))
|
||||
print(f"per {period}: {value}")
|
||||
|
||||
|
||||
def _prorated_values(rate):
|
||||
def _prorated_values(rate: str) -> Iterable[Tuple[str, Number]]:
|
||||
"""
|
||||
Given a rate (a string in units per unit time), and return that same
|
||||
rate for various time periods.
|
||||
|
@ -341,7 +352,8 @@ def _prorated_values(rate):
|
|||
year: 175316.333
|
||||
|
||||
"""
|
||||
res = re.match(r'(?P<value>[\d.]+)/(?P<period>\w+)$', rate).groupdict()
|
||||
match = re.match(r'(?P<value>[\d.]+)/(?P<period>\w+)$', rate)
|
||||
res = cast(re.Match, match).groupdict()
|
||||
value = float(res['value'])
|
||||
value_per_second = value / get_period_seconds(res['period'])
|
||||
for period in ('minute', 'hour', 'day', 'month', 'year'):
|
||||
|
|
|
@ -130,7 +130,7 @@ class PeriodicCommand(DelayedCommand):
|
|||
raise ValueError(
|
||||
"A PeriodicCommand must have a positive, " "non-zero delay."
|
||||
)
|
||||
super(PeriodicCommand, self).__setattr__(key, value)
|
||||
super().__setattr__(key, value)
|
||||
|
||||
|
||||
class PeriodicCommandFixedDelay(PeriodicCommand):
|
||||
|
|
|
@ -115,7 +115,7 @@ class Timer(Stopwatch):
|
|||
|
||||
def __init__(self, target=float('Inf')):
|
||||
self.target = self._accept(target)
|
||||
super(Timer, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
@staticmethod
|
||||
def _accept(target):
|
||||
|
|
|
@ -41,7 +41,7 @@ rumps==0.4.0; platform_system == "Darwin"
|
|||
simplejson==3.18.0
|
||||
six==1.16.0
|
||||
soupsieve==2.3.2.post1
|
||||
tempora==5.0.2
|
||||
tempora==5.1.0
|
||||
tokenize-rt==5.0.0
|
||||
tzdata==2022.6
|
||||
tzlocal==4.2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue