Current File : /home/mmdealscpanel/yummmdeals.com/tz.tar
__init__.py000064400000000317150373450210006656 0ustar00from .tz import *

__all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange",
           "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz",
           "enfold", "datetime_ambiguous", "datetime_exists"]
win.py000064400000026205150373450210005720 0ustar00# This code was originally contributed by Jeffrey Harris.
import datetime
import struct

from six.moves import winreg
from six import text_type

try:
    import ctypes
    from ctypes import wintypes
except ValueError:
    # ValueError is raised on non-Windows systems for some horrible reason.
    raise ImportError("Running tzwin on non-Windows system")

from ._common import tzrangebase

__all__ = ["tzwin", "tzwinlocal", "tzres"]

ONEWEEK = datetime.timedelta(7)

TZKEYNAMENT = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
TZKEYNAME9X = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zones"
TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation"


def _settzkeyname():
    handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
    try:
        winreg.OpenKey(handle, TZKEYNAMENT).Close()
        TZKEYNAME = TZKEYNAMENT
    except WindowsError:
        TZKEYNAME = TZKEYNAME9X
    handle.Close()
    return TZKEYNAME


TZKEYNAME = _settzkeyname()


class tzres(object):
    """
    Class for accessing `tzres.dll`, which contains timezone name related
    resources.

    .. versionadded:: 2.5.0
    """
    p_wchar = ctypes.POINTER(wintypes.WCHAR)        # Pointer to a wide char

    def __init__(self, tzres_loc='tzres.dll'):
        # Load the user32 DLL so we can load strings from tzres
        user32 = ctypes.WinDLL('user32')

        # Specify the LoadStringW function
        user32.LoadStringW.argtypes = (wintypes.HINSTANCE,
                                       wintypes.UINT,
                                       wintypes.LPWSTR,
                                       ctypes.c_int)

        self.LoadStringW = user32.LoadStringW
        self._tzres = ctypes.WinDLL(tzres_loc)
        self.tzres_loc = tzres_loc

    def load_name(self, offset):
        """
        Load a timezone name from a DLL offset (integer).

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.load_name(112))
        'Eastern Standard Time'

        :param offset:
            A positive integer value referring to a string from the tzres dll.

        ..note:
            Offsets found in the registry are generally of the form
            `@tzres.dll,-114`. The offset in this case if 114, not -114.

        """
        resource = self.p_wchar()
        lpBuffer = ctypes.cast(ctypes.byref(resource), wintypes.LPWSTR)
        nchar = self.LoadStringW(self._tzres._handle, offset, lpBuffer, 0)
        return resource[:nchar]

    def name_from_string(self, tzname_str):
        """
        Parse strings as returned from the Windows registry into the time zone
        name as defined in the registry.

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.name_from_string('@tzres.dll,-251'))
        'Dateline Daylight Time'
        >>> print(tzr.name_from_string('Eastern Standard Time'))
        'Eastern Standard Time'

        :param tzname_str:
            A timezone name string as returned from a Windows registry key.

        :return:
            Returns the localized timezone string from tzres.dll if the string
            is of the form `@tzres.dll,-offset`, else returns the input string.
        """
        if not tzname_str.startswith('@'):
            return tzname_str

        name_splt = tzname_str.split(',-')
        try:
            offset = int(name_splt[1])
        except:
            raise ValueError("Malformed timezone string.")

        return self.load_name(offset)


class tzwinbase(tzrangebase):
    """tzinfo class based on win32's timezones available in the registry."""
    def __init__(self):
        raise NotImplementedError('tzwinbase is an abstract base class')

    def __eq__(self, other):
        # Compare on all relevant dimensions, including name.
        if not isinstance(other, tzwinbase):
            return NotImplemented

        return  (self._std_offset == other._std_offset and
                 self._dst_offset == other._dst_offset and
                 self._stddayofweek == other._stddayofweek and
                 self._dstdayofweek == other._dstdayofweek and
                 self._stdweeknumber == other._stdweeknumber and
                 self._dstweeknumber == other._dstweeknumber and
                 self._stdhour == other._stdhour and
                 self._dsthour == other._dsthour and
                 self._stdminute == other._stdminute and
                 self._dstminute == other._dstminute and
                 self._std_abbr == other._std_abbr and
                 self._dst_abbr == other._dst_abbr)

    @staticmethod
    def list():
        """Return a list of all time zones known to the system."""
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
            with winreg.OpenKey(handle, TZKEYNAME) as tzkey:
                result = [winreg.EnumKey(tzkey, i)
                          for i in range(winreg.QueryInfoKey(tzkey)[0])]
        return result

    def display(self):
        return self._display

    def transitions(self, year):
        """
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        """

        if not self.hasdst:
            return None

        dston = picknthweekday(year, self._dstmonth, self._dstdayofweek,
                               self._dsthour, self._dstminute,
                               self._dstweeknumber)

        dstoff = picknthweekday(year, self._stdmonth, self._stddayofweek,
                                self._stdhour, self._stdminute,
                                self._stdweeknumber)

        # Ambiguous dates default to the STD side
        dstoff -= self._dst_base_offset

        return dston, dstoff

    def _get_hasdst(self):
        return self._dstmonth != 0

    @property
    def _dst_base_offset(self):
        return self._dst_base_offset_


class tzwin(tzwinbase):

    def __init__(self, name):
        self._name = name

        # multiple contexts only possible in 2.7 and 3.1, we still support 2.6
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
            tzkeyname = text_type("{kn}\\{name}").format(kn=TZKEYNAME, name=name)
            with winreg.OpenKey(handle, tzkeyname) as tzkey:
                keydict = valuestodict(tzkey)

        self._std_abbr = keydict["Std"]
        self._dst_abbr = keydict["Dlt"]

        self._display = keydict["Display"]

        # See http://ww_winreg.jsiinc.com/SUBA/tip0300/rh0398.htm
        tup = struct.unpack("=3l16h", keydict["TZI"])
        stdoffset = -tup[0]-tup[1]          # Bias + StandardBias * -1
        dstoffset = stdoffset-tup[2]        # + DaylightBias * -1
        self._std_offset = datetime.timedelta(minutes=stdoffset)
        self._dst_offset = datetime.timedelta(minutes=dstoffset)

        # for the meaning see the win32 TIME_ZONE_INFORMATION structure docs
        # http://msdn.microsoft.com/en-us/library/windows/desktop/ms725481(v=vs.85).aspx
        (self._stdmonth,
         self._stddayofweek,   # Sunday = 0
         self._stdweeknumber,  # Last = 5
         self._stdhour,
         self._stdminute) = tup[4:9]

        (self._dstmonth,
         self._dstdayofweek,   # Sunday = 0
         self._dstweeknumber,  # Last = 5
         self._dsthour,
         self._dstminute) = tup[12:17]

        self._dst_base_offset_ = self._dst_offset - self._std_offset
        self.hasdst = self._get_hasdst()

    def __repr__(self):
        return "tzwin(%s)" % repr(self._name)

    def __reduce__(self):
        return (self.__class__, (self._name,))


class tzwinlocal(tzwinbase):
    def __init__(self):
        with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as handle:
            with winreg.OpenKey(handle, TZLOCALKEYNAME) as tzlocalkey:
                keydict = valuestodict(tzlocalkey)

            self._std_abbr = keydict["StandardName"]
            self._dst_abbr = keydict["DaylightName"]

            try:
                tzkeyname = text_type('{kn}\\{sn}').format(kn=TZKEYNAME,
                                                          sn=self._std_abbr)
                with winreg.OpenKey(handle, tzkeyname) as tzkey:
                    _keydict = valuestodict(tzkey)
                    self._display = _keydict["Display"]
            except OSError:
                self._display = None

        stdoffset = -keydict["Bias"]-keydict["StandardBias"]
        dstoffset = stdoffset-keydict["DaylightBias"]

        self._std_offset = datetime.timedelta(minutes=stdoffset)
        self._dst_offset = datetime.timedelta(minutes=dstoffset)

        # For reasons unclear, in this particular key, the day of week has been
        # moved to the END of the SYSTEMTIME structure.
        tup = struct.unpack("=8h", keydict["StandardStart"])

        (self._stdmonth,
         self._stdweeknumber,  # Last = 5
         self._stdhour,
         self._stdminute) = tup[1:5]

        self._stddayofweek = tup[7]

        tup = struct.unpack("=8h", keydict["DaylightStart"])

        (self._dstmonth,
         self._dstweeknumber,  # Last = 5
         self._dsthour,
         self._dstminute) = tup[1:5]

        self._dstdayofweek = tup[7]

        self._dst_base_offset_ = self._dst_offset - self._std_offset
        self.hasdst = self._get_hasdst()

    def __repr__(self):
        return "tzwinlocal()"

    def __str__(self):
        # str will return the standard name, not the daylight name.
        return "tzwinlocal(%s)" % repr(self._std_abbr)

    def __reduce__(self):
        return (self.__class__, ())


def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
    """ dayofweek == 0 means Sunday, whichweek 5 means last instance """
    first = datetime.datetime(year, month, 1, hour, minute)

    # This will work if dayofweek is ISO weekday (1-7) or Microsoft-style (0-6),
    # Because 7 % 7 = 0
    weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7) + 1)
    wd = weekdayone + ((whichweek - 1) * ONEWEEK)
    if (wd.month != month):
        wd -= ONEWEEK

    return wd


def valuestodict(key):
    """Convert a registry key's values to a dictionary."""
    dout = {}
    size = winreg.QueryInfoKey(key)[1]
    tz_res = None

    for i in range(size):
        key_name, value, dtype = winreg.EnumValue(key, i)
        if dtype == winreg.REG_DWORD or dtype == winreg.REG_DWORD_LITTLE_ENDIAN:
            # If it's a DWORD (32-bit integer), it's stored as unsigned - convert
            # that to a proper signed integer
            if value & (1 << 31):
                value = value - (1 << 32)
        elif dtype == winreg.REG_SZ:
            # If it's a reference to the tzres DLL, load the actual string
            if value.startswith('@tzres'):
                tz_res = tz_res or tzres()
                value = tz_res.name_from_string(value)

            value = value.rstrip('\x00')    # Remove trailing nulls

        dout[key_name] = value

    return dout
_common.py000064400000027326150373450210006557 0ustar00from six import PY3

from functools import wraps

from datetime import datetime, timedelta, tzinfo


ZERO = timedelta(0)

__all__ = ['tzname_in_python2', 'enfold']


def tzname_in_python2(namefunc):
    """Change unicode output into bytestrings in Python 2

    tzname() API changed in Python 3. It used to return bytes, but was changed
    to unicode strings
    """
    def adjust_encoding(*args, **kwargs):
        name = namefunc(*args, **kwargs)
        if name is not None and not PY3:
            name = name.encode()

        return name

    return adjust_encoding


# The following is adapted from Alexander Belopolsky's tz library
# https://github.com/abalkin/tz
if hasattr(datetime, 'fold'):
    # This is the pre-python 3.6 fold situation
    def enfold(dt, fold=1):
        """
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        """
        return dt.replace(fold=fold)

else:
    class _DatetimeWithFold(datetime):
        """
        This is a class designed to provide a PEP 495-compliant interface for
        Python versions before 3.6. It is used only for dates in a fold, so
        the ``fold`` attribute is fixed at ``1``.

        .. versionadded:: 2.6.0
        """
        __slots__ = ()

        @property
        def fold(self):
            return 1

    def enfold(dt, fold=1):
        """
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        """
        if getattr(dt, 'fold', 0) == fold:
            return dt

        args = dt.timetuple()[:6]
        args += (dt.microsecond, dt.tzinfo)

        if fold:
            return _DatetimeWithFold(*args)
        else:
            return datetime(*args)


def _validate_fromutc_inputs(f):
    """
    The CPython version of ``fromutc`` checks that the input is a ``datetime``
    object and that ``self`` is attached as its ``tzinfo``.
    """
    @wraps(f)
    def fromutc(self, dt):
        if not isinstance(dt, datetime):
            raise TypeError("fromutc() requires a datetime argument")
        if dt.tzinfo is not self:
            raise ValueError("dt.tzinfo is not self")

        return f(self, dt)

    return fromutc


class _tzinfo(tzinfo):
    """
    Base class for all ``dateutil`` ``tzinfo`` objects.
    """

    def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """

        dt = dt.replace(tzinfo=self)

        wall_0 = enfold(dt, fold=0)
        wall_1 = enfold(dt, fold=1)

        same_offset = wall_0.utcoffset() == wall_1.utcoffset()
        same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)

        return same_dt and not same_offset

    def _fold_status(self, dt_utc, dt_wall):
        """
        Determine the fold status of a "wall" datetime, given a representation
        of the same datetime as a (naive) UTC datetime. This is calculated based
        on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
        datetimes, and that this offset is the actual number of hours separating
        ``dt_utc`` and ``dt_wall``.

        :param dt_utc:
            Representation of the datetime as UTC

        :param dt_wall:
            Representation of the datetime as "wall time". This parameter must
            either have a `fold` attribute or have a fold-naive
            :class:`datetime.tzinfo` attached, otherwise the calculation may
            fail.
        """
        if self.is_ambiguous(dt_wall):
            delta_wall = dt_wall - dt_utc
            _fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst()))
        else:
            _fold = 0

        return _fold

    def _fold(self, dt):
        return getattr(dt, 'fold', 0)

    def _fromutc(self, dt):
        """
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurence, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        """

        # Re-implement the algorithm from Python's datetime.py
        dtoff = dt.utcoffset()
        if dtoff is None:
            raise ValueError("fromutc() requires a non-None utcoffset() "
                             "result")

        # The original datetime.py code assumes that `dst()` defaults to
        # zero during ambiguous times. PEP 495 inverts this presumption, so
        # for pre-PEP 495 versions of python, we need to tweak the algorithm.
        dtdst = dt.dst()
        if dtdst is None:
            raise ValueError("fromutc() requires a non-None dst() result")
        delta = dtoff - dtdst

        dt += delta
        # Set fold=1 so we can default to being in the fold for
        # ambiguous dates.
        dtdst = enfold(dt, fold=1).dst()
        if dtdst is None:
            raise ValueError("fromutc(): dt.dst gave inconsistent "
                             "results; cannot convert")
        return dt + dtdst

    @_validate_fromutc_inputs
    def fromutc(self, dt):
        """
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurance, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        """
        dt_wall = self._fromutc(dt)

        # Calculate the fold status given the two datetimes.
        _fold = self._fold_status(dt, dt_wall)

        # Set the default fold value for ambiguous dates
        return enfold(dt_wall, fold=_fold)


class tzrangebase(_tzinfo):
    """
    This is an abstract base class for time zones represented by an annual
    transition into and out of DST. Child classes should implement the following
    methods:

        * ``__init__(self, *args, **kwargs)``
        * ``transitions(self, year)`` - this is expected to return a tuple of
          datetimes representing the DST on and off transitions in standard
          time.

    A fully initialized ``tzrangebase`` subclass should also provide the
    following attributes:
        * ``hasdst``: Boolean whether or not the zone uses DST.
        * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
          representing the respective UTC offsets.
        * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
          abbreviations in DST and STD, respectively.
        * ``_hasdst``: Whether or not the zone has DST.

    .. versionadded:: 2.6.0
    """
    def __init__(self):
        raise NotImplementedError('tzrangebase is an abstract base class')

    def utcoffset(self, dt):
        isdst = self._isdst(dt)

        if isdst is None:
            return None
        elif isdst:
            return self._dst_offset
        else:
            return self._std_offset

    def dst(self, dt):
        isdst = self._isdst(dt)

        if isdst is None:
            return None
        elif isdst:
            return self._dst_base_offset
        else:
            return ZERO

    @tzname_in_python2
    def tzname(self, dt):
        if self._isdst(dt):
            return self._dst_abbr
        else:
            return self._std_abbr

    def fromutc(self, dt):
        """ Given a datetime in UTC, return local time """
        if not isinstance(dt, datetime):
            raise TypeError("fromutc() requires a datetime argument")

        if dt.tzinfo is not self:
            raise ValueError("dt.tzinfo is not self")

        # Get transitions - if there are none, fixed offset
        transitions = self.transitions(dt.year)
        if transitions is None:
            return dt + self.utcoffset(dt)

        # Get the transition times in UTC
        dston, dstoff = transitions

        dston -= self._std_offset
        dstoff -= self._std_offset

        utc_transitions = (dston, dstoff)
        dt_utc = dt.replace(tzinfo=None)

        isdst = self._naive_isdst(dt_utc, utc_transitions)

        if isdst:
            dt_wall = dt + self._dst_offset
        else:
            dt_wall = dt + self._std_offset

        _fold = int(not isdst and self.is_ambiguous(dt_wall))

        return enfold(dt_wall, fold=_fold)

    def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """
        if not self.hasdst:
            return False

        start, end = self.transitions(dt.year)

        dt = dt.replace(tzinfo=None)
        return (end <= dt < end + self._dst_base_offset)

    def _isdst(self, dt):
        if not self.hasdst:
            return False
        elif dt is None:
            return None

        transitions = self.transitions(dt.year)

        if transitions is None:
            return False

        dt = dt.replace(tzinfo=None)

        isdst = self._naive_isdst(dt, transitions)

        # Handle ambiguous dates
        if not isdst and self.is_ambiguous(dt):
            return not self._fold(dt)
        else:
            return isdst

    def _naive_isdst(self, dt, transitions):
        dston, dstoff = transitions

        dt = dt.replace(tzinfo=None)

        if dston < dstoff:
            isdst = dston <= dt < dstoff
        else:
            isdst = not dstoff <= dt < dston

        return isdst

    @property
    def _dst_base_offset(self):
        return self._dst_offset - self._std_offset

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __repr__(self):
        return "%s(...)" % self.__class__.__name__

    __reduce__ = object.__reduce__


def _total_seconds(td):
    # Python 2.6 doesn't have a total_seconds() method on timedelta objects
    return ((td.seconds + td.days * 86400) * 1000000 +
            td.microseconds) // 1000000


_total_seconds = getattr(timedelta, 'total_seconds', _total_seconds)
__pycache__/_common.cpython-36.opt-1.pyc000064400000026262150373450210014000 0ustar003

6�cY�.�@s�ddlmZddlmZddlmZmZmZed�ZddgZdd�Z	e
ed�rZdd	d�ZnGd
d�de�Zddd�Zd
d�Z
Gdd�de�ZGdd�de�Zdd�Zeede�ZdS)�)�PY3)�wraps)�datetime�	timedelta�tzinfo�tzname_in_python2�enfoldcs�fdd�}|S)z�Change unicode output into bytestrings in Python 2

    tzname() API changed in Python 3. It used to return bytes, but was changed
    to unicode strings
    cs$�||�}|dk	r tr |j�}|S)N)r�encode)�args�kwargs�name)�namefunc��/usr/lib/python3.6/_common.py�adjust_encodings
z*tzname_in_python2.<locals>.adjust_encodingr)r
rr)r
rr
s�fold�cCs|j|d�S)a�
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        )r)�replace)�dtrrrrr!sc@s eZdZdZfZedd��ZdS)�_DatetimeWithFoldz�
        This is a class designed to provide a PEP 495-compliant interface for
        Python versions before 3.6. It is used only for dates in a fold, so
        the ``fold`` attribute is fixed at ``1``.

        .. versionadded:: 2.6.0
        cCsdS)Nrr)�selfrrrr@sz_DatetimeWithFold.foldN)�__name__�
__module__�__qualname__�__doc__�	__slots__�propertyrrrrrr6srcCsLt|dd�|kr|S|j�dd�}||j|jf7}|r@t|�St|�SdS)a�
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        rrN�)�getattrZ	timetupleZmicrosecondrrr)rrr
rrrrDscst���fdd��}|S)z�
    The CPython version of ``fromutc`` checks that the input is a ``datetime``
    object and that ``self`` is attached as its ``tzinfo``.
    cs.t|t�std��|j|k	r$td���||�S)Nz&fromutc() requires a datetime argumentzdt.tzinfo is not self)�
isinstancer�	TypeErrorr�
ValueError)rr)�frr�fromutcgs


z)_validate_fromutc_inputs.<locals>.fromutc)r)r"r#r)r"r�_validate_fromutc_inputsbs	r$c@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dS)
�_tzinfoz=
    Base class for all ``dateutil`` ``tzinfo`` objects.
    cCsV|j|d�}t|dd�}t|dd�}|j�|j�k}|jdd�|jdd�k}|oT|S)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        )rr)rrN)rr�	utcoffset)rrZwall_0Zwall_1Zsame_offsetZsame_dtrrr�is_ambiguousxsz_tzinfo.is_ambiguouscCs4|j|�r,||}t||j�|j�k�}nd}|S)a�
        Determine the fold status of a "wall" datetime, given a representation
        of the same datetime as a (naive) UTC datetime. This is calculated based
        on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
        datetimes, and that this offset is the actual number of hours separating
        ``dt_utc`` and ``dt_wall``.

        :param dt_utc:
            Representation of the datetime as UTC

        :param dt_wall:
            Representation of the datetime as "wall time". This parameter must
            either have a `fold` attribute or have a fold-naive
            :class:`datetime.tzinfo` attached, otherwise the calculation may
            fail.
        r)r'�intr&�dst)r�dt_utc�dt_wallZ
delta_wall�_foldrrr�_fold_status�s

z_tzinfo._fold_statuscCst|dd�S)Nrr)r)rrrrrr,�sz
_tzinfo._foldcCsh|j�}|dkrtd��|j�}|dkr0td��||}||7}t|dd�j�}|dkr`td��||S)a�
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurence, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        Nz0fromutc() requires a non-None utcoffset() resultz*fromutc() requires a non-None dst() resultr)rz;fromutc(): dt.dst gave inconsistent results; cannot convert)r&r!r)r)rrZdtoffZdtdstZdeltarrr�_fromutc�sz_tzinfo._fromutccCs"|j|�}|j||�}t||d�S)a�
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurance, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        )r)r.r-r)rrr+r,rrrr#�s
z_tzinfo.fromutcN)
rrrrr'r-r,r.r$r#rrrrr%ss%r%c@szeZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Ze
dd��ZdZdd�Zdd�ZejZdS)�tzrangebasea�
    This is an abstract base class for time zones represented by an annual
    transition into and out of DST. Child classes should implement the following
    methods:

        * ``__init__(self, *args, **kwargs)``
        * ``transitions(self, year)`` - this is expected to return a tuple of
          datetimes representing the DST on and off transitions in standard
          time.

    A fully initialized ``tzrangebase`` subclass should also provide the
    following attributes:
        * ``hasdst``: Boolean whether or not the zone uses DST.
        * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
          representing the respective UTC offsets.
        * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
          abbreviations in DST and STD, respectively.
        * ``_hasdst``: Whether or not the zone has DST.

    .. versionadded:: 2.6.0
    cCstd��dS)Nz%tzrangebase is an abstract base class)�NotImplementedError)rrrr�__init__�sztzrangebase.__init__cCs*|j|�}|dkrdS|r |jS|jSdS)N)�_isdst�_dst_offset�_std_offset)rr�isdstrrrr&s
ztzrangebase.utcoffsetcCs(|j|�}|dkrdS|r |jStSdS)N)r2�_dst_base_offset�ZERO)rrr5rrrr)s
ztzrangebase.dstcCs|j|�r|jS|jSdS)N)r2Z	_dst_abbrZ	_std_abbr)rrrrr�tznames
ztzrangebase.tznamec
Cs�t|t�std��|j|k	r$td��|j|j�}|dkrF||j|�S|\}}||j8}||j8}||f}|j	dd�}|j
||�}|r�||j}n
||j}t|o�|j
|��}	t||	d�S)z, Given a datetime in UTC, return local time z&fromutc() requires a datetime argumentzdt.tzinfo is not selfN)r)r)rrr rr!�transitions�yearr&r4r�_naive_isdstr3r(r'r)
rrr9�dston�dstoffZutc_transitionsr*r5r+r,rrrr#s$




ztzrangebase.fromutccCsD|js
dS|j|j�\}}|jdd�}||ko>||jkSS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        FN)r)�hasdstr9r:rr6)rr�start�endrrrr'>s
ztzrangebase.is_ambiguouscCsj|js
dS|dkrdS|j|j�}|dkr.dS|jdd�}|j||�}|rb|j|�rb|j|�S|SdS)NF)r)r>r9r:rr;r'r,)rrr9r5rrrr2Tsztzrangebase._isdstcCsT|\}}|jdd�}||kr6||ko.|kn}n||koH|kn}|S)N)r)r)rrr9r<r=r5rrrr;isztzrangebase._naive_isdstcCs|j|jS)N)r3r4)rrrrr6usztzrangebase._dst_base_offsetNcCs
||kS)Nr)r�otherrrr�__ne__{sztzrangebase.__ne__cCsd|jjS)Nz%s(...))�	__class__r)rrrr�__repr__~sztzrangebase.__repr__)rrrrr1r&r)rr8r#r'r2r;rr6�__hash__rBrD�object�
__reduce__rrrrr/�s

!r/cCs|j|jdd|jdS)Ni�Qi@B)ZsecondsZdaysZmicroseconds)Ztdrrr�_total_seconds�srHZ
total_secondsN)r)r)Zsixr�	functoolsrrrrr7�__all__r�hasattrrrr$r%r/rHrrrrr�<module>s

v__pycache__/tz.cpython-36.opt-1.pyc000064400000105541150373450210013004 0ustar003

6�cY���@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl	m
Z
mZddl	mZyddlmZmZWnek
r�dZZYnXejd�Zejjd�Zej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de
�Z"Gdd�de"�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&ej'dk�r�d d!gZ(d"d#d$d%gZ)ngZ(gZ)d0d&d'�Z*d1d(d)�Z+d2d*d+�Z,d,d-�Z-Gd.d/�d/e�Z.dS)3a{
This module offers timezone implementations subclassing the abstract
:py:`datetime.tzinfo` type. There are classes to handle tzfile format files
(usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ
environment string (in all known formats), given ranges (with help from
relative deltas), local machine timezone, fixed offset timezone, and UTC
timezone.
�N)�string_types�)�tzname_in_python2�_tzinfo�_total_seconds)�tzrangebase�enfold)�_validate_fromutc_inputs)�tzwin�
tzwinlocalc@sbeZdZdZdd�Zdd�Zedd��Zdd	�Ze	d
d��Z
dd
�ZdZdd�Z
dd�ZejZdS)�tzutczD
    This is a tzinfo object that represents the UTC time zone.
    cCstS)N)�ZERO)�self�dt�r�/usr/lib/python3.6/tz.py�	utcoffset$sztzutc.utcoffsetcCstS)N)r
)rrrrr�dst'sz	tzutc.dstcCsdS)N�UTCr)rrrrr�tzname*sztzutc.tznamecCsdS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        Fr)rrrrr�is_ambiguous.sztzutc.is_ambiguouscCs|S)z�
        Fast track version of fromutc() returns the original ``dt`` object for
        any valid :py:class:`datetime.datetime` object.
        r)rrrrr�fromutc>sz
tzutc.fromutccCs0t|ttf�stSt|t�p.t|t�o.|jtkS)N)�
isinstancer�tzoffset�NotImplemented�_offsetr
)r�otherrrr�__eq__Fs
ztzutc.__eq__NcCs
||kS)Nr)rrrrr�__ne__Osztzutc.__ne__cCsd|jjS)Nz%s())�	__class__�__name__)rrrr�__repr__Rsztzutc.__repr__)r �
__module__�__qualname__�__doc__rrrrrr	rr�__hash__rr!�object�
__reduce__rrrrr src@sjeZdZdZdd�Zdd�Zdd�Zedd	��Ze	d
d��Z
dd
�Zdd�ZdZ
dd�Zdd�ZejZdS)ra1
    A simple class for representing a fixed offset from UTC.

    :param name:
        The timezone name, to be returned when ``tzname()`` is called.

    :param offset:
        The time zone offset in seconds, or (since version 2.6.0, represented
        as a :py:class:`datetime.timedelta` object.
    cCs>||_yt|�}Wnttfk
r*YnXtj|d�|_dS)N)�seconds)�_namer�	TypeError�AttributeError�datetime�	timedeltar)r�name�offsetrrr�__init__csztzoffset.__init__cCs|jS)N)r)rrrrrrmsztzoffset.utcoffsetcCstS)N)r
)rrrrrrpsztzoffset.dstcCs|jS)N)r))rrrrrrssztzoffset.tznamecCs
||jS)N)r)rrrrrrwsztzoffset.fromutccCsdS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        Fr)rrrrrr{sztzoffset.is_ambiguouscCst|t�stS|j|jkS)N)rrrr)rrrrrr�s
ztzoffset.__eq__NcCs
||kS)Nr)rrrrrr�sztzoffset.__ne__cCs"d|jjt|j�tt|j��fS)Nz
%s(%s, %s))rr �reprr)�intrr)rrrrr!�sztzoffset.__repr__)r r"r#r$r0rrrrr	rrrr%rr!r&r'rrrrrXs

rcsxeZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
ddd�Zdd�ZdZ
dd�Zdd�ZejZ�ZS)�tzlocalzR
    A :class:`tzinfo` subclass built around the ``time`` timezone functions.
    cs`tt|�j�tjtjd�|_tjr:tjtj	d�|_
n|j|_
|j
|j|_t|j�|_
dS)N)r()�superr3r0r,r-�time�timezone�_std_offsetZdaylightZaltzone�_dst_offset�
_dst_saved�bool�_hasdst)r)rrrr0�sztzlocal.__init__cCs,|dkr|jrdS|j|�r"|jS|jSdS)N)r;�_isdstr8r7)rrrrrr�s

ztzlocal.utcoffsetcCs0|dkr|jrdS|j|�r(|j|jStSdS)N)r;r<r8r7r
)rrrrrr�s

ztzlocal.dstcCstj|j|�S)N)r5rr<)rrrrrr�sztzlocal.tznamecCs$|j|�}|o"||j||j�kS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        )�
_naive_is_dstr9)rrZ	naive_dstrrrr�s
ztzlocal.is_ambiguouscCst|�}tj|tj�jS)N)�_datetime_to_timestampr5�	localtimer6Ztm_isdst)rr�	timestamprrrr=�sztzlocal._naive_is_dstTcCsF|js
dS|j|�}t|dd�}|j|�rB|dk	r>|j|�SdS|S)NF�foldT)r;r=�getattrr�_fold)rrZ
fold_naiveZdstvalrArrrr<�s

ztzlocal._isdstcCs&t|t�stS|j|jko$|j|jkS)N)rr3rr7r8)rrrrrrs
ztzlocal.__eq__NcCs
||kS)Nr)rrrrrrsztzlocal.__ne__cCsd|jjS)Nz%s())rr )rrrrr!sztzlocal.__repr__)T)r r"r#r$r0rrrrrr=r<rr%rr!r&r'�
__classcell__rr)rrr3�s		
(r3c@sReZdZdddddddgZdd	�Zd
d�Zdd
�ZdZdd�Zdd�Z	dd�Z
dS)�_ttinfor/�delta�isdst�abbr�isstd�isgmt�	dstoffsetcCs x|jD]}t||d�qWdS)N)�	__slots__�setattr)r�attrrrrr0sz_ttinfo.__init__cCsRg}x6|jD],}t||�}|dk	r|jd|t|�f�qWd|jjdj|�fS)Nz%s=%sz%s(%s)z, )rLrB�appendr1rr �join)r�lrN�valuerrrr!s
z_ttinfo.__repr__cCsbt|t�stS|j|jko`|j|jko`|j|jko`|j|jko`|j|jko`|j|jko`|j	|j	kS)N)
rrErr/rFrGrHrIrJrK)rrrrrr$s
z_ttinfo.__eq__NcCs
||kS)Nr)rrrrrr2sz_ttinfo.__ne__cCs(i}x|jD]}t||d�||<qW|S)N)rLrB)r�stater.rrr�__getstate__5sz_ttinfo.__getstate__cCs,x&|jD]}||krt||||�qWdS)N)rLrM)rrSr.rrr�__setstate__;sz_ttinfo.__setstate__)r r"r#rLr0r!rr%rrTrUrrrrrEs
rEc@s,eZdZdZdddddddd	gZd
d�ZdS)
�_tzfilezw
    Lightweight class for holding the relevant transition and time zone
    information read from binary tzfiles.
    �
trans_list�trans_list_utc�	trans_idx�ttinfo_list�
ttinfo_std�
ttinfo_dst�
ttinfo_before�ttinfo_firstcKs(x"|jD]}t|||j|d��qWdS)N)�attrsrM�get)r�kwargsrNrrrr0Isz_tzfile.__init__N)r r"r#r$r_r0rrrrrVAsrVcs�eZdZdZd&�fdd�	Zdd�Zdd�Zd'd
d�Zdd
�Zdd�Z	dd�Z
d(dd�Zdd�Zdd�Z
dd�Zedd��Zdd�ZdZdd�Zd d!�Zd"d#�Zd$d%�Z�ZS))�tzfilea�
    This is a ``tzinfo`` subclass thant allows one to use the ``tzfile(5)``
    format timezone files to extract current and historical zone information.

    :param fileobj:
        This can be an opened file stream or a file name that the time zone
        information can be read from.

    :param filename:
        This is an optional parameter specifying the source of the time zone
        information in the event that ``fileobj`` is a file object. If omitted
        and ``fileobj`` is a file stream, this parameter will be set either to
        ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``.

    See `Sources for Time Zone and Daylight Saving Time Data
    <http://www.twinsun.com/tz/tz-link.htm>`_ for more information. Time zone
    files can be compiled from the `IANA Time Zone database files
    <https://www.iana.org/time-zones>`_ with the `zic time zone compiler
    <https://www.freebsd.org/cgi/man.cgi?query=zic&sektion=8>`_
    Nc	s�tt|�j�d}t|t�r2||_t|d�}d}n.|dk	rB||_nt|d�rV|j|_n
t	|�|_|dk	r�|stt
|�}|�}|j|�}WdQRX|j|�dS)NF�rbTr.)
r4rbr0rr�	_filename�open�hasattrr.r1�_ContextWrapper�_read_tzfile�_set_tzdata)r�fileobj�filenameZfile_opened_hereZfile_stream�tzobj)rrrr0ds"




ztzfile.__init__cCs*x$tjD]}t|d|t||��qWdS)z= Set the time zone data of this object from a _tzfile object �_N)rVr_rMrB)rrlrNrrrri|sztzfile._set_tzdatacs�t��|jd�j�dkr td��|jd�tjd|jd��\}}}}}}|rnttjd||j|d����_ng�_|r�tjd||j|���_ng�_g}x(t	|�D]}	|j
tjd	|jd
���q�W|j|�j�}
|r�|j|dtj
�|�rtjd||j|��}|�r"tjd||j|��}g�_x�t	|�D]�}	||	\}
}}d
|
dd
}
t�}|
|_tjd�|_tj|
d�|_||_|
||
jd|��|_||	k�o�||	dk|_||	k�o�||	dk|_�jj
|��q2W�fdd��jD��_d�_d�_d�_�j�r؈j�s$�jd�_�_n�x�t	|ddd�D]V}	�j|	}�j�r`|j�r`|�_n�j�rx|j�rx|�_�j�r6�j�r6P�q6W�j�r��j�r��j�_x,�jD]}|j�s�|�_P�q�W�jd�_d}g�_xlt�j�D]^\}	}|j�s
|j}|}n*|dk	�r*|j||_|�j|	<|�p2d}�jj
�j|	|��q�Wd}x~t t	t!�j���D]h}	�j|	}|j�r�|j�p�|dk�s�|j||_n|j}t"|jtj��s�tj|jd�|_|�j|	<�qhWt#�j��_t#�j��_t#�j��_�S)N�ZTZifzmagic not found�z>6l�z>%dlz>%dBz>lbb��z>%db�<�r)r(�csg|]}�j|�qSr)rZ)�.0�idx)�outrr�
<listcomp>sz'tzfile._read_tzfile.<locals>.<listcomp>r���rz)$rV�read�decode�
ValueError�struct�unpack�listrXrY�rangerO�seek�os�SEEK_CURrZrEr/r,r-rKrFrG�findrHrIrJr[r\r]r^rW�	enumerate�reversed�lenr�tuple)rrjZ
ttisgmtcntZ
ttisstdcntZleapcntZtimecntZtypecntZcharcntZttinfo�irHrIrJZgmtoffrGZabbrind�ttiZ
laststdoffsetr/r)rxrrh�s�
		






	



ztzfile._read_tzfileFcCs6|js
dSt|�}|r|jn|j}tj||�}|dS)Nr)�_trans_listr>Z_trans_list_utc�bisectZbisect_right)rr�in_utcr@rWrwrrr�_find_last_transition^sztzfile._find_last_transitioncCs8|dks|dt|j�kr |jS|dkr.|jS|j|S)Nrr)r�r��_ttinfo_stdZ_ttinfo_before�
_trans_idx)rrwrrr�_get_ttinfoms
ztzfile._get_ttinfocCs|j|�}|j|�S)N)�_resolve_ambiguous_timer�)rrrwrrr�_find_ttinfoxs
ztzfile._find_ttinfocCsnt|tj�std��|j|k	r&td��|j|dd�}|j|�}|tj|jd�}|j	||d�}t
|t|�d�S)a
        The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`.

        :param dt:
            A :py:class:`datetime.datetime` object.

        :raises TypeError:
            Raised if ``dt`` is not a :py:class:`datetime.datetime` object.

        :raises ValueError:
            Raised if this is called with a ``dt`` which does not have this
            ``tzinfo`` attached.

        :return:
            Returns a :py:class:`datetime.datetime` object representing the
            wall time in ``self``'s time zone.
        z&fromutc() requires a datetime argumentzdt.tzinfo is not selfT)r�)r()rw)rA)rr,r*�tzinfor}r�r�r-r/rrr2)rrrwr�Zdt_outrArrrr}s

ztzfile.fromutccCsd|dkr|j|�}t|�}|j|�}|dks4|dkr8dS|j|d�j|j}|j|}|||kS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        NrFr)r�r>r�r/r�)rrrwr@r�ZodZttrrrr�s


ztzfile.is_ambiguouscCsF|j|�}|j|�}|dks$|dkr(|St|o:|j||��}||S)Nr)r�rCr2r)rrrwrCZ
idx_offsetrrrr��s

ztzfile._resolve_ambiguous_timecCs"|dkrdS|jstS|j|�jS)N)r�r
r�rF)rrrrrr�s
ztzfile.utcoffsetcCs0|dkrdS|jstS|j|�}|js*tS|jS)N)Z_ttinfo_dstr
r�rGrK)rrr�rrrr�s
z
tzfile.dstcCs |js|dkrdS|j|�jS)N)r�r�rH)rrrrrr�sz
tzfile.tznamecCs2t|t�stS|j|jko0|j|jko0|j|jkS)N)rrbrr�r�Z_ttinfo_list)rrrrrr�s

z
tzfile.__eq__cCs
||kS)Nr)rrrrrr�sz
tzfile.__ne__cCsd|jjt|j�fS)Nz%s(%s))rr r1rd)rrrrr!�sztzfile.__repr__cCs
|jd�S)N)�
__reduce_ex__)rrrrr'�sztzfile.__reduce__cCs|jd|jf|jfS)N)rrd�__dict__)rZprotocolrrrr��sztzfile.__reduce_ex__)N)F)N)r r"r#r$r0rirhr�r�r�rrr�rrrrrr%rr!r'r�rDrr)rrrbNs(]
$

	rbc@s6eZdZdZddd�Zdd�Zdd�Zed	d
��ZdS)�tzrangeaQ
    The ``tzrange`` object is a time zone specified by a set of offsets and
    abbreviations, equivalent to the way the ``TZ`` variable can be specified
    in POSIX-like systems, but using Python delta objects to specify DST
    start, end and offsets.

    :param stdabbr:
        The abbreviation for standard time (e.g. ``'EST'``).

    :param stdoffset:
        An integer or :class:`datetime.timedelta` object or equivalent
        specifying the base offset from UTC.

        If unspecified, +00:00 is used.

    :param dstabbr:
        The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).

        If specified, with no other DST information, DST is assumed to occur
        and the default behavior or ``dstoffset``, ``start`` and ``end`` is
        used. If unspecified and no other DST information is specified, it
        is assumed that this zone has no DST.

        If this is unspecified and other DST information is *is* specified,
        DST occurs in the zone but the time zone abbreviation is left
        unchanged.

    :param dstoffset:
        A an integer or :class:`datetime.timedelta` object or equivalent
        specifying the UTC offset during DST. If unspecified and any other DST
        information is specified, it is assumed to be the STD offset +1 hour.

    :param start:
        A :class:`relativedelta.relativedelta` object or equivalent specifying
        the time and time of year that daylight savings time starts. To specify,
        for example, that DST starts at 2AM on the 2nd Sunday in March, pass:

            ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``

        If unspecified and any other DST information is specified, the default
        value is 2 AM on the first Sunday in April.

    :param end:
        A :class:`relativedelta.relativedelta` object or equivalent representing
        the time and time of year that daylight savings time ends, with the
        same specification method as in ``start``. One note is that this should
        point to the first time in the *standard* zone, so if a transition
        occurs at 2AM in the DST zone and the clocks are set back 1 hour to 1AM,
        set the `hours` parameter to +1.


    **Examples:**

    .. testsetup:: tzrange

        from dateutil.tz import tzrange, tzstr

    .. doctest:: tzrange

        >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
        True

        >>> from dateutil.relativedelta import *
        >>> range1 = tzrange("EST", -18000, "EDT")
        >>> range2 = tzrange("EST", -18000, "EDT", -14400,
        ...                  relativedelta(hours=+2, month=4, day=1,
        ...                                weekday=SU(+1)),
        ...                  relativedelta(hours=+1, month=10, day=31,
        ...                                weekday=SU(-1)))
        >>> tzstr('EST5EDT') == range1 == range2
        True

    NcCs@ddlma||_||_yt|�}Wnttfk
r<YnXyt|�}Wnttfk
rbYnX|dk	r|tj|d�|_	nt
|_	|dk	r�tj|d�|_n(|r�|dk	r�|j	tjdd�|_nt
|_|r�|dkr�tjdddtjd
�d�|_
n||_
|�r|dk�rtjdd	d
tjd�d�|_n||_|j|j	|_t|j
�|_dS)Nr)�
relativedelta)r(r)�hours�rn)r��month�day�weekday�
�rr�rrrz)�dateutilr��	_std_abbr�	_dst_abbrrr*r+r,r-r7r
r8�SU�_start_delta�
_end_delta�_dst_base_offset_r:�hasdst)r�stdabbr�	stdoffset�dstabbrrK�start�endrrrr0Js:ztzrange.__init__cCs4|js
dStj|dd�}||j}||j}||fS)a�
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        Nr)r�r,r�r�)rZyearZ	base_yearr�r�rrr�transitionsys

ztzrange.transitionscCsVt|t�stS|j|jkoT|j|jkoT|j|jkoT|j|jkoT|j|jkoT|j|jkS)N)	rr�rr�r�r7r8r�r�)rrrrrr�s
ztzrange.__eq__cCs|jS)N)r�)rrrr�_dst_base_offset�sztzrange._dst_base_offset)NNNNN)	r r"r#r$r0r�r�propertyr�rrrrr�sI
-r�c@s,eZdZdZddd�Zddd�Zdd	�Zd
S)
�tzstra
    ``tzstr`` objects are time zone objects specified by a time-zone string as
    it would be passed to a ``TZ`` variable on POSIX-style systems (see
    the `GNU C Library: TZ Variable`_ for more details).

    There is one notable exception, which is that POSIX-style time zones use an
    inverted offset format, so normally ``GMT+3`` would be parsed as an offset
    3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
    offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
    behavior, pass a ``True`` value to ``posix_offset``.

    The :class:`tzrange` object provides the same functionality, but is
    specified using :class:`relativedelta.relativedelta` objects. rather than
    strings.

    :param s:
        A time zone string in ``TZ`` variable format. This can be a
        :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: :class:`unicode`)
        or a stream emitting unicode characters (e.g. :class:`StringIO`).

    :param posix_offset:
        Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
        ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
        POSIX standard.

    .. _`GNU C Library: TZ Variable`:
        https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
    Fc	Cs�ddlma||_tj|�}|dkr,td��|jd
krJ|rJ|jd9_tj||j|j|j	|j
ddd�|j	s~d|_d|_n&|j
|j�|_|jr�|j
|jdd	�|_t|j�|_dS)Nr)�parserzunknown string format�GMTrrF)r�r�)�isend)r�rrz)r�r��_sZ_parsetzr}r�r�r�r0r�rKr�r��_deltar�r�r:r�)r�sZposix_offset�resrrrr0�s"

ztzstr.__init__rcCs<ddlm}i}|jdk	rr|j|d<|jdk	r`|j|j|j�|d<|jdkrVd|d<qpd|d<q�|jr�|j|d<n*|jdk	r�|j|d<n|jdk	r�|j|d	<|s�|s�d
|d<d|d<|jd�|d<nd|d<d|d<|jd�|d<|j	dk	�r�|j	|d<nd
|d<|�r0|j
|j}|d|j|j
d8<|jf|�S)Nr)r�r�r�rr�r�ZyeardayZ	nlyeardayrnr�r(i i�Qrrz)r�r�r�r�Zweekr�ZydayZjydayr�r5r8r7r(Zdays)r�xr�r�rarFrrrr��s<








ztzstr._deltacCsd|jjt|j�fS)Nz%s(%s))rr r1r�)rrrrr!sztzstr.__repr__N)F)r)r r"r#r$r0r�r!rrrrr��s
 
)r�c@seZdZddd�ZdS)�_tzicalvtzcompNcCs@tj|d�|_tj|d�|_|j|j|_||_||_||_dS)N)r()r,r-�tzoffsetfrom�
tzoffsetto�tzoffsetdiffrGr�rrule)rr�r�rGrr�rrrr0sz_tzicalvtzcomp.__init__)NN)r r"r#r0rrrrr�sr�csZeZdZgf�fdd�	Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	d
d�Z
ejZ�Z
S)�
_tzicalvtzcs*tt|�j�||_||_g|_g|_dS)N)r4r�r0�_tzid�_comps�
_cachedate�
_cachecomp)r�tzid�comps)rrrr0s
z_tzicalvtz.__init__c
Cs
t|j�dkr|jdS|jdd�}y|j|jj||j|�f�Stk
rTYnXd}d}x4|jD]*}|j||�}|rf|s�||krf|}|}qfW|s�x"|jD]}|j	s�|}Pq�W|d}|jj
d||j|�f�|jj
d|�t|j�dk�r|jj�|jj�|S)Nrr)r�r�)r�r��replacer�r��indexrCr}�_find_compdtrG�insert�pop)rrZ
lastcompdtZlastcomp�comp�compdtrrr�
_find_comps4


z_tzicalvtz._find_compcCs2|jtkr|j|�r||j8}|jj|dd�}|S)NT)Zinc)r�r
rCr�Zbefore)rr�rr�rrrr�Is
z_tzicalvtz._find_compdtcCs|dkrdS|j|�jS)N)r�r�)rrrrrrQsz_tzicalvtz.utcoffsetcCs|j|�}|jr|jStSdS)N)r�rGr�r
)rrr�rrrrWs
z_tzicalvtz.dstcCs|j|�jS)N)r�r)rrrrrr^sz_tzicalvtz.tznamecCsdt|j�S)Nz<tzicalvtz %s>)r1r�)rrrrr!bsz_tzicalvtz.__repr__)r r"r#r0r�r�rrrrr!r&r'rDrr)rrr�s*r�c@sBeZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dS)�tzicala\
    This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure
    as set out in `RFC 2445`_ Section 4.6.5 into one or more `tzinfo` objects.

    :param `fileobj`:
        A file or stream in iCalendar format, which should be UTF-8 encoded
        with CRLF endings.

    .. _`RFC 2445`: https://www.ietf.org/rfc/rfc2445.txt
    c	Csjddlmat|t�r(||_t|d�}nt|dt|��|_t|�}i|_	|�}|j
|j��WdQRXdS)Nr)r��rr.)r�r�rrr�rerBr1rg�_vtz�
_parse_rfcr{)rrjZfobjrrrr0ss
ztzical.__init__cCst|jj��S)z?
        Retrieves the available time zones as a list.
        )r�r��keys)rrrrr��sztzical.keysNcCsP|dkrDt|j�dkr td��nt|j�dkr6td��tt|j��}|jj|�S)a�
        Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.

        :param tzid:
            If there is exactly one time zone available, omitting ``tzid``
            or passing :py:const:`None` value returns it. Otherwise a valid
            key (which can be retrieved from :func:`keys`) is required.

        :raises ValueError:
            Raised if ``tzid`` is not specified but there are either more
            or fewer than 1 zone defined.

        :returns:
            Returns either a :py:class:`datetime.tzinfo` object representing
            the relevant time zone or :py:const:`None` if the ``tzid`` was
            not found.
        Nrzno timezones definedrz more than one timezone available)r�r�r}�next�iterr`)rr�rrrr`�s
z
tzical.getcCs�|j�}|std��|ddkr>d|ddk}|dd�}nd}t|�dkrzt|dd��dt|dd��d	|St|�d
kr�t|dd��dt|dd��d	t|dd��|Std|��dS)Nzempty offsetr�+�-rrnr�irsrqzinvalid offset: )r�r�rzr)rzrr)�stripr}r�r2)rr��signalrrr�
_parse_offset�s,<ztzical._parse_offsetcCsH|j�}|std��d}xh|t|�kr�||j�}|s>||=q|dkrv|ddkrv||d|dd�7<||=q|d7}qWd}g}d}d}�x�|D�]�}|s�q�|jdd�\}	}
|	jd�}|s�td��|dj�}	|dd�}|�r$|	d	k�r(|
d)k�rntd|
��|
}d}d}
d}g}d}�q@|	d
k�r|
dk�r�|�rNtd|��|�s\td��|�sjtd��t||�|j|<d}n�|
|k�r|�s�td��|
dk�r�td��|dk�r�td��d}|�r�tj	dj
|�dddd�}t|
||dk||�}|j|�d}ntd|
���q@|�r�|	dk�r2|j|�d}n�|	d*k�rH|j|�n�|	dk�rx|�rltd|	|df��|j
|
�}
nj|	dk�r�|�r�td |d��|j
|
�}n>|	d!k�r�|�r�td"|d��|
}n|	d#k�r�ntd$|	��n>|	d%k�r
|�rtd&|d��|
}n|	d+k�rntd$|	��q�|	d	kr�|
dkr�d}g}d}q�WdS),Nzempty stringr� rF�:�;zempty property nameZBEGIN�STANDARD�DAYLIGHTzunknown component: ZENDZ	VTIMEZONEzcomponent not closed: zmandatory TZID not foundz at least one component is neededzmandatory DTSTART not foundz mandatory TZOFFSETFROM not found�
T)Z
compatibleZignoretz�cachezinvalid component end: ZDTSTART�RRULE�RDATE�EXRULE�EXDATEZTZOFFSETFROMzunsupported %s parm: %s Z
TZOFFSETTOzunsupported TZOFFSETTO parm: ZTZNAMEzunsupported TZNAME parm: �COMMENTzunsupported property: ZTZIDzunsupported TZID parm: �TZURL�
LAST-MODIFIED)r�r�)r�r�r�r�)r�r�r�)�
splitlinesr}r��rstrip�split�upperr�r�r�ZrrulestrrPr�rOr�)rr��linesr��liner�r�ZinvtzZcomptyper.rRZparmsZfounddtstartr�r�Z
rrulelinesrZrrr�rrrr��s�

















ztzical._parse_rfccCsd|jjt|j�fS)Nz%s(%s))rr r1r�)rrrrr!+sztzical.__repr__)N)
r r"r#r$r0r�r`r�r�r!rrrrr�hs

vr�Zwin32z/etc/localtimer?z/usr/share/zoneinfoz/usr/lib/zoneinfoz/usr/share/lib/zoneinfoz
/etc/zoneinfocCsDd}|s,ytjd}Wntk
r*YnX|dks<|dkr�x�tD]v}tjj|�s�|}x*tD] }tjj||�}tjj|�r\Pq\WqBtjj|�rByt	|�}PWqBt
ttfk
r�YqBXqBWt
�}�nz|jd�r�|dd�}tjj|��r
tjj|��rt	|�}nd}�n6�x2tD]l}tjj||�}tjj|��sP|jdd�}tjj|��sP�qyt	|�}PWnt
ttfk
�rzYnX�qWd}tdk	�r�yt|�}Wntk
�r�d}YnX|�s�ddlm}|�j|�}|�s@xb|D]6}|dk�r�yt|�}Wntk
�rYnXP�q�W|dk�r.t�}n|tjk�r@t
�}|S)
NZTZr�rr�rmr)�get_zonefile_instance�
0123456789r�rrz)r�r)r��environ�KeyError�TZFILES�path�isabs�TZPATHSrP�isfilerb�IOError�OSErrorr}r3�
startswithr�r
ZWindowsErrorZdateutil.zoneinfor�r`r�rr5r)r.�tz�filepathrkr�r��crrr�gettz:sz










r�cCsZ|dkr |jdkrtd��|j}|jdd�}|j|d�jt��j|�}|jdd�}||kS)a�
    Given a datetime and a time zone, determine whether or not a given datetime
    would fall in a gap.

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" exists in ``tz``.
    Nz,Datetime is naive and no time zone provided.)r�)r�r}r�Z
astimezoner)rr�Zdt_rtrrr�datetime_exists�s
r�c
Cs�|dkr |jdkrtd��|j}t|dd�}|dk	rLy
|j|�SYnX|j|d�}t|dd�}t|dd�}|j�|j�k}|j�|j�k}|o�|S)a\
    Given a datetime and a time zone, determine whether or not a given datetime
    is ambiguous (i.e if there are two times differentiated only by their DST
    status).

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" is ambiguous in
        ``tz``.

    .. versionadded:: 2.6.0
    Nz,Datetime is naive and no time zone provided.r)r�r)rAr)r�r}rBrr�rrr)rr�Zis_ambiguous_fnZwall_0Zwall_1Zsame_offsetZsame_dstrrr�datetime_ambiguous�s 

r�cCst|jdd�t�S)z�
    Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds
    since January 1, 1970, ignoring the time zone.
    N)r�)rr��EPOCH)rrrrr>�sr>c@s(eZdZdZdd�Zdd�Zdd�ZdS)	rgz^
    Class for wrapping contexts so that they are passed through in a
    with statement.
    cCs
||_dS)N)�context)rrrrrr0�sz_ContextWrapper.__init__cCs|jS)N)r)rrrr�	__enter__�sz_ContextWrapper.__enter__cOsdS)Nr)�argsrarrr�__exit__�sz_ContextWrapper.__exit__N)r r"r#r$r0rrrrrrrg�srg)N)N)N)/r$r,r~r5�sysr�r�ZsixrZ_commonrrrrrr	�winr
r�ImportErrorr-r
ZutcfromtimestamprZ	toordinalZEPOCHORDINALr�rrr3r&rErVrbr�r�r�r�r��platformr�r�r�r�r�r>rgrrrr�<module>	s\
8Fv-
5"jRH
J

.__pycache__/tz.cpython-36.pyc000064400000105541150373450210012045 0ustar003

6�cY���@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl	m
Z
mZddl	mZyddlmZmZWnek
r�dZZYnXejd�Zejjd�Zej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de
�Z"Gdd�de"�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&ej'dk�r�d d!gZ(d"d#d$d%gZ)ngZ(gZ)d0d&d'�Z*d1d(d)�Z+d2d*d+�Z,d,d-�Z-Gd.d/�d/e�Z.dS)3a{
This module offers timezone implementations subclassing the abstract
:py:`datetime.tzinfo` type. There are classes to handle tzfile format files
(usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ
environment string (in all known formats), given ranges (with help from
relative deltas), local machine timezone, fixed offset timezone, and UTC
timezone.
�N)�string_types�)�tzname_in_python2�_tzinfo�_total_seconds)�tzrangebase�enfold)�_validate_fromutc_inputs)�tzwin�
tzwinlocalc@sbeZdZdZdd�Zdd�Zedd��Zdd	�Ze	d
d��Z
dd
�ZdZdd�Z
dd�ZejZdS)�tzutczD
    This is a tzinfo object that represents the UTC time zone.
    cCstS)N)�ZERO)�self�dt�r�/usr/lib/python3.6/tz.py�	utcoffset$sztzutc.utcoffsetcCstS)N)r
)rrrrr�dst'sz	tzutc.dstcCsdS)N�UTCr)rrrrr�tzname*sztzutc.tznamecCsdS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        Fr)rrrrr�is_ambiguous.sztzutc.is_ambiguouscCs|S)z�
        Fast track version of fromutc() returns the original ``dt`` object for
        any valid :py:class:`datetime.datetime` object.
        r)rrrrr�fromutc>sz
tzutc.fromutccCs0t|ttf�stSt|t�p.t|t�o.|jtkS)N)�
isinstancer�tzoffset�NotImplemented�_offsetr
)r�otherrrr�__eq__Fs
ztzutc.__eq__NcCs
||kS)Nr)rrrrr�__ne__Osztzutc.__ne__cCsd|jjS)Nz%s())�	__class__�__name__)rrrr�__repr__Rsztzutc.__repr__)r �
__module__�__qualname__�__doc__rrrrrr	rr�__hash__rr!�object�
__reduce__rrrrr src@sjeZdZdZdd�Zdd�Zdd�Zedd	��Ze	d
d��Z
dd
�Zdd�ZdZ
dd�Zdd�ZejZdS)ra1
    A simple class for representing a fixed offset from UTC.

    :param name:
        The timezone name, to be returned when ``tzname()`` is called.

    :param offset:
        The time zone offset in seconds, or (since version 2.6.0, represented
        as a :py:class:`datetime.timedelta` object.
    cCs>||_yt|�}Wnttfk
r*YnXtj|d�|_dS)N)�seconds)�_namer�	TypeError�AttributeError�datetime�	timedeltar)r�name�offsetrrr�__init__csztzoffset.__init__cCs|jS)N)r)rrrrrrmsztzoffset.utcoffsetcCstS)N)r
)rrrrrrpsztzoffset.dstcCs|jS)N)r))rrrrrrssztzoffset.tznamecCs
||jS)N)r)rrrrrrwsztzoffset.fromutccCsdS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        Fr)rrrrrr{sztzoffset.is_ambiguouscCst|t�stS|j|jkS)N)rrrr)rrrrrr�s
ztzoffset.__eq__NcCs
||kS)Nr)rrrrrr�sztzoffset.__ne__cCs"d|jjt|j�tt|j��fS)Nz
%s(%s, %s))rr �reprr)�intrr)rrrrr!�sztzoffset.__repr__)r r"r#r$r0rrrrr	rrrr%rr!r&r'rrrrrXs

rcsxeZdZdZ�fdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
ddd�Zdd�ZdZ
dd�Zdd�ZejZ�ZS)�tzlocalzR
    A :class:`tzinfo` subclass built around the ``time`` timezone functions.
    cs`tt|�j�tjtjd�|_tjr:tjtj	d�|_
n|j|_
|j
|j|_t|j�|_
dS)N)r()�superr3r0r,r-�time�timezone�_std_offsetZdaylightZaltzone�_dst_offset�
_dst_saved�bool�_hasdst)r)rrrr0�sztzlocal.__init__cCs,|dkr|jrdS|j|�r"|jS|jSdS)N)r;�_isdstr8r7)rrrrrr�s

ztzlocal.utcoffsetcCs0|dkr|jrdS|j|�r(|j|jStSdS)N)r;r<r8r7r
)rrrrrr�s

ztzlocal.dstcCstj|j|�S)N)r5rr<)rrrrrr�sztzlocal.tznamecCs$|j|�}|o"||j||j�kS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        )�
_naive_is_dstr9)rrZ	naive_dstrrrr�s
ztzlocal.is_ambiguouscCst|�}tj|tj�jS)N)�_datetime_to_timestampr5�	localtimer6Ztm_isdst)rr�	timestamprrrr=�sztzlocal._naive_is_dstTcCsF|js
dS|j|�}t|dd�}|j|�rB|dk	r>|j|�SdS|S)NF�foldT)r;r=�getattrr�_fold)rrZ
fold_naiveZdstvalrArrrr<�s

ztzlocal._isdstcCs&t|t�stS|j|jko$|j|jkS)N)rr3rr7r8)rrrrrrs
ztzlocal.__eq__NcCs
||kS)Nr)rrrrrrsztzlocal.__ne__cCsd|jjS)Nz%s())rr )rrrrr!sztzlocal.__repr__)T)r r"r#r$r0rrrrrr=r<rr%rr!r&r'�
__classcell__rr)rrr3�s		
(r3c@sReZdZdddddddgZdd	�Zd
d�Zdd
�ZdZdd�Zdd�Z	dd�Z
dS)�_ttinfor/�delta�isdst�abbr�isstd�isgmt�	dstoffsetcCs x|jD]}t||d�qWdS)N)�	__slots__�setattr)r�attrrrrr0sz_ttinfo.__init__cCsRg}x6|jD],}t||�}|dk	r|jd|t|�f�qWd|jjdj|�fS)Nz%s=%sz%s(%s)z, )rLrB�appendr1rr �join)r�lrN�valuerrrr!s
z_ttinfo.__repr__cCsbt|t�stS|j|jko`|j|jko`|j|jko`|j|jko`|j|jko`|j|jko`|j	|j	kS)N)
rrErr/rFrGrHrIrJrK)rrrrrr$s
z_ttinfo.__eq__NcCs
||kS)Nr)rrrrrr2sz_ttinfo.__ne__cCs(i}x|jD]}t||d�||<qW|S)N)rLrB)r�stater.rrr�__getstate__5sz_ttinfo.__getstate__cCs,x&|jD]}||krt||||�qWdS)N)rLrM)rrSr.rrr�__setstate__;sz_ttinfo.__setstate__)r r"r#rLr0r!rr%rrTrUrrrrrEs
rEc@s,eZdZdZdddddddd	gZd
d�ZdS)
�_tzfilezw
    Lightweight class for holding the relevant transition and time zone
    information read from binary tzfiles.
    �
trans_list�trans_list_utc�	trans_idx�ttinfo_list�
ttinfo_std�
ttinfo_dst�
ttinfo_before�ttinfo_firstcKs(x"|jD]}t|||j|d��qWdS)N)�attrsrM�get)r�kwargsrNrrrr0Isz_tzfile.__init__N)r r"r#r$r_r0rrrrrVAsrVcs�eZdZdZd&�fdd�	Zdd�Zdd�Zd'd
d�Zdd
�Zdd�Z	dd�Z
d(dd�Zdd�Zdd�Z
dd�Zedd��Zdd�ZdZdd�Zd d!�Zd"d#�Zd$d%�Z�ZS))�tzfilea�
    This is a ``tzinfo`` subclass thant allows one to use the ``tzfile(5)``
    format timezone files to extract current and historical zone information.

    :param fileobj:
        This can be an opened file stream or a file name that the time zone
        information can be read from.

    :param filename:
        This is an optional parameter specifying the source of the time zone
        information in the event that ``fileobj`` is a file object. If omitted
        and ``fileobj`` is a file stream, this parameter will be set either to
        ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``.

    See `Sources for Time Zone and Daylight Saving Time Data
    <http://www.twinsun.com/tz/tz-link.htm>`_ for more information. Time zone
    files can be compiled from the `IANA Time Zone database files
    <https://www.iana.org/time-zones>`_ with the `zic time zone compiler
    <https://www.freebsd.org/cgi/man.cgi?query=zic&sektion=8>`_
    Nc	s�tt|�j�d}t|t�r2||_t|d�}d}n.|dk	rB||_nt|d�rV|j|_n
t	|�|_|dk	r�|stt
|�}|�}|j|�}WdQRX|j|�dS)NF�rbTr.)
r4rbr0rr�	_filename�open�hasattrr.r1�_ContextWrapper�_read_tzfile�_set_tzdata)r�fileobj�filenameZfile_opened_hereZfile_stream�tzobj)rrrr0ds"




ztzfile.__init__cCs*x$tjD]}t|d|t||��qWdS)z= Set the time zone data of this object from a _tzfile object �_N)rVr_rMrB)rrlrNrrrri|sztzfile._set_tzdatacs�t��|jd�j�dkr td��|jd�tjd|jd��\}}}}}}|rnttjd||j|d����_ng�_|r�tjd||j|���_ng�_g}x(t	|�D]}	|j
tjd	|jd
���q�W|j|�j�}
|r�|j|dtj
�|�rtjd||j|��}|�r"tjd||j|��}g�_x�t	|�D]�}	||	\}
}}d
|
dd
}
t�}|
|_tjd�|_tj|
d�|_||_|
||
jd|��|_||	k�o�||	dk|_||	k�o�||	dk|_�jj
|��q2W�fdd��jD��_d�_d�_d�_�j�r؈j�s$�jd�_�_n�x�t	|ddd�D]V}	�j|	}�j�r`|j�r`|�_n�j�rx|j�rx|�_�j�r6�j�r6P�q6W�j�r��j�r��j�_x,�jD]}|j�s�|�_P�q�W�jd�_d}g�_xlt�j�D]^\}	}|j�s
|j}|}n*|dk	�r*|j||_|�j|	<|�p2d}�jj
�j|	|��q�Wd}x~t t	t!�j���D]h}	�j|	}|j�r�|j�p�|dk�s�|j||_n|j}t"|jtj��s�tj|jd�|_|�j|	<�qhWt#�j��_t#�j��_t#�j��_�S)N�ZTZifzmagic not found�z>6l�z>%dlz>%dBz>lbb��z>%db�<�r)r(�csg|]}�j|�qSr)rZ)�.0�idx)�outrr�
<listcomp>sz'tzfile._read_tzfile.<locals>.<listcomp>r���rz)$rV�read�decode�
ValueError�struct�unpack�listrXrY�rangerO�seek�os�SEEK_CURrZrEr/r,r-rKrFrG�findrHrIrJr[r\r]r^rW�	enumerate�reversed�lenr�tuple)rrjZ
ttisgmtcntZ
ttisstdcntZleapcntZtimecntZtypecntZcharcntZttinfo�irHrIrJZgmtoffrGZabbrind�ttiZ
laststdoffsetr/r)rxrrh�s�
		






	



ztzfile._read_tzfileFcCs6|js
dSt|�}|r|jn|j}tj||�}|dS)Nr)�_trans_listr>Z_trans_list_utc�bisectZbisect_right)rr�in_utcr@rWrwrrr�_find_last_transition^sztzfile._find_last_transitioncCs8|dks|dt|j�kr |jS|dkr.|jS|j|S)Nrr)r�r��_ttinfo_stdZ_ttinfo_before�
_trans_idx)rrwrrr�_get_ttinfoms
ztzfile._get_ttinfocCs|j|�}|j|�S)N)�_resolve_ambiguous_timer�)rrrwrrr�_find_ttinfoxs
ztzfile._find_ttinfocCsnt|tj�std��|j|k	r&td��|j|dd�}|j|�}|tj|jd�}|j	||d�}t
|t|�d�S)a
        The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`.

        :param dt:
            A :py:class:`datetime.datetime` object.

        :raises TypeError:
            Raised if ``dt`` is not a :py:class:`datetime.datetime` object.

        :raises ValueError:
            Raised if this is called with a ``dt`` which does not have this
            ``tzinfo`` attached.

        :return:
            Returns a :py:class:`datetime.datetime` object representing the
            wall time in ``self``'s time zone.
        z&fromutc() requires a datetime argumentzdt.tzinfo is not selfT)r�)r()rw)rA)rr,r*�tzinfor}r�r�r-r/rrr2)rrrwr�Zdt_outrArrrr}s

ztzfile.fromutccCsd|dkr|j|�}t|�}|j|�}|dks4|dkr8dS|j|d�j|j}|j|}|||kS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        NrFr)r�r>r�r/r�)rrrwr@r�ZodZttrrrr�s


ztzfile.is_ambiguouscCsF|j|�}|j|�}|dks$|dkr(|St|o:|j||��}||S)Nr)r�rCr2r)rrrwrCZ
idx_offsetrrrr��s

ztzfile._resolve_ambiguous_timecCs"|dkrdS|jstS|j|�jS)N)r�r
r�rF)rrrrrr�s
ztzfile.utcoffsetcCs0|dkrdS|jstS|j|�}|js*tS|jS)N)Z_ttinfo_dstr
r�rGrK)rrr�rrrr�s
z
tzfile.dstcCs |js|dkrdS|j|�jS)N)r�r�rH)rrrrrr�sz
tzfile.tznamecCs2t|t�stS|j|jko0|j|jko0|j|jkS)N)rrbrr�r�Z_ttinfo_list)rrrrrr�s

z
tzfile.__eq__cCs
||kS)Nr)rrrrrr�sz
tzfile.__ne__cCsd|jjt|j�fS)Nz%s(%s))rr r1rd)rrrrr!�sztzfile.__repr__cCs
|jd�S)N)�
__reduce_ex__)rrrrr'�sztzfile.__reduce__cCs|jd|jf|jfS)N)rrd�__dict__)rZprotocolrrrr��sztzfile.__reduce_ex__)N)F)N)r r"r#r$r0rirhr�r�r�rrr�rrrrrr%rr!r'r�rDrr)rrrbNs(]
$

	rbc@s6eZdZdZddd�Zdd�Zdd�Zed	d
��ZdS)�tzrangeaQ
    The ``tzrange`` object is a time zone specified by a set of offsets and
    abbreviations, equivalent to the way the ``TZ`` variable can be specified
    in POSIX-like systems, but using Python delta objects to specify DST
    start, end and offsets.

    :param stdabbr:
        The abbreviation for standard time (e.g. ``'EST'``).

    :param stdoffset:
        An integer or :class:`datetime.timedelta` object or equivalent
        specifying the base offset from UTC.

        If unspecified, +00:00 is used.

    :param dstabbr:
        The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).

        If specified, with no other DST information, DST is assumed to occur
        and the default behavior or ``dstoffset``, ``start`` and ``end`` is
        used. If unspecified and no other DST information is specified, it
        is assumed that this zone has no DST.

        If this is unspecified and other DST information is *is* specified,
        DST occurs in the zone but the time zone abbreviation is left
        unchanged.

    :param dstoffset:
        A an integer or :class:`datetime.timedelta` object or equivalent
        specifying the UTC offset during DST. If unspecified and any other DST
        information is specified, it is assumed to be the STD offset +1 hour.

    :param start:
        A :class:`relativedelta.relativedelta` object or equivalent specifying
        the time and time of year that daylight savings time starts. To specify,
        for example, that DST starts at 2AM on the 2nd Sunday in March, pass:

            ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``

        If unspecified and any other DST information is specified, the default
        value is 2 AM on the first Sunday in April.

    :param end:
        A :class:`relativedelta.relativedelta` object or equivalent representing
        the time and time of year that daylight savings time ends, with the
        same specification method as in ``start``. One note is that this should
        point to the first time in the *standard* zone, so if a transition
        occurs at 2AM in the DST zone and the clocks are set back 1 hour to 1AM,
        set the `hours` parameter to +1.


    **Examples:**

    .. testsetup:: tzrange

        from dateutil.tz import tzrange, tzstr

    .. doctest:: tzrange

        >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
        True

        >>> from dateutil.relativedelta import *
        >>> range1 = tzrange("EST", -18000, "EDT")
        >>> range2 = tzrange("EST", -18000, "EDT", -14400,
        ...                  relativedelta(hours=+2, month=4, day=1,
        ...                                weekday=SU(+1)),
        ...                  relativedelta(hours=+1, month=10, day=31,
        ...                                weekday=SU(-1)))
        >>> tzstr('EST5EDT') == range1 == range2
        True

    NcCs@ddlma||_||_yt|�}Wnttfk
r<YnXyt|�}Wnttfk
rbYnX|dk	r|tj|d�|_	nt
|_	|dk	r�tj|d�|_n(|r�|dk	r�|j	tjdd�|_nt
|_|r�|dkr�tjdddtjd
�d�|_
n||_
|�r|dk�rtjdd	d
tjd�d�|_n||_|j|j	|_t|j
�|_dS)Nr)�
relativedelta)r(r)�hours�rn)r��month�day�weekday�
�rr�rrrz)�dateutilr��	_std_abbr�	_dst_abbrrr*r+r,r-r7r
r8�SU�_start_delta�
_end_delta�_dst_base_offset_r:�hasdst)r�stdabbr�	stdoffset�dstabbrrK�start�endrrrr0Js:ztzrange.__init__cCs4|js
dStj|dd�}||j}||j}||fS)a�
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        Nr)r�r,r�r�)rZyearZ	base_yearr�r�rrr�transitionsys

ztzrange.transitionscCsVt|t�stS|j|jkoT|j|jkoT|j|jkoT|j|jkoT|j|jkoT|j|jkS)N)	rr�rr�r�r7r8r�r�)rrrrrr�s
ztzrange.__eq__cCs|jS)N)r�)rrrr�_dst_base_offset�sztzrange._dst_base_offset)NNNNN)	r r"r#r$r0r�r�propertyr�rrrrr�sI
-r�c@s,eZdZdZddd�Zddd�Zdd	�Zd
S)
�tzstra
    ``tzstr`` objects are time zone objects specified by a time-zone string as
    it would be passed to a ``TZ`` variable on POSIX-style systems (see
    the `GNU C Library: TZ Variable`_ for more details).

    There is one notable exception, which is that POSIX-style time zones use an
    inverted offset format, so normally ``GMT+3`` would be parsed as an offset
    3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
    offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
    behavior, pass a ``True`` value to ``posix_offset``.

    The :class:`tzrange` object provides the same functionality, but is
    specified using :class:`relativedelta.relativedelta` objects. rather than
    strings.

    :param s:
        A time zone string in ``TZ`` variable format. This can be a
        :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: :class:`unicode`)
        or a stream emitting unicode characters (e.g. :class:`StringIO`).

    :param posix_offset:
        Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
        ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
        POSIX standard.

    .. _`GNU C Library: TZ Variable`:
        https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
    Fc	Cs�ddlma||_tj|�}|dkr,td��|jd
krJ|rJ|jd9_tj||j|j|j	|j
ddd�|j	s~d|_d|_n&|j
|j�|_|jr�|j
|jdd	�|_t|j�|_dS)Nr)�parserzunknown string format�GMTrrF)r�r�)�isend)r�rrz)r�r��_sZ_parsetzr}r�r�r�r0r�rKr�r��_deltar�r�r:r�)r�sZposix_offset�resrrrr0�s"

ztzstr.__init__rcCs<ddlm}i}|jdk	rr|j|d<|jdk	r`|j|j|j�|d<|jdkrVd|d<qpd|d<q�|jr�|j|d<n*|jdk	r�|j|d<n|jdk	r�|j|d	<|s�|s�d
|d<d|d<|jd�|d<nd|d<d|d<|jd�|d<|j	dk	�r�|j	|d<nd
|d<|�r0|j
|j}|d|j|j
d8<|jf|�S)Nr)r�r�r�rr�r�ZyeardayZ	nlyeardayrnr�r(i i�Qrrz)r�r�r�r�Zweekr�ZydayZjydayr�r5r8r7r(Zdays)r�xr�r�rarFrrrr��s<








ztzstr._deltacCsd|jjt|j�fS)Nz%s(%s))rr r1r�)rrrrr!sztzstr.__repr__N)F)r)r r"r#r$r0r�r!rrrrr��s
 
)r�c@seZdZddd�ZdS)�_tzicalvtzcompNcCs@tj|d�|_tj|d�|_|j|j|_||_||_||_dS)N)r()r,r-�tzoffsetfrom�
tzoffsetto�tzoffsetdiffrGr�rrule)rr�r�rGrr�rrrr0sz_tzicalvtzcomp.__init__)NN)r r"r#r0rrrrr�sr�csZeZdZgf�fdd�	Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	d
d�Z
ejZ�Z
S)�
_tzicalvtzcs*tt|�j�||_||_g|_g|_dS)N)r4r�r0�_tzid�_comps�
_cachedate�
_cachecomp)r�tzid�comps)rrrr0s
z_tzicalvtz.__init__c
Cs
t|j�dkr|jdS|jdd�}y|j|jj||j|�f�Stk
rTYnXd}d}x4|jD]*}|j||�}|rf|s�||krf|}|}qfW|s�x"|jD]}|j	s�|}Pq�W|d}|jj
d||j|�f�|jj
d|�t|j�dk�r|jj�|jj�|S)Nrr)r�r�)r�r��replacer�r��indexrCr}�_find_compdtrG�insert�pop)rrZ
lastcompdtZlastcomp�comp�compdtrrr�
_find_comps4


