mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Update pytz to 2018.6
Update the pytz library files to those from the 2018.6 release.
This commit is contained in:
parent
c08cec40cb
commit
71cb2d9c4c
609 changed files with 4505 additions and 209 deletions
|
@ -8,12 +8,25 @@ See the datetime section of the Python Library Reference for information
|
|||
on how to use these modules.
|
||||
'''
|
||||
|
||||
import sys
|
||||
import datetime
|
||||
import os.path
|
||||
|
||||
from pytz.exceptions import AmbiguousTimeError
|
||||
from pytz.exceptions import InvalidTimeError
|
||||
from pytz.exceptions import NonExistentTimeError
|
||||
from pytz.exceptions import UnknownTimeZoneError
|
||||
from pytz.lazy import LazyDict, LazyList, LazySet
|
||||
from pytz.tzinfo import unpickler, BaseTzInfo
|
||||
from pytz.tzfile import build_tzinfo
|
||||
|
||||
|
||||
# The IANA (nee Olson) database is updated several times a year.
|
||||
OLSON_VERSION = '2016f'
|
||||
VERSION = '2016.6.1' # Switching to pip compatible version numbering.
|
||||
OLSON_VERSION = '2018f'
|
||||
VERSION = '2018.6' # pip compatible version number.
|
||||
__version__ = VERSION
|
||||
|
||||
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
|
||||
OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
|
||||
|
||||
__all__ = [
|
||||
'timezone', 'utc', 'country_timezones', 'country_names',
|
||||
|
@ -21,23 +34,11 @@ __all__ = [
|
|||
'NonExistentTimeError', 'UnknownTimeZoneError',
|
||||
'all_timezones', 'all_timezones_set',
|
||||
'common_timezones', 'common_timezones_set',
|
||||
]
|
||||
|
||||
import sys, datetime, os.path, gettext
|
||||
|
||||
from pytz.exceptions import AmbiguousTimeError
|
||||
from pytz.exceptions import InvalidTimeError
|
||||
from pytz.exceptions import NonExistentTimeError
|
||||
from pytz.exceptions import UnknownTimeZoneError
|
||||
from pytz.lazy import LazyDict, LazyList, LazySet
|
||||
from pytz.tzinfo import unpickler
|
||||
from pytz.tzfile import build_tzinfo, _byte_string
|
||||
'BaseTzInfo',
|
||||
]
|
||||
|
||||
|
||||
try:
|
||||
unicode
|
||||
|
||||
except NameError: # Python 3.x
|
||||
if sys.version_info[0] > 2: # Python 3.x
|
||||
|
||||
# Python 3.x doesn't have unicode(), making writing code
|
||||
# for Python 2.3 and Python 3.x a pain.
|
||||
|
@ -52,10 +53,13 @@ except NameError: # Python 3.x
|
|||
...
|
||||
UnicodeEncodeError: ...
|
||||
"""
|
||||
s.encode('ASCII') # Raise an exception if not ASCII
|
||||
return s # But return the original string - not a byte string.
|
||||
if type(s) == bytes:
|
||||
s = s.decode('ASCII')
|
||||
else:
|
||||
s.encode('ASCII') # Raise an exception if not ASCII
|
||||
return s # But the string - not a byte string.
|
||||
|
||||
else: # Python 2.x
|
||||
else: # Python 2.x
|
||||
|
||||
def ascii(s):
|
||||
r"""
|
||||
|
@ -76,24 +80,31 @@ def open_resource(name):
|
|||
|
||||
Uses the pkg_resources module if available and no standard file
|
||||
found at the calculated location.
|
||||
|
||||
It is possible to specify different location for zoneinfo
|
||||
subdir by using the PYTZ_TZDATADIR environment variable.
|
||||
"""
|
||||
name_parts = name.lstrip('/').split('/')
|
||||
for part in name_parts:
|
||||
if part == os.path.pardir or os.path.sep in part:
|
||||
raise ValueError('Bad path segment: %r' % part)
|
||||
filename = os.path.join(os.path.dirname(__file__),
|
||||
'zoneinfo', *name_parts)
|
||||
if not os.path.exists(filename):
|
||||
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
|
||||
# unless absolutely necessary to help when a broken version of
|
||||
# pkg_resources is installed.
|
||||
try:
|
||||
from pkg_resources import resource_stream
|
||||
except ImportError:
|
||||
resource_stream = None
|
||||
zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', None)
|
||||
if zoneinfo_dir is not None:
|
||||
filename = os.path.join(zoneinfo_dir, *name_parts)
|
||||
else:
|
||||
filename = os.path.join(os.path.dirname(__file__),
|
||||
'zoneinfo', *name_parts)
|
||||
if not os.path.exists(filename):
|
||||
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
|
||||
# unless absolutely necessary to help when a broken version of
|
||||
# pkg_resources is installed.
|
||||
try:
|
||||
from pkg_resources import resource_stream
|
||||
except ImportError:
|
||||
resource_stream = None
|
||||
|
||||
if resource_stream is not None:
|
||||
return resource_stream(__name__, 'zoneinfo/' + name)
|
||||
if resource_stream is not None:
|
||||
return resource_stream(__name__, 'zoneinfo/' + name)
|
||||
return open(filename, 'rb')
|
||||
|
||||
|
||||
|
@ -106,23 +117,9 @@ def resource_exists(name):
|
|||
return False
|
||||
|
||||
|
||||
# Enable this when we get some translations?
|
||||
# We want an i18n API that is useful to programs using Python's gettext
|
||||
# module, as well as the Zope3 i18n package. Perhaps we should just provide
|
||||
# the POT file and translations, and leave it up to callers to make use
|
||||
# of them.
|
||||
#
|
||||
# t = gettext.translation(
|
||||
# 'pytz', os.path.join(os.path.dirname(__file__), 'locales'),
|
||||
# fallback=True
|
||||
# )
|
||||
# def _(timezone_name):
|
||||
# """Translate a timezone name using the current locale, returning Unicode"""
|
||||
# return t.ugettext(timezone_name)
|
||||
|
||||
|
||||
_tzinfo_cache = {}
|
||||
|
||||
|
||||
def timezone(zone):
|
||||
r''' Return a datetime.tzinfo implementation for the given timezone
|
||||
|
||||
|
@ -192,7 +189,7 @@ ZERO = datetime.timedelta(0)
|
|||
HOUR = datetime.timedelta(hours=1)
|
||||
|
||||
|
||||
class UTC(datetime.tzinfo):
|
||||
class UTC(BaseTzInfo):
|
||||
"""UTC
|
||||
|
||||
Optimized UTC implementation. It unpickles using the single module global
|
||||
|
@ -288,7 +285,6 @@ def _p(*args):
|
|||
_p.__safe_for_unpickling__ = True
|
||||
|
||||
|
||||
|
||||
class _CountryTimezoneDict(LazyDict):
|
||||
"""Map ISO 3166 country code to a list of timezone names commonly used
|
||||
in that country.
|
||||
|
@ -374,7 +370,7 @@ country_names = _CountryNameDict()
|
|||
|
||||
class _FixedOffset(datetime.tzinfo):
|
||||
|
||||
zone = None # to match the standard pytz API
|
||||
zone = None # to match the standard pytz API
|
||||
|
||||
def __init__(self, minutes):
|
||||
if abs(minutes) >= 1440:
|
||||
|
@ -412,24 +408,24 @@ class _FixedOffset(datetime.tzinfo):
|
|||
return dt.astimezone(self)
|
||||
|
||||
|
||||
def FixedOffset(offset, _tzinfos = {}):
|
||||
def FixedOffset(offset, _tzinfos={}):
|
||||
"""return a fixed-offset timezone based off a number of minutes.
|
||||
|
||||
>>> one = FixedOffset(-330)
|
||||
>>> one
|
||||
pytz.FixedOffset(-330)
|
||||
>>> one.utcoffset(datetime.datetime.now())
|
||||
datetime.timedelta(-1, 66600)
|
||||
>>> one.dst(datetime.datetime.now())
|
||||
datetime.timedelta(0)
|
||||
>>> str(one.utcoffset(datetime.datetime.now()))
|
||||
'-1 day, 18:30:00'
|
||||
>>> str(one.dst(datetime.datetime.now()))
|
||||
'0:00:00'
|
||||
|
||||
>>> two = FixedOffset(1380)
|
||||
>>> two
|
||||
pytz.FixedOffset(1380)
|
||||
>>> two.utcoffset(datetime.datetime.now())
|
||||
datetime.timedelta(0, 82800)
|
||||
>>> two.dst(datetime.datetime.now())
|
||||
datetime.timedelta(0)
|
||||
>>> str(two.utcoffset(datetime.datetime.now()))
|
||||
'23:00:00'
|
||||
>>> str(two.dst(datetime.datetime.now()))
|
||||
'0:00:00'
|
||||
|
||||
The datetime.timedelta must be between the range of -1 and 1 day,
|
||||
non-inclusive.
|
||||
|
@ -482,14 +478,13 @@ FixedOffset.__safe_for_unpickling__ = True
|
|||
|
||||
|
||||
def _test():
|
||||
import doctest, os, sys
|
||||
import doctest
|
||||
sys.path.insert(0, os.pardir)
|
||||
import pytz
|
||||
return doctest.testmod(pytz)
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
||||
|
||||
all_timezones = \
|
||||
['Africa/Abidjan',
|
||||
'Africa/Accra',
|
||||
|
@ -676,6 +671,7 @@ all_timezones = \
|
|||
'America/Porto_Acre',
|
||||
'America/Porto_Velho',
|
||||
'America/Puerto_Rico',
|
||||
'America/Punta_Arenas',
|
||||
'America/Rainy_River',
|
||||
'America/Rankin_Inlet',
|
||||
'America/Recife',
|
||||
|
@ -731,6 +727,7 @@ all_timezones = \
|
|||
'Asia/Aqtobe',
|
||||
'Asia/Ashgabat',
|
||||
'Asia/Ashkhabad',
|
||||
'Asia/Atyrau',
|
||||
'Asia/Baghdad',
|
||||
'Asia/Bahrain',
|
||||
'Asia/Baku',
|
||||
|
@ -751,6 +748,7 @@ all_timezones = \
|
|||
'Asia/Dili',
|
||||
'Asia/Dubai',
|
||||
'Asia/Dushanbe',
|
||||
'Asia/Famagusta',
|
||||
'Asia/Gaza',
|
||||
'Asia/Harbin',
|
||||
'Asia/Hebron',
|
||||
|
@ -816,6 +814,7 @@ all_timezones = \
|
|||
'Asia/Vientiane',
|
||||
'Asia/Vladivostok',
|
||||
'Asia/Yakutsk',
|
||||
'Asia/Yangon',
|
||||
'Asia/Yekaterinburg',
|
||||
'Asia/Yerevan',
|
||||
'Atlantic/Azores',
|
||||
|
@ -861,7 +860,6 @@ all_timezones = \
|
|||
'CST6CDT',
|
||||
'Canada/Atlantic',
|
||||
'Canada/Central',
|
||||
'Canada/East-Saskatchewan',
|
||||
'Canada/Eastern',
|
||||
'Canada/Mountain',
|
||||
'Canada/Newfoundland',
|
||||
|
@ -955,6 +953,7 @@ all_timezones = \
|
|||
'Europe/Samara',
|
||||
'Europe/San_Marino',
|
||||
'Europe/Sarajevo',
|
||||
'Europe/Saratov',
|
||||
'Europe/Simferopol',
|
||||
'Europe/Skopje',
|
||||
'Europe/Sofia',
|
||||
|
@ -1072,7 +1071,6 @@ all_timezones = \
|
|||
'US/Michigan',
|
||||
'US/Mountain',
|
||||
'US/Pacific',
|
||||
'US/Pacific-New',
|
||||
'US/Samoa',
|
||||
'UTC',
|
||||
'Universal',
|
||||
|
@ -1252,6 +1250,7 @@ common_timezones = \
|
|||
'America/Port_of_Spain',
|
||||
'America/Porto_Velho',
|
||||
'America/Puerto_Rico',
|
||||
'America/Punta_Arenas',
|
||||
'America/Rainy_River',
|
||||
'America/Rankin_Inlet',
|
||||
'America/Recife',
|
||||
|
@ -1301,6 +1300,7 @@ common_timezones = \
|
|||
'Asia/Aqtau',
|
||||
'Asia/Aqtobe',
|
||||
'Asia/Ashgabat',
|
||||
'Asia/Atyrau',
|
||||
'Asia/Baghdad',
|
||||
'Asia/Bahrain',
|
||||
'Asia/Baku',
|
||||
|
@ -1317,6 +1317,7 @@ common_timezones = \
|
|||
'Asia/Dili',
|
||||
'Asia/Dubai',
|
||||
'Asia/Dushanbe',
|
||||
'Asia/Famagusta',
|
||||
'Asia/Gaza',
|
||||
'Asia/Hebron',
|
||||
'Asia/Ho_Chi_Minh',
|
||||
|
@ -1351,7 +1352,6 @@ common_timezones = \
|
|||
'Asia/Pyongyang',
|
||||
'Asia/Qatar',
|
||||
'Asia/Qyzylorda',
|
||||
'Asia/Rangoon',
|
||||
'Asia/Riyadh',
|
||||
'Asia/Sakhalin',
|
||||
'Asia/Samarkand',
|
||||
|
@ -1372,6 +1372,7 @@ common_timezones = \
|
|||
'Asia/Vientiane',
|
||||
'Asia/Vladivostok',
|
||||
'Asia/Yakutsk',
|
||||
'Asia/Yangon',
|
||||
'Asia/Yekaterinburg',
|
||||
'Asia/Yerevan',
|
||||
'Atlantic/Azores',
|
||||
|
@ -1444,6 +1445,7 @@ common_timezones = \
|
|||
'Europe/Samara',
|
||||
'Europe/San_Marino',
|
||||
'Europe/Sarajevo',
|
||||
'Europe/Saratov',
|
||||
'Europe/Simferopol',
|
||||
'Europe/Skopje',
|
||||
'Europe/Sofia',
|
||||
|
@ -1489,7 +1491,6 @@ common_timezones = \
|
|||
'Pacific/Guadalcanal',
|
||||
'Pacific/Guam',
|
||||
'Pacific/Honolulu',
|
||||
'Pacific/Johnston',
|
||||
'Pacific/Kiritimati',
|
||||
'Pacific/Kosrae',
|
||||
'Pacific/Kwajalein',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue