[Python-modules-commits] [tzlocal] 01/04: import tzlocal_1.2.orig.tar.gz

Brian May bam at moszumanska.debian.org
Thu Mar 24 01:44:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch master
in repository tzlocal.

commit 1791b2d2e661af8d03f6f29b6af02a9a4396d297
Author: Brian May <brian at linuxpenguins.xyz>
Date:   Thu Mar 24 10:53:08 2016 +1100

    import tzlocal_1.2.orig.tar.gz
---
 CHANGES.txt                                        |  73 +++
 LICENSE.txt                                        | 121 +++++
 MANIFEST.in                                        |   4 +
 PKG-INFO                                           | 179 +++++++
 README.rst                                         |  81 +++
 get_windows_info.py                                |  37 ++
 setup.cfg                                          |   8 +
 setup.py                                           |  36 ++
 tzlocal.egg-info/PKG-INFO                          | 179 +++++++
 tzlocal.egg-info/SOURCES.txt                       |  27 +
 tzlocal.egg-info/dependency_links.txt              |   1 +
 tzlocal.egg-info/pbr.json                          |   1 +
 tzlocal.egg-info/requires.txt                      |   1 +
 tzlocal.egg-info/top_level.txt                     |   1 +
 tzlocal.egg-info/zip-safe                          |   1 +
 tzlocal/__init__.py                                |   7 +
 tzlocal/darwin.py                                  |  27 +
 tzlocal/test_data/Harare                           | Bin 0 -> 157 bytes
 tzlocal/test_data/localtime/etc/localtime          | Bin 0 -> 157 bytes
 tzlocal/test_data/symlink_localtime/etc/localtime  |   1 +
 .../usr/share/zoneinfo/Africa/Harare               | Bin 0 -> 157 bytes
 tzlocal/test_data/timezone/etc/timezone            |   1 +
 .../test_data/timezone_setting/etc/conf.d/clock    |   1 +
 tzlocal/test_data/zone_setting/etc/sysconfig/clock |   1 +
 tzlocal/tests.py                                   |  70 +++
 tzlocal/unix.py                                    | 129 +++++
 tzlocal/win32.py                                   |  93 ++++
 tzlocal/windows_tz.py                              | 542 +++++++++++++++++++++
 28 files changed, 1622 insertions(+)