z_tzicalvtz._find_compcCs2|jtkr|j|�r||j8}|jj|dd�}|S)NT)Zinc)r�r
rCr�Zbefore)rr�rr�rrrr�Is
z_tzicalvtz._find_compdtcCs|dkrdS|j|�jS)N)r�r�)rrrrrrQsz_tzicalvtz.utcoffsetcCs|j|�}|jr|jStSdS)N)r�rGr�r
)rrr�rrrrWs
z_tzicalvtz.dstcCs|j|�jS)N)r�r)rrrrrr^sz_tzicalvtz.tznamecCsdt|j�S)Nz<tzicalvtz %s>)r1r�)rrrrr!bsz_tzicalvtz.__repr__)r r"r#r0r�r�rrrrr!r&r'rDrr)rrr�s*r�c@sBeZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dS)�tzicala\
    This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure
    as set out in `RFC 2445`_ Section 4.6.5 into one or more `tzinfo` objects.

    :param `fileobj`:
        A file or stream in iCalendar format, which should be UTF-8 encoded
        with CRLF endings.

    .. _`RFC 2445`: https://www.ietf.org/rfc/rfc2445.txt
    c	Csjddlmat|t�r(||_t|d�}nt|dt|��|_t|�}i|_	|�}|j
|j��WdQRXdS)Nr)r��rr.)r�r�rrr�rerBr1rg�_vtz�
_parse_rfcr{)rrjZfobjrrrr0ss
ztzical.__init__cCst|jj��S)z?
        Retrieves the available time zones as a list.
        )r�r��keys)rrrrr��sztzical.keysNcCsP|dkrDt|j�dkr td��nt|j�dkr6td��tt|j��}|jj|�S)a�
        Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.

        :param tzid:
            If there is exactly one time zone available, omitting ``tzid``
            or passing :py:const:`None` value returns it. Otherwise a valid
            key (which can be retrieved from :func:`keys`) is required.

        :raises ValueError:
            Raised if ``tzid`` is not specified but there are either more
            or fewer than 1 zone defined.

        :returns:
            Returns either a :py:class:`datetime.tzinfo` object representing
            the relevant time zone or :py:const:`None` if the ``tzid`` was
            not found.
        Nrzno timezones definedrz more than one timezone available)r�r�r}�next�iterr`)rr�rrrr`�s
z
tzical.getcCs�|j�}|std��|ddkr>d|ddk}|dd�}nd}t|�dkrzt|dd��dt|dd��d	|St|�d
kr�t|dd��dt|dd��d	t|dd��|Std|��dS)Nzempty offsetr�+�-rrnr�irsrqzinvalid offset: )r�r�rzr)rzrr)�stripr}r�r2)rr��signalrrr�
_parse_offset�s,<ztzical._parse_offsetcCsH|j�}|std��d}xh|t|�kr�||j�}|s>||=q|dkrv|ddkrv||d|dd�7<||=q|d7}qWd}g}d}d}�x�|D�]�}|s�q�|jdd�\}	}
|	jd�}|s�td��|dj�}	|dd�}|�r$|	d	k�r(|
d)k�rntd|
��|
}d}d}
d}g}d}�q@|	d
k�r|
dk�r�|�rNtd|��|�s\td��|�sjtd��t||�|j|<d}n�|
|k�r|�s�td��|
dk�r�td��|dk�r�td��d}|�r�tj	dj
|�dddd�}t|
||dk||�}|j|�d}ntd|
���q@|�r�|	dk�r2|j|�d}n�|	d*k�rH|j|�n�|	dk�rx|�rltd|	|df��|j
|
�}
nj|	dk�r�|�r�td |d��|j
|
�}n>|	d!k�r�|�r�td"|d��|
}n|	d#k�r�ntd$|	��n>|	d%k�r
|�rtd&|d��|
}n|	d+k�rntd$|	��q�|	d	kr�|
dkr�d}g}d}q�WdS),Nzempty stringr� rF�:�;zempty property nameZBEGIN�STANDARD�DAYLIGHTzunknown component: ZENDZ	VTIMEZONEzcomponent not closed: zmandatory TZID not foundz at least one component is neededzmandatory DTSTART not foundz mandatory TZOFFSETFROM not found�
T)Z
compatibleZignoretz�cachezinvalid component end: ZDTSTART�RRULE�RDATE�EXRULE�EXDATEZTZOFFSETFROMzunsupported %s parm: %s Z
TZOFFSETTOzunsupported TZOFFSETTO parm: ZTZNAMEzunsupported TZNAME parm: �COMMENTzunsupported property: ZTZIDzunsupported TZID parm: �TZURL�
LAST-MODIFIED)r�r�)r�r�r�r�)r�r�r�)�
splitlinesr}r��rstrip�split�upperr�r�r�ZrrulestrrPr�rOr�)rr��linesr��liner�r�ZinvtzZcomptyper.rRZparmsZfounddtstartr�r�Z
rrulelinesrZrrr�rrrr��s�

















ztzical._parse_rfccCsd|jjt|j�fS)Nz%s(%s))rr r1r�)rrrrr!+sztzical.__repr__)N)
r r"r#r$r0r�r`r�r�r!rrrrr�hs

vr�Zwin32z/etc/localtimer?z/usr/share/zoneinfoz/usr/lib/zoneinfoz/usr/share/lib/zoneinfoz
/etc/zoneinfocCsDd}|s,ytjd}Wntk
r*YnX|dks<|dkr�x�tD]v}tjj|�s�|}x*tD] }tjj||�}tjj|�r\Pq\WqBtjj|�rByt	|�}PWqBt
ttfk
r�YqBXqBWt
�}�nz|jd�r�|dd�}tjj|��r
tjj|��rt	|�}nd}�n6�x2tD]l}tjj||�}tjj|��sP|jdd�}tjj|��sP�qyt	|�}PWnt
ttfk
�rzYnX�qWd}tdk	�r�yt|�}Wntk
�r�d}YnX|�s�ddlm}|�j|�}|�s@xb|D]6}|dk�r�yt|�}Wntk
�rYnXP�q�W|dk�r.t�}n|tjk�r@t
�}|S)
NZTZr�rr�rmr)�get_zonefile_instance�
0123456789r�rrz)r�r)r��environ�KeyError�TZFILES�path�isabs�TZPATHSrP�isfilerb�IOError�OSErrorr}r3�
startswithr�r
ZWindowsErrorZdateutil.zoneinfor�r`r�rr5r)r.�tz�filepathrkr�r��crrr�gettz:sz










r�cCsZ|dkr |jdkrtd��|j}|jdd�}|j|d�jt��j|�}|jdd�}||kS)a�
    Given a datetime and a time zone, determine whether or not a given datetime
    would fall in a gap.

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" exists in ``tz``.
    Nz,Datetime is naive and no time zone provided.)r�)r�r}r�Z
astimezoner)rr�Zdt_rtrrr�datetime_exists�s
r�c
Cs�|dkr |jdkrtd��|j}t|dd�}|dk	rLy
|j|�SYnX|j|d�}t|dd�}t|dd�}|j�|j�k}|j�|j�k}|o�|S)a\
    Given a datetime and a time zone, determine whether or not a given datetime
    is ambiguous (i.e if there are two times differentiated only by their DST
    status).

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" is ambiguous in
        ``tz``.

    .. versionadded:: 2.6.0
    Nz,Datetime is naive and no time zone provided.r)r�r)rAr)r�r}rBrr�rrr)rr�Zis_ambiguous_fnZwall_0Zwall_1Zsame_offsetZsame_dstrrr�datetime_ambiguous�s 

r�cCst|jdd�t�S)z�
    Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds
    since January 1, 1970, ignoring the time zone.
    N)r�)rr��EPOCH)rrrrr>�sr>c@s(eZdZdZdd�Zdd�Zdd�ZdS)	rgz^
    Class for wrapping contexts so that they are passed through in a
    with statement.
    cCs
||_dS)N)�context)rrrrrr0�sz_ContextWrapper.__init__cCs|jS)N)r)rrrr�	__enter__�sz_ContextWrapper.__enter__cOsdS)Nr)�argsrarrr�__exit__�sz_ContextWrapper.__exit__N)r r"r#r$r0rrrrrrrg�srg)N)N)N)/r$r,r~r5�sysr�r�ZsixrZ_commonrrrrrr	�winr
r�ImportErrorr-r
ZutcfromtimestamprZ	toordinalZEPOCHORDINALr�rrr3r&rErVrbr�r�r�r�r��platformr�r�r�r�r�r>rgrrrr�<module>	s\
8Fv-
5"jRH
J

.__pycache__/win.cpython-36.opt-1.pyc000064400000022344150373450210013143 0ustar003

6�cY�,�@s�ddlZddlZddlmZddlmZyddlZddlmZWnek
r\e	d��YnXddl
mZdd	d
gZej
d�ZdZd
ZdZdd�Ze�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd	�d	e�Zdd�Zdd�ZdS)�N)�winreg)�	text_type)�wintypesz#Running tzwin on non-Windows system�)�tzrangebase�tzwin�
tzwinlocal�tzres�z7SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zonesz4SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zonesz4SYSTEM\CurrentControlSet\Control\TimeZoneInformationcCsLtjdtj�}ytj|t�j�t}Wntk
r>t}YnX|j�|S)N)r�ConnectRegistry�HKEY_LOCAL_MACHINE�OpenKey�TZKEYNAMENTZCloseZWindowsError�TZKEYNAME9X)�handle�	TZKEYNAME�r�/usr/lib/python3.6/win.py�
_settzkeynames
rc@s6eZdZdZejej�Zd
dd�Z	dd�Z
dd�Zd	S)r	z{
    Class for accessing `tzres.dll`, which contains timezone name related
    resources.

    .. versionadded:: 2.5.0
    �	tzres.dllcCs@tjd�}tjtjtjtjf|j_|j|_tj|�|_	||_
dS)N�user32)�ctypesZWinDLLrZ	HINSTANCEZUINT�LPWSTRZc_int�LoadStringWZargtypes�_tzres�	tzres_loc)�selfrrrrr�__init__1s
ztzres.__init__cCs<|j�}tjtj|�tj�}|j|jj||d�}|d|�S)a�
        Load a timezone name from a DLL offset (integer).

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.load_name(112))
        'Eastern Standard Time'

        :param offset:
            A positive integer value referring to a string from the tzres dll.

        ..note:
            Offsets found in the registry are generally of the form
            `@tzres.dll,-114`. The offset in this case if 114, not -114.

        rN)	�p_wcharr�castZbyrefrrrrZ_handle)r�offsetZresourceZlpBufferZncharrrr�	load_name?sztzres.load_namec	CsH|jd�s|S|jd�}yt|d�}Wntd��YnX|j|�S)a�
        Parse strings as returned from the Windows registry into the time zone
        name as defined in the registry.

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.name_from_string('@tzres.dll,-251'))
        'Dateline Daylight Time'
        >>> print(tzr.name_from_string('Eastern Standard Time'))
        'Eastern Standard Time'

        :param tzname_str:
            A timezone name string as returned from a Windows registry key.

        :return:
            Returns the localized timezone string from tzres.dll if the string
            is of the form `@tzres.dll,-offset`, else returns the input string.
        �@z,-rzMalformed timezone string.)�
startswith�split�int�
ValueErrorr!)rZ
tzname_strZ	name_spltr rrr�name_from_stringUs

ztzres.name_from_stringN)r)�__name__�
__module__�__qualname__�__doc__rZPOINTERrZWCHARrrr!r'rrrrr	(s

c@sPeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
edd��ZdS)�	tzwinbasezBtzinfo class based on win32's timezones available in the registry.cCstd��dS)Nz#tzwinbase is an abstract base class)�NotImplementedError)rrrrrvsztzwinbase.__init__cCs�t|t�stS|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j	|j	ko�|j
|j
ko�|j|jko�|j|jko�|j
|j
ko�|j|jkS)N)�
isinstancer,�NotImplemented�_std_offset�_dst_offset�
_stddayofweek�
_dstdayofweek�_stdweeknumber�_dstweeknumber�_stdhour�_dsthour�
_stdminute�
_dstminute�	_std_abbr�	_dst_abbr)r�otherrrr�__eq__ys
ztzwinbase.__eq__csVtjdtj��>}tj|t��&��fdd�ttj��d�D�}WdQRXWdQRX|S)z4Return a list of all time zones known to the system.Ncsg|]}tj�|��qSr)rZEnumKey)�.0�i)�tzkeyrr�
<listcomp>�sz"tzwinbase.list.<locals>.<listcomp>r)rrrr
r�range�QueryInfoKey)r�resultr)r@r�list�s

*ztzwinbase.listcCs|jS)N)�_display)rrrr�display�sztzwinbase.displaycCsT|js
dSt||j|j|j|j|j�}t||j|j|j	|j
|j�}||j8}||fS)a�
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        N)
�hasdst�picknthweekday�	_dstmonthr3r7r9r5�	_stdmonthr2r6r8r4�_dst_base_offset)r�yearZdstonZdstoffrrr�transitions�s
ztzwinbase.transitionscCs
|jdkS)Nr)rJ)rrrr�_get_hasdst�sztzwinbase._get_hasdstcCs|jS)N)�_dst_base_offset_)rrrrrL�sztzwinbase._dst_base_offsetN)
r(r)r*r+rr=�staticmethodrErGrNrO�propertyrLrrrrr,ts	r,c@s$eZdZdd�Zdd�Zdd�ZdS)rc	Cs||_tjdtj��8}td�jt|d�}tj||��}t|�}WdQRXWdQRX|d|_	|d|_
|d|_tj
d|d�}|d|d	}||d
}tj|d�|_tj|d�|_|dd
�\|_|_|_|_|_|dd�\|_|_|_|_|_|j|j|_|j�|_dS)Nz{kn}\{name})�kn�nameZStdZDlt�Displayz=3l16hZTZIrr�)�minutes��	��)�_namerrrr�formatrr
�valuestodictr:r;rF�struct�unpack�datetime�	timedeltar0r1rKr2r4r6r8rJr3r5r7r9rPrOrH)	rrTr�	tzkeynamer@�keydict�tup�	stdoffset�	dstoffsetrrrr�s"


  ztzwin.__init__cCsdt|j�S)Nz	tzwin(%s))�reprr\)rrrr�__repr__�sztzwin.__repr__cCs|j|jffS)N)�	__class__r\)rrrr�
__reduce__�sztzwin.__reduce__N)r(r)r*rrirkrrrrr�s&c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rc
 Csntjdtj���}tj|t��}t|�}WdQRX|d|_|d|_yBtd�j	t
|jd�}tj||��}t|�}|d|_WdQRXWntk
r�d|_YnXWdQRX|d|d}||d}t
j|d	�|_t
j|d	�|_tjd
|d�}	|	dd
�\|_|_|_|_|	d|_tjd
|d�}	|	dd
�\|_|_|_|_|	d|_|j|j|_|j�|_dS)NZStandardNameZDaylightNamez	{kn}\{sn})rSZsnrUZBiasZStandardBiasZDaylightBias)rWz=8hZ
StandardStartr�r
Z
DaylightStart) rrrr
�TZLOCALKEYNAMEr^r:r;rr]rrF�OSErrorrarbr0r1r_r`rKr4r6r8r2rJr5r7r9r3rPrOrH)
rrZ
tzlocalkeyrdrcr@Z_keydictrfrgrerrrr�s2





ztzwinlocal.__init__cCsdS)Nztzwinlocal()r)rrrrrisztzwinlocal.__repr__cCsdt|j�S)Nztzwinlocal(%s))rhr:)rrrr�__str__sztzwinlocal.__str__cCs
|jffS)N)rj)rrrrrk#sztzwinlocal.__reduce__N)r(r)r*rrirorkrrrrr�s.c	CsTtj||d||�}|j||j�ddd�}||dt}|j|krP|t8}|S)z> dayofweek == 0 means Sunday, whichweek 5 means last instance rr
)Zday)ra�replaceZ
isoweekday�ONEWEEK�month)	rMrrZ	dayofweekZhourZminuteZ	whichweek�firstZ
weekdayoneZwdrrrrI's
rIcCs�i}tj|�d}d}x�t|�D]v}tj||�\}}}|tjksJ|tjkr\|d@r�|d}n2|tjkr�|jd�r�|pxt�}|j	|�}|j
d�}|||<q W|S)	z0Convert a registry key's values to a dictionary.rN�� z@tzres�ll)rrCrBZ	EnumValueZ	REG_DWORDZREG_DWORD_LITTLE_ENDIANZREG_SZr#r	r'�rstrip)�keyZdout�sizeZtz_resr?Zkey_name�valueZdtyperrrr^5s





r^)rar_Z	six.movesrZsixrrrr&�ImportErrorZ_commonr�__all__rbrqrrrmrr�objectr	r,rrrIr^rrrr�<module>s,

LJ/:__pycache__/_common.cpython-36.pyc000064400000026262150373450210013041 0ustar003

6�cY�.�@s�ddlmZddlmZddlmZmZmZed�ZddgZdd�Z	e
ed�rZdd	d�ZnGd
d�de�Zddd�Zd
d�Z
Gdd�de�ZGdd�de�Zdd�Zeede�ZdS)�)�PY3)�wraps)�datetime�	timedelta�tzinfo�tzname_in_python2�enfoldcs�fdd�}|S)z�Change unicode output into bytestrings in Python 2

    tzname() API changed in Python 3. It used to return bytes, but was changed
    to unicode strings
    cs$�||�}|dk	r tr |j�}|S)N)r�encode)�args�kwargs�name)�namefunc��/usr/lib/python3.6/_common.py�adjust_encodings
z*tzname_in_python2.<locals>.adjust_encodingr)r
rr)r
rr
s�fold�cCs|j|d�S)a�
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        )r)�replace)�dtrrrrr!sc@s eZdZdZfZedd��ZdS)�_DatetimeWithFoldz�
        This is a class designed to provide a PEP 495-compliant interface for
        Python versions before 3.6. It is used only for dates in a fold, so
        the ``fold`` attribute is fixed at ``1``.

        .. versionadded:: 2.6.0
        cCsdS)Nrr)�selfrrrr@sz_DatetimeWithFold.foldN)�__name__�
__module__�__qualname__�__doc__�	__slots__�propertyrrrrrr6srcCsLt|dd�|kr|S|j�dd�}||j|jf7}|r@t|�St|�SdS)a�
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        rrN�)�getattrZ	timetupleZmicrosecondrrr)rrr
rrrrDscst���fdd��}|S)z�
    The CPython version of ``fromutc`` checks that the input is a ``datetime``
    object and that ``self`` is attached as its ``tzinfo``.
    cs.t|t�std��|j|k	r$td���||�S)Nz&fromutc() requires a datetime argumentzdt.tzinfo is not self)�
isinstancer�	TypeErrorr�
ValueError)rr)�frr�fromutcgs


