mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-20 05:13:21 -07:00
Update apscheduler==3.8.1
This commit is contained in:
parent
a6c933cfce
commit
973cad264f
20 changed files with 1122 additions and 333 deletions
58
lib/pytz_deprecation_shim/_compat_py3.py
Normal file
58
lib/pytz_deprecation_shim/_compat_py3.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Note: This file could use Python 3-only syntax, but at the moment this breaks
|
||||
# the coverage job on Python 2. Until we make it so that coverage can ignore
|
||||
# this file only on Python 2, we'll have to stick to 2/3-compatible syntax.
|
||||
try:
|
||||
import zoneinfo
|
||||
except ImportError:
|
||||
from backports import zoneinfo
|
||||
|
||||
import datetime
|
||||
|
||||
UTC = datetime.timezone.utc
|
||||
|
||||
|
||||
def get_timezone(key):
|
||||
try:
|
||||
return zoneinfo.ZoneInfo(key)
|
||||
except (ValueError, OSError):
|
||||
# TODO: Use `from e` when this file can use Python 3 syntax
|
||||
raise KeyError(key)
|
||||
|
||||
|
||||
def get_timezone_file(f, key=None):
|
||||
return zoneinfo.ZoneInfo.from_file(f, key=key)
|
||||
|
||||
|
||||
def get_fixed_offset_zone(offset):
|
||||
return datetime.timezone(datetime.timedelta(minutes=offset))
|
||||
|
||||
|
||||
def is_imaginary(dt):
|
||||
dt_rt = dt.astimezone(UTC).astimezone(dt.tzinfo)
|
||||
|
||||
return not (dt == dt_rt)
|
||||
|
||||
|
||||
def is_ambiguous(dt):
|
||||
if is_imaginary(dt):
|
||||
return False
|
||||
|
||||
wall_0 = dt
|
||||
wall_1 = dt.replace(fold=not dt.fold)
|
||||
|
||||
# Ambiguous datetimes can only exist if the offset changes, so we don't
|
||||
# actually have to check whether dst() or tzname() are different.
|
||||
same_offset = wall_0.utcoffset() == wall_1.utcoffset()
|
||||
|
||||
return not same_offset
|
||||
|
||||
|
||||
def enfold(dt, fold=1):
|
||||
if dt.fold != fold:
|
||||
return dt.replace(fold=fold)
|
||||
else:
|
||||
return dt
|
||||
|
||||
|
||||
def get_fold(dt):
|
||||
return dt.fold
|
Loading…
Add table
Add a link
Reference in a new issue