diff --git a/CHANGES.txt b/CHANGES.txt
new file mode 100644
index 0000000..2d872ff
--- /dev/null
+++ b/CHANGES.txt
@@ -0,0 +1,73 @@
+Changes
+=======
+
+1.2 (2015-06-14)
+----------------
+
+- Systemd stores no time zone name, forcing us to look at the name of the file
+  that localtime symlinks to. (cameris)
+
+
+1.1.2 (2014-10-18)
+------------------
+
+- Timezones that has 3 items did not work on Mac OS X.
+  (Marc Van Olmen)
+
+- Now doesn't fail if the TZ environment variable isn't an Olsen time zone.
+
+- Some timezones on Windows can apparently be empty (perhaps the are deleted).
+  Now these are ignored.
+  (Xiaokun Zhu)
+
+
+1.1.1 (2014-01-29)
+------------------
+
+- I forgot to add Etc/UTC as an alias for Etc/GMT.
+
+
+1.1 (2014-01-28)
+----------------
+
+- Adding better support for OS X.
+
+- Added support to map from tzdata/Olsen names to Windows names.
+  (Thanks to Benjamen Meyer).
+
+
+1.0 (2013-05-29)
+----------------
+
+- Fixed some more cases where spaces needs replacing with underscores.
+
+- Better handling of misconfigured /etc/timezone.
+
+- Better error message on Windows if we can't find a timezone at all.
+
+
+0.3 (2012-09-13)
+----------------
+
+- Windows 7 support.
+
+- Python 2.5 supported; because it only needed a __future__ import.
+
+- Python 3.3 tested, it worked.
+
+- Got rid of relative imports, because I don't actually like them,
+  so I don't know why I used them in the first place.
+
+- For each Windows zone, use the default zoneinfo zone, not the last one.
+
+
+0.2 (2012-09-12)
+----------------
+
+- Python 3 support.
+
+
+0.1 (2012-09-11)
+----------------
+
+- Initial release.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..0e259d4
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,121 @@
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+    LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+    ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+    INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+    REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+    PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+    THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+    HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+  i. the right to reproduce, adapt, distribute, perform, display,
+     communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+     likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+     subject to the limitations in paragraph 4(a), below;
+  v. rights protecting the extraction, dissemination, use and reuse of data
+     in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+     European Parliament and of the Council of 11 March 1996 on the legal
+     protection of databases, and under any national implementation
+     thereof, including any amended or successor version of such
+     directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+     world based on applicable law or treaty, and any national
+     implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+    surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+    warranties of any kind concerning the Work, express, implied,
+    statutory or otherwise, including without limitation warranties of
+    title, merchantability, fitness for a particular purpose, non
+    infringement, or the absence of latent or other defects, accuracy, or
+    the present or absence of errors, whether or not discoverable, all to
+    the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+    that may apply to the Work or any use thereof, including without
+    limitation any person's Copyright and Related Rights in the Work.
+    Further, Affirmer disclaims responsibility for obtaining any necessary
+    consents, permissions or other rights required for any use of the
+    Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+    party to this document and has no duty or obligation with respect to
+    this CC0 or use of the Work.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..f2bc65f
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,4 @@
+include *.py
+include *.rst
+include *.txt
+recursive-include tzlocal/test_data *
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..c570e40
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,179 @@
+Metadata-Version: 1.1
+Name: tzlocal
+Version: 1.2
+Summary: tzinfo object for the local timezone
+Home-page: https://github.com/regebro/tzlocal
+Author: Lennart Regebro
+Author-email: regebro at gmail.com
+License: CC0 1.0 Universal
+Description: tzlocal
+        =======
+        
+        This Python module returns a `tzinfo` object with the local timezone information under Unix and Win-32.
+        It requires `pytz`, and returns `pytz` `tzinfo` objects.
+        
+        This module attempts to fix a glaring hole in `pytz`, that there is no way to
+        get the local timezone information, unless you know the zoneinfo name, and
+        under several Linux distros that's hard or impossible to figure out.
+        
+        Also, with Windows different timezone system using pytz isn't of much use
+        unless you separately configure the zoneinfo timezone name.
+        
+        With `tzlocal` you only need to call `get_localzone()` and you will get a
+        `tzinfo` object with the local time zone info. On some Unices you will still
+        not get to know what the timezone name is, but you don't need that when you
+        have the tzinfo file. However, if the timezone name is readily available it
+        will be used.
+        
+        
+        Supported systems
+        -----------------
+        
+        These are the systems that are in theory supported:
+        
+         * Windows 2000 and later
+        
+         * Any unix-like system with a /etc/localtime or /usr/local/etc/localtime
+        
+        If you have one of the above systems and it does not work, it's a bug.
+        Please report it.
+        
+        
+        Usage
+        -----
+        
+        Load the local timezone:
+        
+            >>> from tzlocal import get_localzone
+            >>> tz = get_localzone()
+            >>> tz
+            <DstTzInfo 'Europe/Warsaw' WMT+1:24:00 STD>
+        
+        Create a local datetime:
+        
+            >>> from datetime import datetime
+            >>> dt = tz.localize(datetime(2015, 4, 10, 7, 22))
+            >>> dt
+            datetime.datetime(2015, 4, 10, 7, 22, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)
+        
+        Lookup another timezone with `pytz`:
+        
+            >>> import pytz
+            >>> eastern = pytz.timezone('US/Eastern')
+        
+        Convert the datetime:
+        
+            >>> dt.astimezone(eastern)
+            datetime.datetime(2015, 4, 10, 1, 2, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)
+        
+        
+        Maintainer
+        ----------
+        
+        * Lennart Regebro, regebro at gmail.com
+        
+        Contributors
+        ------------
+        
+        * Marc Van Olmen
+        * Benjamen Meyer
+        * Manuel Ebert
+        * Xiaokun Zhu
+        * Cameris
+        
+        (Sorry if I forgot someone)
+        
+        License
+        -------
+        
+        * CC0 1.0 Universal  http://creativecommons.org/publicdomain/zero/1.0/
+        
+        
+        Changes
+        =======
+        
+        1.2 (2015-06-14)
+        ----------------
+        
+        - Systemd stores no time zone name, forcing us to look at the name of the file
+          that localtime symlinks to. (cameris)
+        
+        
+        1.1.2 (2014-10-18)
+        ------------------
+        
+        - Timezones that has 3 items did not work on Mac OS X.
+          (Marc Van Olmen)
+        
+        - Now doesn't fail if the TZ environment variable isn't an Olsen time zone.
+        
+        - Some timezones on Windows can apparently be empty (perhaps the are deleted).
+          Now these are ignored.
+          (Xiaokun Zhu)
+        
+        
+        1.1.1 (2014-01-29)
+        ------------------
+        
+        - I forgot to add Etc/UTC as an alias for Etc/GMT.
+        
+        
+        1.1 (2014-01-28)
+        ----------------
+        
+        - Adding better support for OS X.
+        
+        - Added support to map from tzdata/Olsen names to Windows names.
+          (Thanks to Benjamen Meyer).
+        
+        
+        1.0 (2013-05-29)
+        ----------------
+        
+        - Fixed some more cases where spaces needs replacing with underscores.
+        
+        - Better handling of misconfigured /etc/timezone.
+        
+        - Better error message on Windows if we can't find a timezone at all.
+        
+        
+        0.3 (2012-09-13)
+        ----------------
+        
+        - Windows 7 support.
+        
+        - Python 2.5 supported; because it only needed a __future__ import.
+        
+        - Python 3.3 tested, it worked.
+        
+        - Got rid of relative imports, because I don't actually like them,
+          so I don't know why I used them in the first place.
+        
+        - For each Windows zone, use the default zoneinfo zone, not the last one.
+        
+        
+        0.2 (2012-09-12)
+        ----------------
+        
+        - Python 3 support.
+        
+        
+        0.1 (2012-09-11)
+        ----------------
+        
+        - Initial release.
+        
+Keywords: timezone pytz
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: Unix
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.1
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..2abe7ef
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,81 @@
+tzlocal
+=======
+
+This Python module returns a `tzinfo` object with the local timezone information under Unix and Win-32.
+It requires `pytz`, and returns `pytz` `tzinfo` objects.
+
+This module attempts to fix a glaring hole in `pytz`, that there is no way to
+get the local timezone information, unless you know the zoneinfo name, and
+under several Linux distros that's hard or impossible to figure out.
+
+Also, with Windows different timezone system using pytz isn't of much use
+unless you separately configure the zoneinfo timezone name.
+
+With `tzlocal` you only need to call `get_localzone()` and you will get a
+`tzinfo` object with the local time zone info. On some Unices you will still
+not get to know what the timezone name is, but you don't need that when you
+have the tzinfo file. However, if the timezone name is readily available it
+will be used.
+
+
+Supported systems
+-----------------
+
+These are the systems that are in theory supported:
+
+ * Windows 2000 and later
+
+ * Any unix-like system with a /etc/localtime or /usr/local/etc/localtime
+
+If you have one of the above systems and it does not work, it's a bug.
+Please report it.
+
+
+Usage
+-----
+
+Load the local timezone:
+
+    >>> from tzlocal import get_localzone
+    >>> tz = get_localzone()
+    >>> tz
+    <DstTzInfo 'Europe/Warsaw' WMT+1:24:00 STD>
+
+Create a local datetime:
+
+    >>> from datetime import datetime
+    >>> dt = tz.localize(datetime(2015, 4, 10, 7, 22))
+    >>> dt
+    datetime.datetime(2015, 4, 10, 7, 22, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)
+
+Lookup another timezone with `pytz`:
+
+    >>> import pytz
+    >>> eastern = pytz.timezone('US/Eastern')
+
+Convert the datetime:
+
+    >>> dt.astimezone(eastern)
+    datetime.datetime(2015, 4, 10, 1, 2, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)
+
+
+Maintainer
+----------
+
+* Lennart Regebro, regebro at gmail.com
+
+Contributors
+------------
+
+* Marc Van Olmen
+* Benjamen Meyer
+* Manuel Ebert
+* Xiaokun Zhu
+* Cameris
+
+(Sorry if I forgot someone)
+
+License
+-------
+
+* CC0 1.0 Universal  http://creativecommons.org/publicdomain/zero/1.0/
diff --git a/get_windows_info.py b/get_windows_info.py
new file mode 100644
index 0000000..daa3e85
--- /dev/null
+++ b/get_windows_info.py
@@ -0,0 +1,37 @@
+# This script generates the mapping between MS Windows timezone names and
+# tzdata/Olsen timezone names, by retrieving a file:
+# http://unicode.org/cldr/data/common/supplemental/supplementalData.xml
+# and parsing it, and from this generating the file windows_tz.py.
+#
+# It must be run with Python 3.
+
+XML_SOURCE = 'http://unicode.org/cldr/data/common/supplemental/windowsZones.xml'
+from urllib.request import urlopen
+from xml.dom import minidom
+from pprint import pprint
+
+source = urlopen(XML_SOURCE).read()
+dom = minidom.parseString(source)
+
+for element in dom.getElementsByTagName('mapTimezones'):
+    if element.getAttribute('type') == 'windows':
+        break
+
+win_tz = {}
+tz_win = {}
+for mapping in element.getElementsByTagName('mapZone'):
+    if mapping.getAttribute('territory') == '001':
+        win_tz[mapping.getAttribute('other')] = mapping.getAttribute('type').split(' ')[0]
+
+    for tz_name in mapping.getAttribute('type').split(' '):
+        tz_win[tz_name] = mapping.getAttribute('other')
+
+# Etc/UTC is a common alias for Etc/GMT:
+tz_win['Etc/UTC'] = 'UTC'
+
+with open('tzlocal/windows_tz.py', "wt") as out:
+    out.write("# This file is autogenerated by the get_windows_info.py script\n"
+              "# Do not edit.\nwin_tz = ")
+    pprint(win_tz, out)
+    out.write("\n# Old name for the win_tz variable:\ntz_names = win_tz\n\ntz_win = ")
+    pprint(tz_win, out)
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..bb23140
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,8 @@
+[check-manifest]
+ignore = spiny.conf
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..25e7170
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,36 @@
+from setuptools import setup, find_packages
+import sys, os
+
+version = '1.2'
+
+setup(name='tzlocal',
+      version=version,
+      description="tzinfo object for the local timezone",
+      long_description=open('README.rst', 'rt').read() + '\n\n' + open('CHANGES.txt', 'rt').read(),
+      classifiers=[
+          'Development Status :: 4 - Beta',
+          'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
+          'Operating System :: Microsoft :: Windows',
+          'Operating System :: Unix',
+          'Operating System :: MacOS :: MacOS X',
+          'Programming Language :: Python :: 2.5',
+          'Programming Language :: Python :: 2.6',
+          'Programming Language :: Python :: 2.7',
+          'Programming Language :: Python :: 3.1',
+          'Programming Language :: Python :: 3.2',
+          'Programming Language :: Python :: 3.3',
+          'Programming Language :: Python :: 3.4',
+          ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
+      keywords='timezone pytz',
+      author='Lennart Regebro',
+      author_email='regebro at gmail.com',
+      url='https://github.com/regebro/tzlocal',
+      license='CC0 1.0 Universal',
+      packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
+      include_package_data=True,
+      zip_safe=True,
+      install_requires=[
+          'pytz',
+      ],
+      test_suite='tzlocal.tests',
+      )
diff --git a/tzlocal.egg-info/PKG-INFO b/tzlocal.egg-info/PKG-INFO
new file mode 100644
index 0000000..c570e40
--- /dev/null
+++ b/tzlocal.egg-info/PKG-INFO
@@ -0,0 +1,179 @@
+Metadata-Version: 1.1
+Name: tzlocal
+Version: 1.2
+Summary: tzinfo object for the local timezone
+Home-page: https://github.com/regebro/tzlocal
+Author: Lennart Regebro
+Author-email: regebro at gmail.com
+License: CC0 1.0 Universal
+Description: tzlocal
+        =======
+        
+        This Python module returns a `tzinfo` object with the local timezone information under Unix and Win-32.
+        It requires `pytz`, and returns `pytz` `tzinfo` objects.
+        
+        This module attempts to fix a glaring hole in `pytz`, that there is no way to
+        get the local timezone information, unless you know the zoneinfo name, and
+        under several Linux distros that's hard or impossible to figure out.
+        
+        Also, with Windows different timezone system using pytz isn't of much use
+        unless you separately configure the zoneinfo timezone name.
+        
+        With `tzlocal` you only need to call `get_localzone()` and you will get a
+        `tzinfo` object with the local time zone info. On some Unices you will still
+        not get to know what the timezone name is, but you don't need that when you
+        have the tzinfo file. However, if the timezone name is readily available it
+        will be used.
+        
+        
+        Supported systems
+        -----------------
+        
+        These are the systems that are in theory supported:
+        
+         * Windows 2000 and later
+        
+         * Any unix-like system with a /etc/localtime or /usr/local/etc/localtime
+        
+        If you have one of the above systems and it does not work, it's a bug.
+        Please report it.
+        
+        
+        Usage
+        -----
+        
+        Load the local timezone:
+        
+            >>> from tzlocal import get_localzone
+            >>> tz = get_localzone()
+            >>> tz
+            <DstTzInfo 'Europe/Warsaw' WMT+1:24:00 STD>
+        
+        Create a local datetime:
+        
+            >>> from datetime import datetime
+            >>> dt = tz.localize(datetime(2015, 4, 10, 7, 22))
+            >>> dt
+            datetime.datetime(2015, 4, 10, 7, 22, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)
+        
+        Lookup another timezone with `pytz`:
+        
+            >>> import pytz
+            >>> eastern = pytz.timezone('US/Eastern')
+        
+        Convert the datetime:
+        
+            >>> dt.astimezone(eastern)
+            datetime.datetime(2015, 4, 10, 1, 2, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)
+        
+        
+        Maintainer
+        ----------
+        
+        * Lennart Regebro, regebro at gmail.com
+        
+        Contributors
+        ------------
+        
+        * Marc Van Olmen
+        * Benjamen Meyer
+        * Manuel Ebert
+        * Xiaokun Zhu
+        * Cameris
+        
+        (Sorry if I forgot someone)
+        
+        License
+        -------
+        
+        * CC0 1.0 Universal  http://creativecommons.org/publicdomain/zero/1.0/
+        
+        
+        Changes
+        =======
+        
+        1.2 (2015-06-14)
+        ----------------
+        
+        - Systemd stores no time zone name, forcing us to look at the name of the file
+          that localtime symlinks to. (cameris)
+        
+        
+        1.1.2 (2014-10-18)
+        ------------------
+        
+        - Timezones that has 3 items did not work on Mac OS X.
+          (Marc Van Olmen)
+        
+        - Now doesn't fail if the TZ environment variable isn't an Olsen time zone.
+        
+        - Some timezones on Windows can apparently be empty (perhaps the are deleted).
+          Now these are ignored.
+          (Xiaokun Zhu)
+        
+        
+        1.1.1 (2014-01-29)
+        ------------------
+        
+        - I forgot to add Etc/UTC as an alias for Etc/GMT.
+        
+        
+        1.1 (2014-01-28)
+        ----------------
+        
+        - Adding better support for OS X.
+        
+        - Added support to map from tzdata/Olsen names to Windows names.
+          (Thanks to Benjamen Meyer).
+        
+        
+        1.0 (2013-05-29)
+        ----------------
+        
+        - Fixed some more cases where spaces needs replacing with underscores.
+        
+        - Better handling of misconfigured /etc/timezone.
+        
+        - Better error message on Windows if we can't find a timezone at all.
+        
+        
+        0.3 (2012-09-13)
+        ----------------
+        
+        - Windows 7 support.
+        
+        - Python 2.5 supported; because it only needed a __future__ import.
+        
+        - Python 3.3 tested, it worked.
+        
+        - Got rid of relative imports, because I don't actually like them,
+          so I don't know why I used them in the first place.
+        
+        - For each Windows zone, use the default zoneinfo zone, not the last one.
+        
+        
+        0.2 (2012-09-12)
+        ----------------
+        
+        - Python 3 support.
+        
+        
+        0.1 (2012-09-11)
+        ----------------
+        
+        - Initial release.
+        
+Keywords: timezone pytz
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: Unix
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.1
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
diff --git a/tzlocal.egg-info/SOURCES.txt b/tzlocal.egg-info/SOURCES.txt
new file mode 100644
index 0000000..c71349e
--- /dev/null
+++ b/tzlocal.egg-info/SOURCES.txt
@@ -0,0 +1,27 @@
+CHANGES.txt
+LICENSE.txt
+MANIFEST.in
+README.rst
+get_windows_info.py
+setup.cfg
+setup.py
+tzlocal/__init__.py
+tzlocal/darwin.py
+tzlocal/tests.py
+tzlocal/unix.py
+tzlocal/win32.py
+tzlocal/windows_tz.py
+tzlocal.egg-info/PKG-INFO
+tzlocal.egg-info/SOURCES.txt
+tzlocal.egg-info/dependency_links.txt
+tzlocal.egg-info/pbr.json
+tzlocal.egg-info/requires.txt
+tzlocal.egg-info/top_level.txt
+tzlocal.egg-info/zip-safe
+tzlocal/test_data/Harare
+tzlocal/test_data/localtime/etc/localtime
+tzlocal/test_data/symlink_localtime/etc/localtime
+tzlocal/test_data/symlink_localtime/usr/share/zoneinfo/Africa/Harare
+tzlocal/test_data/timezone/etc/timezone
+tzlocal/test_data/timezone_setting/etc/conf.d/clock
+tzlocal/test_data/zone_setting/etc/sysconfig/clock
\ No newline at end of file
diff --git a/tzlocal.egg-info/dependency_links.txt b/tzlocal.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tzlocal.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/tzlocal.egg-info/pbr.json b/tzlocal.egg-info/pbr.json
new file mode 100644
index 0000000..ee6f674
--- /dev/null
+++ b/tzlocal.egg-info/pbr.json
@@ -0,0 +1 @@
+{"is_release": true, "git_version": "440ede1"}
\ No newline at end of file
diff --git a/tzlocal.egg-info/requires.txt b/tzlocal.egg-info/requires.txt
new file mode 100644
index 0000000..9850437
--- /dev/null
+++ b/tzlocal.egg-info/requires.txt
@@ -0,0 +1 @@
+pytz
\ No newline at end of file
diff --git a/tzlocal.egg-info/top_level.txt b/tzlocal.egg-info/top_level.txt
new file mode 100644
index 0000000..cd5e9b1
--- /dev/null
+++ b/tzlocal.egg-info/top_level.txt
@@ -0,0 +1 @@
+tzlocal
diff --git a/tzlocal.egg-info/zip-safe b/tzlocal.egg-info/zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/tzlocal.egg-info/zip-safe
@@ -0,0 +1 @@
+
diff --git a/tzlocal/__init__.py b/tzlocal/__init__.py
new file mode 100644
index 0000000..df7a66b
--- /dev/null
+++ b/tzlocal/__init__.py
@@ -0,0 +1,7 @@
+import sys
+if sys.platform == 'win32':
+    from tzlocal.win32 import get_localzone, reload_localzone
+elif 'darwin' in sys.platform:
+    from tzlocal.darwin import get_localzone, reload_localzone
+else:
+    from tzlocal.unix import get_localzone, reload_localzone
diff --git a/tzlocal/darwin.py b/tzlocal/darwin.py
new file mode 100644
index 0000000..86fd906
--- /dev/null
+++ b/tzlocal/darwin.py
@@ -0,0 +1,27 @@
+from __future__ import with_statement
+import os
+import pytz
+
+_cache_tz = None
+
+def _get_localzone():
+    tzname = os.popen("systemsetup -gettimezone").read().replace("Time Zone: ", "").strip()
+    if not tzname or tzname not in pytz.all_timezones_set:
+        # link will be something like /usr/share/zoneinfo/America/Los_Angeles.
+        link = os.readlink("/etc/localtime")
+        tzname = link[link.rfind("zoneinfo/") + 9:]
+    return pytz.timezone(tzname)
+
+def get_localzone():
+    """Get the computers configured local timezone, if any."""
+    global _cache_tz
+    if _cache_tz is None:
+        _cache_tz = _get_localzone()
+    return _cache_tz
+
+def reload_localzone():
+    """Reload the cached localzone. You need to call this if the timezone has changed."""
+    global _cache_tz
+    _cache_tz = _get_localzone()
+    return _cache_tz
+
diff --git a/tzlocal/test_data/Harare b/tzlocal/test_data/Harare
new file mode 100644
index 0000000..258b393
Binary files /dev/null and b/tzlocal/test_data/Harare differ
diff --git a/tzlocal/test_data/localtime/etc/localtime b/tzlocal/test_data/localtime/etc/localtime
new file mode 100644
index 0000000..258b393
Binary files /dev/null and b/tzlocal/test_data/localtime/etc/localtime differ
diff --git a/tzlocal/test_data/symlink_localtime/etc/localtime b/tzlocal/test_data/symlink_localtime/etc/localtime
new file mode 120000
index 0000000..2f01cab
--- /dev/null
+++ b/tzlocal/test_data/symlink_localtime/etc/localtime
@@ -0,0 +1 @@
+../usr/share/zoneinfo/Africa/Harare
\ No newline at end of file
diff --git a/tzlocal/test_data/symlink_localtime/usr/share/zoneinfo/Africa/Harare b/tzlocal/test_data/symlink_localtime/usr/share/zoneinfo/Africa/Harare
new file mode 100644
index 0000000..258b393
Binary files /dev/null and b/tzlocal/test_data/symlink_localtime/usr/share/zoneinfo/Africa/Harare differ
diff --git a/tzlocal/test_data/timezone/etc/timezone b/tzlocal/test_data/timezone/etc/timezone
new file mode 100644
index 0000000..28b3372
--- /dev/null
+++ b/tzlocal/test_data/timezone/etc/timezone
@@ -0,0 +1 @@
+Africa/Harare
diff --git a/tzlocal/test_data/timezone_setting/etc/conf.d/clock b/tzlocal/test_data/timezone_setting/etc/conf.d/clock
new file mode 100644
index 0000000..9503293
--- /dev/null
+++ b/tzlocal/test_data/timezone_setting/etc/conf.d/clock
@@ -0,0 +1 @@
+TIMEZONE = "Africa/Harare"
diff --git a/tzlocal/test_data/zone_setting/etc/sysconfig/clock b/tzlocal/test_data/zone_setting/etc/sysconfig/clock
new file mode 100644
index 0000000..e1ddbfd
--- /dev/null
+++ b/tzlocal/test_data/zone_setting/etc/sysconfig/clock
@@ -0,0 +1 @@
+ZONE="Africa/Harare"
diff --git a/tzlocal/tests.py b/tzlocal/tests.py
new file mode 100644
index 0000000..831738d
--- /dev/null
+++ b/tzlocal/tests.py
@@ -0,0 +1,70 @@
+import sys
+import os
+from datetime import datetime
+import unittest
+import pytz
+import tzlocal.unix
+
+class TzLocalTests(unittest.TestCase):
+
+    def test_env(self):
+        tz_harare = tzlocal.unix._tz_from_env(':Africa/Harare')
+        self.assertEqual(tz_harare.zone, 'Africa/Harare')
+
+        # Some Unices allow this as well, so we must allow it:
+        tz_harare = tzlocal.unix._tz_from_env('Africa/Harare')
+        self.assertEqual(tz_harare.zone, 'Africa/Harare')
+
+        local_path = os.path.split(__file__)[0]
+        tz_local = tzlocal.unix._tz_from_env(':' + os.path.join(local_path, 'test_data', 'Harare'))
+        self.assertEqual(tz_local.zone, 'local')
+        # Make sure the local timezone is the same as the Harare one above.
+        # We test this with a past date, so that we don't run into future changes
+        # of the Harare timezone.
+        dt = datetime(2012, 1, 1, 5)
+        self.assertEqual(tz_harare.localize(dt), tz_local.localize(dt))
+
+        # Non-zoneinfo timezones are not supported in the TZ environment.
... 825 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/tzlocal.git



More information about the Python-modules-commits mailing list