z)_validate_fromutc_inputs.<locals>.fromutc)r)r"r#r)r"r�_validate_fromutc_inputsbs	r$c@s<eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dS)
�_tzinfoz=
    Base class for all ``dateutil`` ``tzinfo`` objects.
    cCsV|j|d�}t|dd�}t|dd�}|j�|j�k}|jdd�|jdd�k}|oT|S)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        )rr)rrN)rr�	utcoffset)rrZwall_0Zwall_1Zsame_offsetZsame_dtrrr�is_ambiguousxsz_tzinfo.is_ambiguouscCs4|j|�r,||}t||j�|j�k�}nd}|S)a�
        Determine the fold status of a "wall" datetime, given a representation
        of the same datetime as a (naive) UTC datetime. This is calculated based
        on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all
        datetimes, and that this offset is the actual number of hours separating
        ``dt_utc`` and ``dt_wall``.

        :param dt_utc:
            Representation of the datetime as UTC

        :param dt_wall:
            Representation of the datetime as "wall time". This parameter must
            either have a `fold` attribute or have a fold-naive
            :class:`datetime.tzinfo` attached, otherwise the calculation may
            fail.
        r)r'�intr&�dst)r�dt_utc�dt_wallZ
delta_wall�_foldrrr�_fold_status�s

z_tzinfo._fold_statuscCst|dd�S)Nrr)r)rrrrrr,�sz
_tzinfo._foldcCsh|j�}|dkrtd��|j�}|dkr0td��||}||7}t|dd�j�}|dkr`td��||S)a�
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurence, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        Nz0fromutc() requires a non-None utcoffset() resultz*fromutc() requires a non-None dst() resultr)rz;fromutc(): dt.dst gave inconsistent results; cannot convert)r&r!r)r)rrZdtoffZdtdstZdeltarrr�_fromutc�sz_tzinfo._fromutccCs"|j|�}|j||�}t||d�S)a�
        Given a timezone-aware datetime in a given timezone, calculates a
        timezone-aware datetime in a new timezone.

        Since this is the one time that we *know* we have an unambiguous
        datetime object, we take this opportunity to determine whether the
        datetime is ambiguous and in a "fold" state (e.g. if it's the first
        occurance, chronologically, of the ambiguous datetime).

        :param dt:
            A timezone-aware :class:`datetime.datetime` object.
        )r)r.r-r)rrr+r,rrrr#�s
z_tzinfo.fromutcN)
rrrrr'r-r,r.r$r#rrrrr%ss%r%c@szeZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Ze
dd��ZdZdd�Zdd�ZejZdS)�tzrangebasea�
    This is an abstract base class for time zones represented by an annual
    transition into and out of DST. Child classes should implement the following
    methods:

        * ``__init__(self, *args, **kwargs)``
        * ``transitions(self, year)`` - this is expected to return a tuple of
          datetimes representing the DST on and off transitions in standard
          time.

    A fully initialized ``tzrangebase`` subclass should also provide the
    following attributes:
        * ``hasdst``: Boolean whether or not the zone uses DST.
        * ``_dst_offset`` / ``_std_offset``: :class:`datetime.timedelta` objects
          representing the respective UTC offsets.
        * ``_dst_abbr`` / ``_std_abbr``: Strings representing the timezone short
          abbreviations in DST and STD, respectively.
        * ``_hasdst``: Whether or not the zone has DST.

    .. versionadded:: 2.6.0
    cCstd��dS)Nz%tzrangebase is an abstract base class)�NotImplementedError)rrrr�__init__�sztzrangebase.__init__cCs*|j|�}|dkrdS|r |jS|jSdS)N)�_isdst�_dst_offset�_std_offset)rr�isdstrrrr&s
ztzrangebase.utcoffsetcCs(|j|�}|dkrdS|r |jStSdS)N)r2�_dst_base_offset�ZERO)rrr5rrrr)s
ztzrangebase.dstcCs|j|�r|jS|jSdS)N)r2Z	_dst_abbrZ	_std_abbr)rrrrr�tznames
ztzrangebase.tznamec
Cs�t|t�std��|j|k	r$td��|j|j�}|dkrF||j|�S|\}}||j8}||j8}||f}|j	dd�}|j
||�}|r�||j}n
||j}t|o�|j
|��}	t||	d�S)z, Given a datetime in UTC, return local time z&fromutc() requires a datetime argumentzdt.tzinfo is not selfN)r)r)rrr rr!�transitions�yearr&r4r�_naive_isdstr3r(r'r)
rrr9�dston�dstoffZutc_transitionsr*r5r+r,rrrr#s$




ztzrangebase.fromutccCsD|js
dS|j|j�\}}|jdd�}||ko>||jkSS)a6
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        FN)r)�hasdstr9r:rr6)rr�start�endrrrr'>s
ztzrangebase.is_ambiguouscCsj|js
dS|dkrdS|j|j�}|dkr.dS|jdd�}|j||�}|rb|j|�rb|j|�S|SdS)NF)r)r>r9r:rr;r'r,)rrr9r5rrrr2Tsztzrangebase._isdstcCsT|\}}|jdd�}||kr6||ko.|kn}n||koH|kn}|S)N)r)r)rrr9r<r=r5rrrr;isztzrangebase._naive_isdstcCs|j|jS)N)r3r4)rrrrr6usztzrangebase._dst_base_offsetNcCs
||kS)Nr)r�otherrrr�__ne__{sztzrangebase.__ne__cCsd|jjS)Nz%s(...))�	__class__r)rrrr�__repr__~sztzrangebase.__repr__)rrrrr1r&r)rr8r#r'r2r;rr6�__hash__rBrD�object�
__reduce__rrrrr/�s

!r/cCs|j|jdd|jdS)Ni�Qi@B)ZsecondsZdaysZmicroseconds)Ztdrrr�_total_seconds�srHZ
total_secondsN)r)r)Zsixr�	functoolsrrrrr7�__all__r�hasattrrrr$r%r/rHrrrrr�<module>s

v__pycache__/win.cpython-36.pyc000064400000022344150373450210012204 0ustar003

6�cY�,�@s�ddlZddlZddlmZddlmZyddlZddlmZWnek
r\e	d��YnXddl
mZdd	d
gZej
d�ZdZd
ZdZdd�Ze�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd	�d	e�Zdd�Zdd�ZdS)�N)�winreg)�	text_type)�wintypesz#Running tzwin on non-Windows system�)�tzrangebase�tzwin�
tzwinlocal�tzres�z7SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zonesz4SOFTWARE\Microsoft\Windows\CurrentVersion\Time Zonesz4SYSTEM\CurrentControlSet\Control\TimeZoneInformationcCsLtjdtj�}ytj|t�j�t}Wntk
r>t}YnX|j�|S)N)r�ConnectRegistry�HKEY_LOCAL_MACHINE�OpenKey�TZKEYNAMENTZCloseZWindowsError�TZKEYNAME9X)�handle�	TZKEYNAME�r�/usr/lib/python3.6/win.py�
_settzkeynames
rc@s6eZdZdZejej�Zd
dd�Z	dd�Z
dd�Zd	S)r	z{
    Class for accessing `tzres.dll`, which contains timezone name related
    resources.

    .. versionadded:: 2.5.0
    �	tzres.dllcCs@tjd�}tjtjtjtjf|j_|j|_tj|�|_	||_
dS)N�user32)�ctypesZWinDLLrZ	HINSTANCEZUINT�LPWSTRZc_int�LoadStringWZargtypes�_tzres�	tzres_loc)�selfrrrrr�__init__1s
ztzres.__init__cCs<|j�}tjtj|�tj�}|j|jj||d�}|d|�S)a�
        Load a timezone name from a DLL offset (integer).

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.load_name(112))
        'Eastern Standard Time'

        :param offset:
            A positive integer value referring to a string from the tzres dll.

        ..note:
            Offsets found in the registry are generally of the form
            `@tzres.dll,-114`. The offset in this case if 114, not -114.

        rN)	�p_wcharr�castZbyrefrrrrZ_handle)r�offsetZresourceZlpBufferZncharrrr�	load_name?sztzres.load_namec	CsH|jd�s|S|jd�}yt|d�}Wntd��YnX|j|�S)a�
        Parse strings as returned from the Windows registry into the time zone
        name as defined in the registry.

        >>> from dateutil.tzwin import tzres
        >>> tzr = tzres()
        >>> print(tzr.name_from_string('@tzres.dll,-251'))
        'Dateline Daylight Time'
        >>> print(tzr.name_from_string('Eastern Standard Time'))
        'Eastern Standard Time'

        :param tzname_str:
            A timezone name string as returned from a Windows registry key.

        :return:
            Returns the localized timezone string from tzres.dll if the string
            is of the form `@tzres.dll,-offset`, else returns the input string.
        �@z,-rzMalformed timezone string.)�
startswith�split�int�
ValueErrorr!)rZ
tzname_strZ	name_spltr rrr�name_from_stringUs

ztzres.name_from_stringN)r)�__name__�
__module__�__qualname__�__doc__rZPOINTERrZWCHARrrr!r'rrrrr	(s

c@sPeZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	dd
�Z
edd��ZdS)�	tzwinbasezBtzinfo class based on win32's timezones available in the registry.cCstd��dS)Nz#tzwinbase is an abstract base class)�NotImplementedError)rrrrrvsztzwinbase.__init__cCs�t|t�stS|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j	|j	ko�|j
|j
ko�|j|jko�|j|jko�|j
|j
ko�|j|jkS)N)�
isinstancer,�NotImplemented�_std_offset�_dst_offset�
_stddayofweek�
_dstdayofweek�_stdweeknumber�_dstweeknumber�_stdhour�_dsthour�
_stdminute�
_dstminute�	_std_abbr�	_dst_abbr)r�otherrrr�__eq__ys
ztzwinbase.__eq__csVtjdtj��>}tj|t��&��fdd�ttj��d�D�}WdQRXWdQRX|S)z4Return a list of all time zones known to the system.Ncsg|]}tj�|��qSr)rZEnumKey)�.0�i)�tzkeyrr�
<listcomp>�sz"tzwinbase.list.<locals>.<listcomp>r)rrrr
r�range�QueryInfoKey)r�resultr)r@r�list�s

*ztzwinbase.listcCs|jS)N)�_display)rrrr�display�sztzwinbase.displaycCsT|js
dSt||j|j|j|j|j�}t||j|j|j	|j
|j�}||j8}||fS)a�
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        N)
�hasdst�picknthweekday�	_dstmonthr3r7r9r5�	_stdmonthr2r6r8r4�_dst_base_offset)r�yearZdstonZdstoffrrr�transitions�s
ztzwinbase.transitionscCs
|jdkS)Nr)rJ)rrrr�_get_hasdst�sztzwinbase._get_hasdstcCs|jS)N)�_dst_base_offset_)rrrrrL�sztzwinbase._dst_base_offsetN)
r(r)r*r+rr=�staticmethodrErGrNrO�propertyrLrrrrr,ts	r,c@s$eZdZdd�Zdd�Zdd�ZdS)rc	Cs||_tjdtj��8}td�jt|d�}tj||��}t|�}WdQRXWdQRX|d|_	|d|_
|d|_tj
d|d�}|d|d	}||d
}tj|d�|_tj|d�|_|dd
�\|_|_|_|_|_|dd�\|_|_|_|_|_|j|j|_|j�|_dS)Nz{kn}\{name})�kn�nameZStdZDlt�Displayz=3l16hZTZIrr�)�minutes��	��)�_namerrrr�formatrr
�valuestodictr:r;rF�struct�unpack�datetime�	timedeltar0r1rKr2r4r6r8rJr3r5r7r9rPrOrH)	rrTr�	tzkeynamer@�keydict�tup�	stdoffset�	dstoffsetrrrr�s"


  ztzwin.__init__cCsdt|j�S)Nz	tzwin(%s))�reprr\)rrrr�__repr__�sztzwin.__repr__cCs|j|jffS)N)�	__class__r\)rrrr�
__reduce__�sztzwin.__reduce__N)r(r)r*rrirkrrrrr�s&c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rc
 Csntjdtj���}tj|t��}t|�}WdQRX|d|_|d|_yBtd�j	t
|jd�}tj||��}t|�}|d|_WdQRXWntk
r�d|_YnXWdQRX|d|d}||d}t
j|d	�|_t
j|d	�|_tjd
|d�}	|	dd
�\|_|_|_|_|	d|_tjd
|d�}	|	dd
�\|_|_|_|_|	d|_|j|j|_|j�|_dS)NZStandardNameZDaylightNamez	{kn}\{sn})rSZsnrUZBiasZStandardBiasZDaylightBias)rWz=8hZ
StandardStartr�r
Z
DaylightStart) rrrr
�TZLOCALKEYNAMEr^r:r;rr]rrF�OSErrorrarbr0r1r_r`rKr4r6r8r2rJr5r7r9r3rPrOrH)
rrZ
tzlocalkeyrdrcr@Z_keydictrfrgrerrrr�s2





ztzwinlocal.__init__cCsdS)Nztzwinlocal()r)rrrrrisztzwinlocal.__repr__cCsdt|j�S)Nztzwinlocal(%s))rhr:)rrrr�__str__sztzwinlocal.__str__cCs
|jffS)N)rj)rrrrrk#sztzwinlocal.__reduce__N)r(r)r*rrirorkrrrrr�s.c	CsTtj||d||�}|j||j�ddd�}||dt}|j|krP|t8}|S)z> dayofweek == 0 means Sunday, whichweek 5 means last instance rr
)Zday)ra�replaceZ
isoweekday�ONEWEEK�month)	rMrrZ	dayofweekZhourZminuteZ	whichweek�firstZ
weekdayoneZwdrrrrI's
rIcCs�i}tj|�d}d}x�t|�D]v}tj||�\}}}|tjksJ|tjkr\|d@r�|d}n2|tjkr�|jd�r�|pxt�}|j	|�}|j
d�}|||<q W|S)	z0Convert a registry key's values to a dictionary.rN�� z@tzres�ll)rrCrBZ	EnumValueZ	REG_DWORDZREG_DWORD_LITTLE_ENDIANZREG_SZr#r	r'�rstrip)�keyZdout�sizeZtz_resr?Zkey_name�valueZdtyperrrr^5s





r^)rar_Z	six.movesrZsixrrrr&�ImportErrorZ_commonr�__all__rbrqrrrmrr�objectr	r,rrrIr^rrrr�<module>s,

LJ/:__pycache__/__init__.cpython-36.pyc000064400000000462150373450210013143 0ustar003

6�cY��
@s*ddlTdddddddd	d
ddd
dg
ZdS)�)�*ZtzutcZtzoffsetZtzlocalZtzfileZtzrangeZtzstrZtzicalZtzwinZ
tzwinlocalZgettzZenfoldZdatetime_ambiguousZdatetime_existsN)Ztz�__all__�rr�/usr/lib/python3.6/__init__.py�<module>s

__pycache__/__init__.cpython-36.opt-1.pyc000064400000000462150373450210014102 0ustar003

6�cY��
@s*ddlTdddddddd	d
ddd
dg
ZdS)�)�*ZtzutcZtzoffsetZtzlocalZtzfileZtzrangeZtzstrZtzicalZtzwinZ
tzwinlocalZgettzZenfoldZdatetime_ambiguousZdatetime_existsN)Ztz�__all__�rr�/usr/lib/python3.6/__init__.py�<module>s

tz.py000064400000142622150373450210005562 0ustar00# -*- coding: utf-8 -*-
"""
This module offers timezone implementations subclassing the abstract
:py:`datetime.tzinfo` type. There are classes to handle tzfile format files
(usually are in :file:`/etc/localtime`, :file:`/usr/share/zoneinfo`, etc), TZ
environment string (in all known formats), given ranges (with help from
relative deltas), local machine timezone, fixed offset timezone, and UTC
timezone.
"""
import datetime
import struct
import time
import sys
import os
import bisect

from six import string_types
from ._common import tzname_in_python2, _tzinfo, _total_seconds
from ._common import tzrangebase, enfold
from ._common import _validate_fromutc_inputs

try:
    from .win import tzwin, tzwinlocal
except ImportError:
    tzwin = tzwinlocal = None

ZERO = datetime.timedelta(0)
EPOCH = datetime.datetime.utcfromtimestamp(0)
EPOCHORDINAL = EPOCH.toordinal()


class tzutc(datetime.tzinfo):
    """
    This is a tzinfo object that represents the UTC time zone.
    """
    def utcoffset(self, dt):
        return ZERO

    def dst(self, dt):
        return ZERO

    @tzname_in_python2
    def tzname(self, dt):
        return "UTC"

    def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """
        return False

    @_validate_fromutc_inputs
    def fromutc(self, dt):
        """
        Fast track version of fromutc() returns the original ``dt`` object for
        any valid :py:class:`datetime.datetime` object.
        """
        return dt

    def __eq__(self, other):
        if not isinstance(other, (tzutc, tzoffset)):
            return NotImplemented

        return (isinstance(other, tzutc) or
                (isinstance(other, tzoffset) and other._offset == ZERO))

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __repr__(self):
        return "%s()" % self.__class__.__name__

    __reduce__ = object.__reduce__


class tzoffset(datetime.tzinfo):
    """
    A simple class for representing a fixed offset from UTC.

    :param name:
        The timezone name, to be returned when ``tzname()`` is called.

    :param offset:
        The time zone offset in seconds, or (since version 2.6.0, represented
        as a :py:class:`datetime.timedelta` object.
    """
    def __init__(self, name, offset):
        self._name = name

        try:
            # Allow a timedelta
            offset = _total_seconds(offset)
        except (TypeError, AttributeError):
            pass
        self._offset = datetime.timedelta(seconds=offset)

    def utcoffset(self, dt):
        return self._offset

    def dst(self, dt):
        return ZERO

    @tzname_in_python2
    def tzname(self, dt):
        return self._name

    @_validate_fromutc_inputs
    def fromutc(self, dt):
        return dt + self._offset

    def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """
        return False

    def __eq__(self, other):
        if not isinstance(other, tzoffset):
            return NotImplemented

        return self._offset == other._offset

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __repr__(self):
        return "%s(%s, %s)" % (self.__class__.__name__,
                               repr(self._name),
                               int(_total_seconds(self._offset)))

    __reduce__ = object.__reduce__


class tzlocal(_tzinfo):
    """
    A :class:`tzinfo` subclass built around the ``time`` timezone functions.
    """
    def __init__(self):
        super(tzlocal, self).__init__()

        self._std_offset = datetime.timedelta(seconds=-time.timezone)
        if time.daylight:
            self._dst_offset = datetime.timedelta(seconds=-time.altzone)
        else:
            self._dst_offset = self._std_offset

        self._dst_saved = self._dst_offset - self._std_offset
        self._hasdst = bool(self._dst_saved)

    def utcoffset(self, dt):
        if dt is None and self._hasdst:
            return None

        if self._isdst(dt):
            return self._dst_offset
        else:
            return self._std_offset

    def dst(self, dt):
        if dt is None and self._hasdst:
            return None

        if self._isdst(dt):
            return self._dst_offset - self._std_offset
        else:
            return ZERO

    @tzname_in_python2
    def tzname(self, dt):
        return time.tzname[self._isdst(dt)]

    def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """
        naive_dst = self._naive_is_dst(dt)
        return (not naive_dst and
                (naive_dst != self._naive_is_dst(dt - self._dst_saved)))

    def _naive_is_dst(self, dt):
        timestamp = _datetime_to_timestamp(dt)
        return time.localtime(timestamp + time.timezone).tm_isdst

    def _isdst(self, dt, fold_naive=True):
        # We can't use mktime here. It is unstable when deciding if
        # the hour near to a change is DST or not.
        #
        # timestamp = time.mktime((dt.year, dt.month, dt.day, dt.hour,
        #                         dt.minute, dt.second, dt.weekday(), 0, -1))
        # return time.localtime(timestamp).tm_isdst
        #
        # The code above yields the following result:
        #
        # >>> import tz, datetime
        # >>> t = tz.tzlocal()
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRDT'
        # >>> datetime.datetime(2003,2,16,0,tzinfo=t).tzname()
        # 'BRST'
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRST'
        # >>> datetime.datetime(2003,2,15,22,tzinfo=t).tzname()
        # 'BRDT'
        # >>> datetime.datetime(2003,2,15,23,tzinfo=t).tzname()
        # 'BRDT'
        #
        # Here is a more stable implementation:
        #
        if not self._hasdst:
            return False

        # Check for ambiguous times:
        dstval = self._naive_is_dst(dt)
        fold = getattr(dt, 'fold', None)

        if self.is_ambiguous(dt):
            if fold is not None:
                return not self._fold(dt)
            else:
                return True

        return dstval

    def __eq__(self, other):
        if not isinstance(other, tzlocal):
            return NotImplemented

        return (self._std_offset == other._std_offset and
                self._dst_offset == other._dst_offset)

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __repr__(self):
        return "%s()" % self.__class__.__name__

    __reduce__ = object.__reduce__


class _ttinfo(object):
    __slots__ = ["offset", "delta", "isdst", "abbr",
                 "isstd", "isgmt", "dstoffset"]

    def __init__(self):
        for attr in self.__slots__:
            setattr(self, attr, None)

    def __repr__(self):
        l = []
        for attr in self.__slots__:
            value = getattr(self, attr)
            if value is not None:
                l.append("%s=%s" % (attr, repr(value)))
        return "%s(%s)" % (self.__class__.__name__, ", ".join(l))

    def __eq__(self, other):
        if not isinstance(other, _ttinfo):
            return NotImplemented

        return (self.offset == other.offset and
                self.delta == other.delta and
                self.isdst == other.isdst and
                self.abbr == other.abbr and
                self.isstd == other.isstd and
                self.isgmt == other.isgmt and
                self.dstoffset == other.dstoffset)

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __getstate__(self):
        state = {}
        for name in self.__slots__:
            state[name] = getattr(self, name, None)
        return state

    def __setstate__(self, state):
        for name in self.__slots__:
            if name in state:
                setattr(self, name, state[name])


class _tzfile(object):
    """
    Lightweight class for holding the relevant transition and time zone
    information read from binary tzfiles.
    """
    attrs = ['trans_list', 'trans_list_utc', 'trans_idx', 'ttinfo_list',
             'ttinfo_std', 'ttinfo_dst', 'ttinfo_before', 'ttinfo_first']

    def __init__(self, **kwargs):
        for attr in self.attrs:
            setattr(self, attr, kwargs.get(attr, None))


class tzfile(_tzinfo):
    """
    This is a ``tzinfo`` subclass thant allows one to use the ``tzfile(5)``
    format timezone files to extract current and historical zone information.

    :param fileobj:
        This can be an opened file stream or a file name that the time zone
        information can be read from.

    :param filename:
        This is an optional parameter specifying the source of the time zone
        information in the event that ``fileobj`` is a file object. If omitted
        and ``fileobj`` is a file stream, this parameter will be set either to
        ``fileobj``'s ``name`` attribute or to ``repr(fileobj)``.

    See `Sources for Time Zone and Daylight Saving Time Data
    <http://www.twinsun.com/tz/tz-link.htm>`_ for more information. Time zone
    files can be compiled from the `IANA Time Zone database files
    <https://www.iana.org/time-zones>`_ with the `zic time zone compiler
    <https://www.freebsd.org/cgi/man.cgi?query=zic&sektion=8>`_
    """

    def __init__(self, fileobj, filename=None):
        super(tzfile, self).__init__()

        file_opened_here = False
        if isinstance(fileobj, string_types):
            self._filename = fileobj
            fileobj = open(fileobj, 'rb')
            file_opened_here = True
        elif filename is not None:
            self._filename = filename
        elif hasattr(fileobj, "name"):
            self._filename = fileobj.name
        else:
            self._filename = repr(fileobj)

        if fileobj is not None:
            if not file_opened_here:
                fileobj = _ContextWrapper(fileobj)

            with fileobj as file_stream:
                tzobj = self._read_tzfile(file_stream)

            self._set_tzdata(tzobj)

    def _set_tzdata(self, tzobj):
        """ Set the time zone data of this object from a _tzfile object """
        # Copy the relevant attributes over as private attributes
        for attr in _tzfile.attrs:
            setattr(self, '_' + attr, getattr(tzobj, attr))

    def _read_tzfile(self, fileobj):
        out = _tzfile()

        # From tzfile(5):
        #
        # The time zone information files used by tzset(3)
        # begin with the magic characters "TZif" to identify
        # them as time zone information files, followed by
        # sixteen bytes reserved for future use, followed by
        # six four-byte values of type long, written in a
        # ``standard'' byte order (the high-order  byte
        # of the value is written first).
        if fileobj.read(4).decode() != "TZif":
            raise ValueError("magic not found")

        fileobj.read(16)

        (
            # The number of UTC/local indicators stored in the file.
            ttisgmtcnt,

            # The number of standard/wall indicators stored in the file.
            ttisstdcnt,

            # The number of leap seconds for which data is
            # stored in the file.
            leapcnt,

            # The number of "transition times" for which data
            # is stored in the file.
            timecnt,

            # The number of "local time types" for which data
            # is stored in the file (must not be zero).
            typecnt,

            # The  number  of  characters  of "time zone
            # abbreviation strings" stored in the file.
            charcnt,

        ) = struct.unpack(">6l", fileobj.read(24))

        # The above header is followed by tzh_timecnt four-byte
        # values  of  type long,  sorted  in ascending order.
        # These values are written in ``standard'' byte order.
        # Each is used as a transition time (as  returned  by
        # time(2)) at which the rules for computing local time
        # change.

        if timecnt:
            out.trans_list_utc = list(struct.unpack(">%dl" % timecnt,
                                                    fileobj.read(timecnt*4)))
        else:
            out.trans_list_utc = []

        # Next come tzh_timecnt one-byte values of type unsigned
        # char; each one tells which of the different types of
        # ``local time'' types described in the file is associated
        # with the same-indexed transition time. These values
        # serve as indices into an array of ttinfo structures that
        # appears next in the file.

        if timecnt:
            out.trans_idx = struct.unpack(">%dB" % timecnt,
                                            fileobj.read(timecnt))
        else:
            out.trans_idx = []

        # Each ttinfo structure is written as a four-byte value
        # for tt_gmtoff  of  type long,  in  a  standard  byte
        # order, followed  by a one-byte value for tt_isdst
        # and a one-byte  value  for  tt_abbrind.   In  each
        # structure, tt_gmtoff  gives  the  number  of
        # seconds to be added to UTC, tt_isdst tells whether
        # tm_isdst should be set by  localtime(3),  and
        # tt_abbrind serves  as an index into the array of
        # time zone abbreviation characters that follow the
        # ttinfo structure(s) in the file.

        ttinfo = []

        for i in range(typecnt):
            ttinfo.append(struct.unpack(">lbb", fileobj.read(6)))

        abbr = fileobj.read(charcnt).decode()

        # Then there are tzh_leapcnt pairs of four-byte
        # values, written in  standard byte  order;  the
        # first  value  of  each pair gives the time (as
        # returned by time(2)) at which a leap second
        # occurs;  the  second  gives the  total  number of
        # leap seconds to be applied after the given time.
        # The pairs of values are sorted in ascending order
        # by time.

        # Not used, for now (but seek for correct file position)
        if leapcnt:
            fileobj.seek(leapcnt * 8, os.SEEK_CUR)

        # Then there are tzh_ttisstdcnt standard/wall
        # indicators, each stored as a one-byte value;
        # they tell whether the transition times associated
        # with local time types were specified as standard
        # time or wall clock time, and are used when
        # a time zone file is used in handling POSIX-style
        # time zone environment variables.

        if ttisstdcnt:
            isstd = struct.unpack(">%db" % ttisstdcnt,
                                  fileobj.read(ttisstdcnt))

        # Finally, there are tzh_ttisgmtcnt UTC/local
        # indicators, each stored as a one-byte value;
        # they tell whether the transition times associated
        # with local time types were specified as UTC or
        # local time, and are used when a time zone file
        # is used in handling POSIX-style time zone envi-
        # ronment variables.

        if ttisgmtcnt:
            isgmt = struct.unpack(">%db" % ttisgmtcnt,
                                  fileobj.read(ttisgmtcnt))

        # Build ttinfo list
        out.ttinfo_list = []
        for i in range(typecnt):
            gmtoff, isdst, abbrind = ttinfo[i]
            # Round to full-minutes if that's not the case. Python's
            # datetime doesn't accept sub-minute timezones. Check
            # http://python.org/sf/1447945 for some information.
            gmtoff = 60 * ((gmtoff + 30) // 60)
            tti = _ttinfo()
            tti.offset = gmtoff
            tti.dstoffset = datetime.timedelta(0)
            tti.delta = datetime.timedelta(seconds=gmtoff)
            tti.isdst = isdst
            tti.abbr = abbr[abbrind:abbr.find('\x00', abbrind)]
            tti.isstd = (ttisstdcnt > i and isstd[i] != 0)
            tti.isgmt = (ttisgmtcnt > i and isgmt[i] != 0)
            out.ttinfo_list.append(tti)

        # Replace ttinfo indexes for ttinfo objects.
        out.trans_idx = [out.ttinfo_list[idx] for idx in out.trans_idx]

        # Set standard, dst, and before ttinfos. before will be
        # used when a given time is before any transitions,
        # and will be set to the first non-dst ttinfo, or to
        # the first dst, if all of them are dst.
        out.ttinfo_std = None
        out.ttinfo_dst = None
        out.ttinfo_before = None
        if out.ttinfo_list:
            if not out.trans_list_utc:
                out.ttinfo_std = out.ttinfo_first = out.ttinfo_list[0]
            else:
                for i in range(timecnt-1, -1, -1):
                    tti = out.trans_idx[i]
                    if not out.ttinfo_std and not tti.isdst:
                        out.ttinfo_std = tti
                    elif not out.ttinfo_dst and tti.isdst:
                        out.ttinfo_dst = tti

                    if out.ttinfo_std and out.ttinfo_dst:
                        break
                else:
                    if out.ttinfo_dst and not out.ttinfo_std:
                        out.ttinfo_std = out.ttinfo_dst

                for tti in out.ttinfo_list:
                    if not tti.isdst:
                        out.ttinfo_before = tti
                        break
                else:
                    out.ttinfo_before = out.ttinfo_list[0]

        # Now fix transition times to become relative to wall time.
        #
        # I'm not sure about this. In my tests, the tz source file
        # is setup to wall time, and in the binary file isstd and
        # isgmt are off, so it should be in wall time. OTOH, it's
        # always in gmt time. Let me know if you have comments
        # about this.
        laststdoffset = None
        out.trans_list = []
        for i, tti in enumerate(out.trans_idx):
            if not tti.isdst:
                offset = tti.offset
                laststdoffset = offset
            else:
                if laststdoffset is not None:
                    # Store the DST offset as well and update it in the list
                    tti.dstoffset = tti.offset - laststdoffset
                    out.trans_idx[i] = tti

                offset = laststdoffset or 0

            out.trans_list.append(out.trans_list_utc[i] + offset)

        # In case we missed any DST offsets on the way in for some reason, make
        # a second pass over the list, looking for the /next/ DST offset.
        laststdoffset = None
        for i in reversed(range(len(out.trans_idx))):
            tti = out.trans_idx[i]
            if tti.isdst:
                if not (tti.dstoffset or laststdoffset is None):
                    tti.dstoffset = tti.offset - laststdoffset
            else:
                laststdoffset = tti.offset

            if not isinstance(tti.dstoffset, datetime.timedelta):
                tti.dstoffset = datetime.timedelta(seconds=tti.dstoffset)

            out.trans_idx[i] = tti

        out.trans_idx = tuple(out.trans_idx)
        out.trans_list = tuple(out.trans_list)
        out.trans_list_utc = tuple(out.trans_list_utc)

        return out

    def _find_last_transition(self, dt, in_utc=False):
        # If there's no list, there are no transitions to find
        if not self._trans_list:
            return None

        timestamp = _datetime_to_timestamp(dt)

        # Find where the timestamp fits in the transition list - if the
        # timestamp is a transition time, it's part of the "after" period.
        trans_list = self._trans_list_utc if in_utc else self._trans_list
        idx = bisect.bisect_right(trans_list, timestamp)

        # We want to know when the previous transition was, so subtract off 1
        return idx - 1        

    def _get_ttinfo(self, idx):
        # For no list or after the last transition, default to _ttinfo_std
        if idx is None or (idx + 1) >= len(self._trans_list):
            return self._ttinfo_std

        # If there is a list and the time is before it, return _ttinfo_before
        if idx < 0:
            return self._ttinfo_before

        return self._trans_idx[idx]

    def _find_ttinfo(self, dt):
        idx = self._resolve_ambiguous_time(dt)

        return self._get_ttinfo(idx)

    def fromutc(self, dt):
        """
        The ``tzfile`` implementation of :py:func:`datetime.tzinfo.fromutc`.

        :param dt:
            A :py:class:`datetime.datetime` object.

        :raises TypeError:
            Raised if ``dt`` is not a :py:class:`datetime.datetime` object.

        :raises ValueError:
            Raised if this is called with a ``dt`` which does not have this
            ``tzinfo`` attached.

        :return:
            Returns a :py:class:`datetime.datetime` object representing the
            wall time in ``self``'s time zone.
        """
        # These isinstance checks are in datetime.tzinfo, so we'll preserve
        # them, even if we don't care about duck typing.
        if not isinstance(dt, datetime.datetime):
            raise TypeError("fromutc() requires a datetime argument")

        if dt.tzinfo is not self:
            raise ValueError("dt.tzinfo is not self")

        # First treat UTC as wall time and get the transition we're in.
        idx = self._find_last_transition(dt, in_utc=True)
        tti = self._get_ttinfo(idx)

        dt_out = dt + datetime.timedelta(seconds=tti.offset)

        fold = self.is_ambiguous(dt_out, idx=idx)

        return enfold(dt_out, fold=int(fold))

    def is_ambiguous(self, dt, idx=None):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """
        if idx is None:
            idx = self._find_last_transition(dt)

        # Calculate the difference in offsets from current to previous
        timestamp = _datetime_to_timestamp(dt)
        tti = self._get_ttinfo(idx)

        if idx is None or idx <= 0:
            return False

        od = self._get_ttinfo(idx - 1).offset - tti.offset
        tt = self._trans_list[idx]          # Transition time

        return timestamp < tt + od

    def _resolve_ambiguous_time(self, dt):
        idx = self._find_last_transition(dt)

        # If we have no transitions, return the index
        _fold = self._fold(dt)
        if idx is None or idx == 0:
            return idx

        # If it's ambiguous and we're in a fold, shift to a different index.
        idx_offset = int(not _fold and self.is_ambiguous(dt, idx))

        return idx - idx_offset

    def utcoffset(self, dt):
        if dt is None:
            return None

        if not self._ttinfo_std:
            return ZERO

        return self._find_ttinfo(dt).delta

    def dst(self, dt):
        if dt is None:
            return None

        if not self._ttinfo_dst:
            return ZERO

        tti = self._find_ttinfo(dt)

        if not tti.isdst:
            return ZERO

        # The documentation says that utcoffset()-dst() must
        # be constant for every dt.
        return tti.dstoffset

    @tzname_in_python2
    def tzname(self, dt):
        if not self._ttinfo_std or dt is None:
            return None
        return self._find_ttinfo(dt).abbr

    def __eq__(self, other):
        if not isinstance(other, tzfile):
            return NotImplemented
        return (self._trans_list == other._trans_list and
                self._trans_idx == other._trans_idx and
                self._ttinfo_list == other._ttinfo_list)

    __hash__ = None

    def __ne__(self, other):
        return not (self == other)

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, repr(self._filename))

    def __reduce__(self):
        return self.__reduce_ex__(None)

    def __reduce_ex__(self, protocol):
        return (self.__class__, (None, self._filename), self.__dict__)


class tzrange(tzrangebase):
    """
    The ``tzrange`` object is a time zone specified by a set of offsets and
    abbreviations, equivalent to the way the ``TZ`` variable can be specified
    in POSIX-like systems, but using Python delta objects to specify DST
    start, end and offsets.

    :param stdabbr:
        The abbreviation for standard time (e.g. ``'EST'``).

    :param stdoffset:
        An integer or :class:`datetime.timedelta` object or equivalent
        specifying the base offset from UTC.

        If unspecified, +00:00 is used.

    :param dstabbr:
        The abbreviation for DST / "Summer" time (e.g. ``'EDT'``).

        If specified, with no other DST information, DST is assumed to occur
        and the default behavior or ``dstoffset``, ``start`` and ``end`` is
        used. If unspecified and no other DST information is specified, it
        is assumed that this zone has no DST.

        If this is unspecified and other DST information is *is* specified,
        DST occurs in the zone but the time zone abbreviation is left
        unchanged.

    :param dstoffset:
        A an integer or :class:`datetime.timedelta` object or equivalent
        specifying the UTC offset during DST. If unspecified and any other DST
        information is specified, it is assumed to be the STD offset +1 hour.

    :param start:
        A :class:`relativedelta.relativedelta` object or equivalent specifying
        the time and time of year that daylight savings time starts. To specify,
        for example, that DST starts at 2AM on the 2nd Sunday in March, pass:

            ``relativedelta(hours=2, month=3, day=1, weekday=SU(+2))``

        If unspecified and any other DST information is specified, the default
        value is 2 AM on the first Sunday in April.

    :param end:
        A :class:`relativedelta.relativedelta` object or equivalent representing
        the time and time of year that daylight savings time ends, with the
        same specification method as in ``start``. One note is that this should
        point to the first time in the *standard* zone, so if a transition
        occurs at 2AM in the DST zone and the clocks are set back 1 hour to 1AM,
        set the `hours` parameter to +1.


    **Examples:**

    .. testsetup:: tzrange

        from dateutil.tz import tzrange, tzstr

    .. doctest:: tzrange

        >>> tzstr('EST5EDT') == tzrange("EST", -18000, "EDT")
        True

        >>> from dateutil.relativedelta import *
        >>> range1 = tzrange("EST", -18000, "EDT")
        >>> range2 = tzrange("EST", -18000, "EDT", -14400,
        ...                  relativedelta(hours=+2, month=4, day=1,
        ...                                weekday=SU(+1)),
        ...                  relativedelta(hours=+1, month=10, day=31,
        ...                                weekday=SU(-1)))
        >>> tzstr('EST5EDT') == range1 == range2
        True

    """
    def __init__(self, stdabbr, stdoffset=None,
                 dstabbr=None, dstoffset=None,
                 start=None, end=None):

        global relativedelta
        from dateutil import relativedelta

        self._std_abbr = stdabbr
        self._dst_abbr = dstabbr

        try:
            stdoffset = _total_seconds(stdoffset)
        except (TypeError, AttributeError):
            pass

        try:
            dstoffset = _total_seconds(dstoffset)
        except (TypeError, AttributeError):
            pass

        if stdoffset is not None:
            self._std_offset = datetime.timedelta(seconds=stdoffset)
        else:
            self._std_offset = ZERO

        if dstoffset is not None:
            self._dst_offset = datetime.timedelta(seconds=dstoffset)
        elif dstabbr and stdoffset is not None:
            self._dst_offset = self._std_offset + datetime.timedelta(hours=+1)
        else:
            self._dst_offset = ZERO

        if dstabbr and start is None:
            self._start_delta = relativedelta.relativedelta(
                hours=+2, month=4, day=1, weekday=relativedelta.SU(+1))
        else:
            self._start_delta = start

        if dstabbr and end is None:
            self._end_delta = relativedelta.relativedelta(
                hours=+1, month=10, day=31, weekday=relativedelta.SU(-1))
        else:
            self._end_delta = end

        self._dst_base_offset_ = self._dst_offset - self._std_offset
        self.hasdst = bool(self._start_delta)

    def transitions(self, year):
        """
        For a given year, get the DST on and off transition times, expressed
        always on the standard time side. For zones with no transitions, this
        function returns ``None``.

        :param year:
            The year whose transitions you would like to query.

        :return:
            Returns a :class:`tuple` of :class:`datetime.datetime` objects,
            ``(dston, dstoff)`` for zones with an annual DST transition, or
            ``None`` for fixed offset zones.
        """
        if not self.hasdst:
            return None

        base_year = datetime.datetime(year, 1, 1)

        start = base_year + self._start_delta
        end = base_year + self._end_delta

        return (start, end)

    def __eq__(self, other):
        if not isinstance(other, tzrange):
            return NotImplemented

        return (self._std_abbr == other._std_abbr and
                self._dst_abbr == other._dst_abbr and
                self._std_offset == other._std_offset and
                self._dst_offset == other._dst_offset and
                self._start_delta == other._start_delta and
                self._end_delta == other._end_delta)

    @property
    def _dst_base_offset(self):
        return self._dst_base_offset_


class tzstr(tzrange):
    """
    ``tzstr`` objects are time zone objects specified by a time-zone string as
    it would be passed to a ``TZ`` variable on POSIX-style systems (see
    the `GNU C Library: TZ Variable`_ for more details).

    There is one notable exception, which is that POSIX-style time zones use an
    inverted offset format, so normally ``GMT+3`` would be parsed as an offset
    3 hours *behind* GMT. The ``tzstr`` time zone object will parse this as an
    offset 3 hours *ahead* of GMT. If you would like to maintain the POSIX
    behavior, pass a ``True`` value to ``posix_offset``.

    The :class:`tzrange` object provides the same functionality, but is
    specified using :class:`relativedelta.relativedelta` objects. rather than
    strings.

    :param s:
        A time zone string in ``TZ`` variable format. This can be a
        :class:`bytes` (2.x: :class:`str`), :class:`str` (2.x: :class:`unicode`)
        or a stream emitting unicode characters (e.g. :class:`StringIO`).

    :param posix_offset:
        Optional. If set to ``True``, interpret strings such as ``GMT+3`` or
        ``UTC+3`` as being 3 hours *behind* UTC rather than ahead, per the
        POSIX standard.

    .. _`GNU C Library: TZ Variable`:
        https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
    """
    def __init__(self, s, posix_offset=False):
        global parser
        from dateutil import parser

        self._s = s

        res = parser._parsetz(s)
        if res is None:
            raise ValueError("unknown string format")

        # Here we break the compatibility with the TZ variable handling.
        # GMT-3 actually *means* the timezone -3.
        if res.stdabbr in ("GMT", "UTC") and not posix_offset:
            res.stdoffset *= -1

        # We must initialize it first, since _delta() needs
        # _std_offset and _dst_offset set. Use False in start/end
        # to avoid building it two times.
        tzrange.__init__(self, res.stdabbr, res.stdoffset,
                         res.dstabbr, res.dstoffset,
                         start=False, end=False)

        if not res.dstabbr:
            self._start_delta = None
            self._end_delta = None
        else:
            self._start_delta = self._delta(res.start)
            if self._start_delta:
                self._end_delta = self._delta(res.end, isend=1)

        self.hasdst = bool(self._start_delta)

    def _delta(self, x, isend=0):
        from dateutil import relativedelta
        kwargs = {}
        if x.month is not None:
            kwargs["month"] = x.month
            if x.weekday is not None:
                kwargs["weekday"] = relativedelta.weekday(x.weekday, x.week)
                if x.week > 0:
                    kwargs["day"] = 1
                else:
                    kwargs["day"] = 31
            elif x.day:
                kwargs["day"] = x.day
        elif x.yday is not None:
            kwargs["yearday"] = x.yday
        elif x.jyday is not None:
            kwargs["nlyearday"] = x.jyday
        if not kwargs:
            # Default is to start on first sunday of april, and end
            # on last sunday of october.
            if not isend:
                kwargs["month"] = 4
                kwargs["day"] = 1
                kwargs["weekday"] = relativedelta.SU(+1)
            else:
                kwargs["month"] = 10
                kwargs["day"] = 31
                kwargs["weekday"] = relativedelta.SU(-1)
        if x.time is not None:
            kwargs["seconds"] = x.time
        else:
            # Default is 2AM.
            kwargs["seconds"] = 7200
        if isend:
            # Convert to standard time, to follow the documented way
            # of working with the extra hour. See the documentation
            # of the tzinfo class.
            delta = self._dst_offset - self._std_offset
            kwargs["seconds"] -= delta.seconds + delta.days * 86400
        return relativedelta.relativedelta(**kwargs)

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, repr(self._s))


class _tzicalvtzcomp(object):
    def __init__(self, tzoffsetfrom, tzoffsetto, isdst,
                 tzname=None, rrule=None):
        self.tzoffsetfrom = datetime.timedelta(seconds=tzoffsetfrom)
        self.tzoffsetto = datetime.timedelta(seconds=tzoffsetto)
        self.tzoffsetdiff = self.tzoffsetto - self.tzoffsetfrom
        self.isdst = isdst
        self.tzname = tzname
        self.rrule = rrule


class _tzicalvtz(_tzinfo):
    def __init__(self, tzid, comps=[]):
        super(_tzicalvtz, self).__init__()

        self._tzid = tzid
        self._comps = comps
        self._cachedate = []
        self._cachecomp = []

    def _find_comp(self, dt):
        if len(self._comps) == 1:
            return self._comps[0]

        dt = dt.replace(tzinfo=None)

        try:
            return self._cachecomp[self._cachedate.index((dt, self._fold(dt)))]
        except ValueError:
            pass

        lastcompdt = None
        lastcomp = None

        for comp in self._comps:
            compdt = self._find_compdt(comp, dt)

            if compdt and (not lastcompdt or lastcompdt < compdt):
                lastcompdt = compdt
                lastcomp = comp

        if not lastcomp:
            # RFC says nothing about what to do when a given
            # time is before the first onset date. We'll look for the
            # first standard component, or the first component, if
            # none is found.
            for comp in self._comps:
                if not comp.isdst:
                    lastcomp = comp
                    break
            else:
                lastcomp = comp[0]

        self._cachedate.insert(0, (dt, self._fold(dt)))
        self._cachecomp.insert(0, lastcomp)

        if len(self._cachedate) > 10:
            self._cachedate.pop()
            self._cachecomp.pop()

        return lastcomp

    def _find_compdt(self, comp, dt):
        if comp.tzoffsetdiff < ZERO and self._fold(dt):
            dt -= comp.tzoffsetdiff

        compdt = comp.rrule.before(dt, inc=True)

        return compdt

    def utcoffset(self, dt):
        if dt is None:
            return None

        return self._find_comp(dt).tzoffsetto

    def dst(self, dt):
        comp = self._find_comp(dt)
        if comp.isdst:
            return comp.tzoffsetdiff
        else:
            return ZERO

    @tzname_in_python2
    def tzname(self, dt):
        return self._find_comp(dt).tzname

    def __repr__(self):
        return "<tzicalvtz %s>" % repr(self._tzid)

    __reduce__ = object.__reduce__


class tzical(object):
    """
    This object is designed to parse an iCalendar-style ``VTIMEZONE`` structure
    as set out in `RFC 2445`_ Section 4.6.5 into one or more `tzinfo` objects.

    :param `fileobj`:
        A file or stream in iCalendar format, which should be UTF-8 encoded
        with CRLF endings.

    .. _`RFC 2445`: https://www.ietf.org/rfc/rfc2445.txt
    """
    def __init__(self, fileobj):
        global rrule
        from dateutil import rrule

        if isinstance(fileobj, string_types):
            self._s = fileobj
            # ical should be encoded in UTF-8 with CRLF
            fileobj = open(fileobj, 'r')
        else:
            self._s = getattr(fileobj, 'name', repr(fileobj))
            fileobj = _ContextWrapper(fileobj)

        self._vtz = {}

        with fileobj as fobj:
            self._parse_rfc(fobj.read())

    def keys(self):
        """
        Retrieves the available time zones as a list.
        """
        return list(self._vtz.keys())

    def get(self, tzid=None):
        """
        Retrieve a :py:class:`datetime.tzinfo` object by its ``tzid``.

        :param tzid:
            If there is exactly one time zone available, omitting ``tzid``
            or passing :py:const:`None` value returns it. Otherwise a valid
            key (which can be retrieved from :func:`keys`) is required.

        :raises ValueError:
            Raised if ``tzid`` is not specified but there are either more
            or fewer than 1 zone defined.

        :returns:
            Returns either a :py:class:`datetime.tzinfo` object representing
            the relevant time zone or :py:const:`None` if the ``tzid`` was
            not found.
        """
        if tzid is None:
            if len(self._vtz) == 0:
                raise ValueError("no timezones defined")
            elif len(self._vtz) > 1:
                raise ValueError("more than one timezone available")
            tzid = next(iter(self._vtz))

        return self._vtz.get(tzid)

    def _parse_offset(self, s):
        s = s.strip()
        if not s:
            raise ValueError("empty offset")
        if s[0] in ('+', '-'):
            signal = (-1, +1)[s[0] == '+']
            s = s[1:]
        else:
            signal = +1
        if len(s) == 4:
            return (int(s[:2]) * 3600 + int(s[2:]) * 60) * signal
        elif len(s) == 6:
            return (int(s[:2]) * 3600 + int(s[2:4]) * 60 + int(s[4:])) * signal
        else:
            raise ValueError("invalid offset: " + s)

    def _parse_rfc(self, s):
        lines = s.splitlines()
        if not lines:
            raise ValueError("empty string")

        # Unfold
        i = 0
        while i < len(lines):
            line = lines[i].rstrip()
            if not line:
                del lines[i]
            elif i > 0 and line[0] == " ":
                lines[i-1] += line[1:]
                del lines[i]
            else:
                i += 1

        tzid = None
        comps = []
        invtz = False
        comptype = None
        for line in lines:
            if not line:
                continue
            name, value = line.split(':', 1)
            parms = name.split(';')
            if not parms:
                raise ValueError("empty property name")
            name = parms[0].upper()
            parms = parms[1:]
            if invtz:
                if name == "BEGIN":
                    if value in ("STANDARD", "DAYLIGHT"):
                        # Process component
                        pass
                    else:
                        raise ValueError("unknown component: "+value)
                    comptype = value
                    founddtstart = False
                    tzoffsetfrom = None
                    tzoffsetto = None
                    rrulelines = []
                    tzname = None
                elif name == "END":
                    if value == "VTIMEZONE":
                        if comptype:
                            raise ValueError("component not closed: "+comptype)
                        if not tzid:
                            raise ValueError("mandatory TZID not found")
                        if not comps:
                            raise ValueError(
                                "at least one component is needed")
                        # Process vtimezone
                        self._vtz[tzid] = _tzicalvtz(tzid, comps)
                        invtz = False
                    elif value == comptype:
                        if not founddtstart:
                            raise ValueError("mandatory DTSTART not found")
                        if tzoffsetfrom is None:
                            raise ValueError(
                                "mandatory TZOFFSETFROM not found")
                        if tzoffsetto is None:
                            raise ValueError(
                                "mandatory TZOFFSETFROM not found")
                        # Process component
                        rr = None
                        if rrulelines:
                            rr = rrule.rrulestr("\n".join(rrulelines),
                                                compatible=True,
                                                ignoretz=True,
                                                cache=True)
                        comp = _tzicalvtzcomp(tzoffsetfrom, tzoffsetto,
                                              (comptype == "DAYLIGHT"),
                                              tzname, rr)
                        comps.append(comp)
                        comptype = None
                    else:
                        raise ValueError("invalid component end: "+value)
                elif comptype:
                    if name == "DTSTART":
                        rrulelines.append(line)
                        founddtstart = True
                    elif name in ("RRULE", "RDATE", "EXRULE", "EXDATE"):
                        rrulelines.append(line)
                    elif name == "TZOFFSETFROM":
                        if parms:
                            raise ValueError(
                                "unsupported %s parm: %s " % (name, parms[0]))
                        tzoffsetfrom = self._parse_offset(value)
                    elif name == "TZOFFSETTO":
                        if parms:
                            raise ValueError(
                                "unsupported TZOFFSETTO parm: "+parms[0])
                        tzoffsetto = self._parse_offset(value)
                    elif name == "TZNAME":
                        if parms:
                            raise ValueError(
                                "unsupported TZNAME parm: "+parms[0])
                        tzname = value
                    elif name == "COMMENT":
                        pass
                    else:
                        raise ValueError("unsupported property: "+name)
                else:
                    if name == "TZID":
                        if parms:
                            raise ValueError(
                                "unsupported TZID parm: "+parms[0])
                        tzid = value
                    elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"):
                        pass
                    else:
                        raise ValueError("unsupported property: "+name)
            elif name == "BEGIN" and value == "VTIMEZONE":
                tzid = None
                comps = []
                invtz = True

    def __repr__(self):
        return "%s(%s)" % (self.__class__.__name__, repr(self._s))


if sys.platform != "win32":
    TZFILES = ["/etc/localtime", "localtime"]
    TZPATHS = ["/usr/share/zoneinfo",
               "/usr/lib/zoneinfo",
               "/usr/share/lib/zoneinfo",
               "/etc/zoneinfo"]
else:
    TZFILES = []
    TZPATHS = []


def gettz(name=None):
    tz = None
    if not name:
        try:
            name = os.environ["TZ"]
        except KeyError:
            pass
    if name is None or name == ":":
        for filepath in TZFILES:
            if not os.path.isabs(filepath):
                filename = filepath
                for path in TZPATHS:
                    filepath = os.path.join(path, filename)
                    if os.path.isfile(filepath):
                        break
                else:
                    continue
            if os.path.isfile(filepath):
                try:
                    tz = tzfile(filepath)
                    break
                except (IOError, OSError, ValueError):
                    pass
        else:
            tz = tzlocal()
    else:
        if name.startswith(":"):
            name = name[:-1]
        if os.path.isabs(name):
            if os.path.isfile(name):
                tz = tzfile(name)
            else:
                tz = None
        else:
            for path in TZPATHS:
                filepath = os.path.join(path, name)
                if not os.path.isfile(filepath):
                    filepath = filepath.replace(' ', '_')
                    if not os.path.isfile(filepath):
                        continue
                try:
                    tz = tzfile(filepath)
                    break
                except (IOError, OSError, ValueError):
                    pass
            else:
                tz = None
                if tzwin is not None:
                    try:
                        tz = tzwin(name)
                    except WindowsError:
                        tz = None

                if not tz:
                    from dateutil.zoneinfo import get_zonefile_instance
                    tz = get_zonefile_instance().get(name)

                if not tz:
                    for c in name:
                        # name must have at least one offset to be a tzstr
                        if c in "0123456789":
                            try:
                                tz = tzstr(name)
                            except ValueError:
                                pass
                            break
                    else:
                        if name in ("GMT", "UTC"):
                            tz = tzutc()
                        elif name in time.tzname:
                            tz = tzlocal()
    return tz


def datetime_exists(dt, tz=None):
    """
    Given a datetime and a time zone, determine whether or not a given datetime
    would fall in a gap.

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" exists in ``tz``.
    """
    if tz is None:
        if dt.tzinfo is None:
            raise ValueError('Datetime is naive and no time zone provided.')
        tz = dt.tzinfo

    dt = dt.replace(tzinfo=None)

    # This is essentially a test of whether or not the datetime can survive
    # a round trip to UTC.
    dt_rt = dt.replace(tzinfo=tz).astimezone(tzutc()).astimezone(tz)
    dt_rt = dt_rt.replace(tzinfo=None)

    return dt == dt_rt


def datetime_ambiguous(dt, tz=None):
    """
    Given a datetime and a time zone, determine whether or not a given datetime
    is ambiguous (i.e if there are two times differentiated only by their DST
    status).

    :param dt:
        A :class:`datetime.datetime` (whose time zone will be ignored if ``tz``
        is provided.)

    :param tz:
        A :class:`datetime.tzinfo` with support for the ``fold`` attribute. If
        ``None`` or not provided, the datetime's own time zone will be used.

    :return:
        Returns a boolean value whether or not the "wall time" is ambiguous in
        ``tz``.

    .. versionadded:: 2.6.0
    """
    if tz is None:
        if dt.tzinfo is None:
            raise ValueError('Datetime is naive and no time zone provided.')

        tz = dt.tzinfo

    # If a time zone defines its own "is_ambiguous" function, we'll use that.
    is_ambiguous_fn = getattr(tz, 'is_ambiguous', None)
    if is_ambiguous_fn is not None:
        try:
            return tz.is_ambiguous(dt)
        except:
            pass

    # If it doesn't come out and tell us it's ambiguous, we'll just check if
    # the fold attribute has any effect on this particular date and time.
    dt = dt.replace(tzinfo=tz)
    wall_0 = enfold(dt, fold=0)
    wall_1 = enfold(dt, fold=1)

    same_offset = wall_0.utcoffset() == wall_1.utcoffset()
    same_dst = wall_0.dst() == wall_1.dst()

    return not (same_offset and same_dst)


def _datetime_to_timestamp(dt):
    """
    Convert a :class:`datetime.datetime` object to an epoch timestamp in seconds
    since January 1, 1970, ignoring the time zone.
    """
    return _total_seconds((dt.replace(tzinfo=None) - EPOCH))


class _ContextWrapper(object):
    """
    Class for wrapping contexts so that they are passed through in a
    with statement.
    """
    def __init__(self, context):
        self.context = context

    def __enter__(self):
        return self.context

    def __exit__(*args, **kwargs):
        pass

# vim:ts=4:sw=4:et