Hello community, here is the log from the commit of package python-tzlocal for openSUSE:Factory checked in at 2019-03-05 12:21:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tzlocal (Old) and /work/SRC/openSUSE:Factory/.python-tzlocal.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tzlocal" Tue Mar 5 12:21:47 2019 rev:7 rq:681301 version:1.5.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tzlocal/python-tzlocal.changes 2018-12-24 11:45:31.761232092 +0100 +++ /work/SRC/openSUSE:Factory/.python-tzlocal.new.28833/python-tzlocal.changes 2019-03-05 12:22:18.776896487 +0100 @@ -1,0 +2,12 @@ +Mon Mar 4 11:10:03 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Switch to github archive as per upstream recommendation: + * the pypi archive fails tests due to wrong file->symlink conversions +- Update to 1.5.1: + * increased test coverage. + * No longer treats macOS as special, but as a unix. + * get_windows_info.py is renamed to update_windows_mappings.py + * Windows mappings now also contain mappings from deprecated zoneinfo names. + (Preston-Landers, regebro) + +------------------------------------------------------------------- Old: ---- tzlocal-1.4.tar.gz New: ---- 1.5.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tzlocal.spec ++++++ --- /var/tmp/diff_new_pack.ucQ6er/_old 2019-03-05 12:22:19.596896237 +0100 +++ /var/tmp/diff_new_pack.ucQ6er/_new 2019-03-05 12:22:19.600896237 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-tzlocal # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,21 +19,20 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define modname tzlocal Name: python-%{modname} -Version: 1.4 +Version: 1.5.1 Release: 0 Summary: Provides tzinfo object for the local timezone License: MIT Group: Development/Libraries/Python -Url: https://github.com/regebro/%{modname} -Source: https://files.pythonhosted.org/packages/source/t/%{modname}/%{modname}-%{version}.tar.gz +URL: https://github.com/regebro/tzlocal +Source: https://github.com/regebro/tzlocal/archive/%{version}.tar.gz +BuildRequires: %{python_module mock} BuildRequires: %{python_module pytz} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-pytz -BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch - %python_subpackages %description @@ -66,9 +65,8 @@ %python_exec setup.py test %files %{python_files} -%defattr(-,root,root) %license LICENSE.txt -%doc README.rst MANIFEST.in CHANGES.txt PKG-INFO +%doc README.rst CHANGES.txt %{python_sitelib}/%{modname} %{python_sitelib}/%{modname}-%{version}-py%{py_ver}.egg-info ++++++ tzlocal-1.4.tar.gz -> 1.5.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/.gitignore new/tzlocal-1.5.1/.gitignore --- old/tzlocal-1.4/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/tzlocal-1.5.1/.gitignore 2017-12-01 10:37:45.000000000 +0100 @@ -0,0 +1,5 @@ +*.pyc +*.wpr +*.wpu +*.egg-info +*.egg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/.travis.yml new/tzlocal-1.5.1/.travis.yml --- old/tzlocal-1.4/.travis.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/tzlocal-1.5.1/.travis.yml 2017-12-01 10:37:45.000000000 +0100 @@ -0,0 +1,47 @@ +os: + - linux + - osx +language: python +python: + - "2.7" + - "3.5" + - "3.6" + - "nightly" # currently points to 3.7-dev +# command to run tests +install: +# Nothing needed +script: python setup.py test + +# osx Python installs must be run as generic language, because Python isn't +# installed. Also, the queue for their macs is long so let's just test 3.6. +matrix: + include: + - os: osx + language: generic + python: "3.6" + exclude: + - os: osx + +# Why travis can't include Python in the macOS builds is beyond me +before_install: | + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + brew update + # Per the `pyenv homebrew recommendations <https://github.com/yyuu/pyenv/wiki#suggested-build-environment>`_. + brew install openssl readline + # See https://docs.travis-ci.com/user/osx-ci-environment/#A-note-on-upgrading-packages. + # I didn't do this above because it works and I'm lazy. + brew outdated pyenv || brew upgrade pyenv + # virtualenv doesn't work without pyenv knowledge. venv in Python 3.3 + # doesn't provide Pip by default. So, use `pyenv-virtualenv <https://github.com/yyuu/pyenv-virtualenv/blob/master/README.md>`_. + brew install pyenv-virtualenv + pyenv install $PYTHON + # I would expect something like ``pyenv init; pyenv local $PYTHON`` or + # ``pyenv shell $PYTHON`` would work, but ``pyenv init`` doesn't seem to + # modify the Bash environment. ??? So, I hand-set the variables instead. + export PYENV_VERSION=$PYTHON + export PATH="/Users/travis/.pyenv/shims:${PATH}" + pyenv-virtualenv venv + source venv/bin/activate + # A manual check that the correct version of Python is running. + python --version + fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/CHANGES.txt new/tzlocal-1.5.1/CHANGES.txt --- old/tzlocal-1.4/CHANGES.txt 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/CHANGES.txt 2017-12-01 10:37:45.000000000 +0100 @@ -1,6 +1,24 @@ Changes ======= +1.5.1 (2017-12-01) +------------------ + +- 1.5 had a bug that slipped through testing, fixed that, + increased test coverage. + + +1.5 (2017-11-30) +---------------- + +- No longer treats macOS as special, but as a unix. + +- get_windows_info.py is renamed to update_windows_mappings.py + +- Windows mappings now also contain mappings from deprecated zoneinfo names. + (Preston-Landers, regebro) + + 1.4 (2017-04-18) ---------------- @@ -20,6 +38,9 @@ ------------------ - Ensure closing of subprocess on OS X (ayalash) +DOING: Implementing feedback on the unsubscribe button +DOING: Investigating remaining issues with DOCX export +BLOCKERS: None - Removed unused imports (jwilk) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/PKG-INFO new/tzlocal-1.5.1/PKG-INFO --- old/tzlocal-1.4/PKG-INFO 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,234 +0,0 @@ -Metadata-Version: 1.1 -Name: tzlocal -Version: 1.4 -Summary: tzinfo object for the local timezone -Home-page: https://github.com/regebro/tzlocal -Author: Lennart Regebro -Author-email: [email protected] -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, 22, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>) - - - Maintainer - ---------- - - * Lennart Regebro, [email protected] - - Contributors - ------------ - - * Marc Van Olmen - * Benjamen Meyer - * Manuel Ebert - * Xiaokun Zhu - * Cameris - * Edward Betts - * McK KIM - * Cris Ewing - * Ayala Shachar - * Lev Maximov - * Jakub Wilk - * John Quarles - - (Sorry if I forgot someone) - - License - ------- - - * CC0 1.0 Universal http://creativecommons.org/publicdomain/zero/1.0/ - - - Changes - ======= - - 1.4 (2017-04-18) - ---------------- - - - I use MIT on my other projects, so relicensing. - - - 1.4b1 (2017-04-14) - ------------------ - - - Dropping support for Python versions nobody uses (2.5, 3.1, 3.2), adding 3.6 - Python 3.1 and 3.2 still works, 2.5 has been broken for some time. - - - Ayalash's OS X fix didn't work on Python 2.7, fixed that. - - - 1.3.2 (2017-04-12) - ------------------ - - - Ensure closing of subprocess on OS X (ayalash) - - - Removed unused imports (jwilk) - - - Closes stdout and stderr to get rid of ResourceWarnings (johnwquarles) - - - Updated Windows timezones (axil) - - - 1.3 (2016-10-15) - ---------------- - - - #34: Added support for /var/db/zoneinfo - - - 1.2.2 (2016-03-02) - ------------------ - - - #30: Fixed a bug on OS X. - - - 1.2.1 (2016-02-28) - ------------------ - - - Tests failed if TZ was set in the environment. (EdwardBetts) - - - Replaces os.popen() with subprocess.Popen() for OS X to - handle when systemsetup doesn't exist. (mckabi, cewing) - - - 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 :: 5 - Production/Stable -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: Microsoft :: Windows -Classifier: Operating System :: Unix -Classifier: Operating System :: MacOS :: MacOS X -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/README.rst new/tzlocal-1.5.1/README.rst --- old/tzlocal-1.4/README.rst 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/README.rst 2017-12-01 10:37:45.000000000 +0100 @@ -79,10 +79,11 @@ * Lev Maximov * Jakub Wilk * John Quarles +* Preston Landers (Sorry if I forgot someone) License ------- -* CC0 1.0 Universal http://creativecommons.org/publicdomain/zero/1.0/ +* MIT https://opensource.org/licenses/MIT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/get_windows_info.py new/tzlocal-1.5.1/get_windows_info.py --- old/tzlocal-1.4/get_windows_info.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/get_windows_info.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,37 +0,0 @@ -# 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/setup.cfg new/tzlocal-1.5.1/setup.cfg --- old/tzlocal-1.4/setup.cfg 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/setup.cfg 2017-12-01 10:37:45.000000000 +0100 @@ -1,8 +1,2 @@ [check-manifest] -ignore = spiny.conf - -[egg_info] -tag_build = -tag_date = 0 -tag_svn_revision = 0 - +ignore=spiny.conf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/setup.py new/tzlocal-1.5.1/setup.py --- old/tzlocal-1.4/setup.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/setup.py 2017-12-01 10:37:45.000000000 +0100 @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -version = '1.4' +version = '1.5.1' setup(name='tzlocal', version=version, @@ -12,11 +12,8 @@ 'Operating System :: Microsoft :: Windows', 'Operating System :: Unix', 'Operating System :: MacOS :: MacOS X', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers @@ -24,12 +21,15 @@ author='Lennart Regebro', author_email='[email protected]', url='https://github.com/regebro/tzlocal', - license='CC0 1.0 Universal', + license="MIT", packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=True, install_requires=[ 'pytz', ], + tests_require=[ + 'mock', + ], test_suite='tzlocal.tests', ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/spiny.conf new/tzlocal-1.5.1/spiny.conf --- old/tzlocal-1.4/spiny.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/tzlocal-1.5.1/spiny.conf 2017-12-01 10:37:45.000000000 +0100 @@ -0,0 +1,8 @@ +[spiny] +environments=python2.5 + python2.6 + python2.7 + python3.1 + python3.2 + python3.3 + python3.4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/__init__.py new/tzlocal-1.5.1/tzlocal/__init__.py --- old/tzlocal-1.4/tzlocal/__init__.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/__init__.py 2017-12-01 10:37:45.000000000 +0100 @@ -1,7 +1,5 @@ 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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/darwin.py new/tzlocal-1.5.1/tzlocal/darwin.py --- old/tzlocal-1.4/tzlocal/darwin.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/darwin.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,59 +0,0 @@ -from __future__ import with_statement -import os -import pytz -import subprocess -import sys - -_cache_tz = None - -if sys.version_info[0] == 2: - - class Popen(subprocess.Popen): - - def __enter__(self): - return self - - def __exit__(self, type, value, traceback): - if self.stdout: - self.stdout.close() - if self.stderr: - self.stderr.close() - if self.stdin: - self.stdin.close() - # Wait for the process to terminate, to avoid zombies. - self.wait() - -else: - from subprocess import Popen - - -def _get_localzone(_root='/'): - with Popen( - "systemsetup -gettimezone", - shell=True, - stderr=subprocess.PIPE, - stdout=subprocess.PIPE - ) as pipe: - tzname = pipe.stdout.read().replace(b'Time Zone: ', b'').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(os.path.join(_root, "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 -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/test_data/timezone/etc/timezone new/tzlocal-1.5.1/tzlocal/test_data/timezone/etc/timezone --- old/tzlocal-1.4/tzlocal/test_data/timezone/etc/timezone 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/test_data/timezone/etc/timezone 2017-12-01 10:37:45.000000000 +0100 @@ -1 +1 @@ -Africa/Harare +Africa/Harare# We allow comments. It's unusual, but has happened diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo new/tzlocal-1.5.1/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo --- old/tzlocal-1.4/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo 2017-12-01 10:37:45.000000000 +0100 @@ -1 +1 @@ -Africa/Harare +Africa/Harare localhost # The host is not a part of the format, but is allowed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/tests.py new/tzlocal-1.5.1/tzlocal/tests.py --- old/tzlocal-1.4/tzlocal/tests.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/tests.py 2017-12-01 10:37:45.000000000 +0100 @@ -1,10 +1,12 @@ -import sys +import mock import os -from datetime import datetime -import unittest import pytz +import sys import tzlocal.unix -import tzlocal.darwin +import unittest + +from datetime import datetime + class TzLocalTests(unittest.TestCase): def setUp(self): @@ -32,6 +34,16 @@ # Non-zoneinfo timezones are not supported in the TZ environment. self.assertRaises(pytz.UnknownTimeZoneError, tzlocal.unix._tz_from_env, 'GMT+03:00') + # Test the _try function + os.environ['TZ'] = 'Africa/Harare' + tz_harare = tzlocal.unix._try_tz_from_env() + self.assertEqual(tz_harare.zone, 'Africa/Harare') + # With a zone that doesn't exist + os.environ['TZ'] = 'Just Nonsense' + tz_harare = tzlocal.unix._try_tz_from_env() + self.assertIsNone(tz_harare) + + def test_timezone(self): # Most versions of Ubuntu @@ -63,18 +75,26 @@ self.assertEqual(tz.zone, 'Africa/Harare') def test_only_localtime(self): - tz = tzlocal.unix._get_localzone(_root=os.path.join(self.path, 'test_data', 'localtime')) self.assertEqual(tz.zone, 'local') dt = datetime(2012, 1, 1, 5) self.assertEqual(pytz.timezone('Africa/Harare').localize(dt), tz.localize(dt)) - def test_darwin(self): - # Basic test of OS X code. The systemcall will fail if this is not OS X - # And a symlink will be used. This means that on OS X, this test will - # actually fail! No matter, this exersizes the code. - tz = tzlocal.darwin._get_localzone(_root=os.path.join(self.path, 'test_data', 'symlink_localtime')) - self.assertEqual(tz.zone, 'Africa/Harare') + def test_get_reload(self): + os.environ['TZ'] = 'Africa/Harare' + tz_harare = tzlocal.unix.get_localzone() + self.assertEqual(tz_harare.zone, 'Africa/Harare') + # Changing the TZ makes no difference, because it's cached + os.environ['TZ'] = 'Africa/Johannesburg' + tz_harare = tzlocal.unix.get_localzone() + self.assertEqual(tz_harare.zone, 'Africa/Harare') + # So we reload it + tz_harare = tzlocal.unix.reload_localzone() + self.assertEqual(tz_harare.zone, 'Africa/Johannesburg') + + def test_fail(self): + with self.assertRaises(pytz.exceptions.UnknownTimeZoneError): + tz = tzlocal.unix._get_localzone(_root=os.path.join(self.path, 'test_data')) if sys.platform == 'win32': @@ -84,5 +104,31 @@ def test_win32(self): tzlocal.win32.get_localzone() +else: + + class TzWin32Tests(unittest.TestCase): + + def test_win32_on_unix(self): + # Yes, winreg is all mocked out, but this test means we at least + # catch syntax errors, etc. + winreg = mock.MagicMock() + winreg.OpenKey = mock.MagicMock() + winreg.OpenKey.close = mock.MagicMock() + winreg.QueryInfoKey = mock.MagicMock(return_value=(1, 1)) + winreg.EnumValue = mock.MagicMock( + return_value=('TimeZoneKeyName','Belarus Standard Time')) + winreg.EnumKey = mock.Mock(return_value='Bahia Standard Time') + sys.modules['winreg'] = winreg + import tzlocal.win32 + tz = tzlocal.win32.get_localzone() + self.assertEqual(tz.zone, 'Europe/Minsk') + + tzlocal.win32.valuestodict = mock.Mock(return_value={ + 'StandardName': 'Mocked Standard Time', + 'Std': 'Mocked Standard Time', + }) + tz = tzlocal.win32.reload_localzone() + self.assertEqual(tz.zone, 'America/Bahia') + if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/unix.py new/tzlocal-1.5.1/tzlocal/unix.py --- old/tzlocal-1.4/tzlocal/unix.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/unix.py 2017-12-01 10:37:45.000000000 +0100 @@ -1,4 +1,3 @@ -from __future__ import with_statement import os import re import pytz @@ -24,6 +23,16 @@ "tzlocal() does not support non-zoneinfo timezones like %s. \n" "Please use a timezone in the form of Continent/City") + +def _try_tz_from_env(): + tzenv = os.environ.get('TZ') + if tzenv: + try: + return _tz_from_env(tzenv) + except pytz.UnknownTimeZoneError: + pass + + def _get_localzone(_root='/'): """Tries to find the local timezone configuration. @@ -35,12 +44,9 @@ beneath the _root directory. This is primarily used by the tests. In normal usage you call the function without parameters.""" - tzenv = os.environ.get('TZ') + tzenv = _try_tz_from_env() if tzenv: - try: - return _tz_from_env(tzenv) - except pytz.UnknownTimeZoneError: - pass + return tzenv # Now look for distribution specific configuration files # that contain the timezone name. @@ -52,14 +58,16 @@ # Issue #3 was that /etc/timezone was a zoneinfo file. # That's a misconfiguration, but we need to handle it gracefully: - if data[:5] != 'TZif2': - etctz = data.strip().decode() - # Get rid of host definitions and comments: - if ' ' in etctz: - etctz, dummy = etctz.split(' ', 1) - if '#' in etctz: - etctz, dummy = etctz.split('#', 1) - return pytz.timezone(etctz.replace(' ', '_')) + if data[:5] == 'TZif2': + continue + + etctz = data.strip().decode() + # Get rid of host definitions and comments: + if ' ' in etctz: + etctz, dummy = etctz.split(' ', 1) + if '#' in etctz: + etctz, dummy = etctz.split('#', 1) + return pytz.timezone(etctz.replace(' ', '_')) # CentOS has a ZONE setting in /etc/sysconfig/clock, # OpenSUSE has a TIMEZONE setting in /etc/sysconfig/clock and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/win32.py new/tzlocal-1.5.1/tzlocal/win32.py --- old/tzlocal-1.4/tzlocal/win32.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/win32.py 2017-12-01 10:37:45.000000000 +0100 @@ -29,6 +29,7 @@ localtz = winreg.OpenKey(handle, TZLOCALKEYNAME) keyvalues = valuestodict(localtz) localtz.Close() + if 'TimeZoneKeyName' in keyvalues: # Windows 7 (and Vista?) @@ -91,3 +92,4 @@ """Reload the cached localzone. You need to call this if the timezone has changed.""" global _cache_tz _cache_tz = pytz.timezone(get_localzone_name()) + return _cache_tz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal/windows_tz.py new/tzlocal-1.5.1/tzlocal/windows_tz.py --- old/tzlocal-1.4/tzlocal/windows_tz.py 2017-04-18 18:51:44.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal/windows_tz.py 2017-12-01 10:37:45.000000000 +0100 @@ -1,4 +1,4 @@ -# This file is autogenerated by the get_windows_info.py script +# This file is autogenerated by the update_windows_mapping.py script # Do not edit. win_tz = {'AUS Central Standard Time': 'Australia/Darwin', 'AUS Eastern Standard Time': 'Australia/Sydney', @@ -63,6 +63,7 @@ 'Line Islands Standard Time': 'Pacific/Kiritimati', 'Lord Howe Standard Time': 'Australia/Lord_Howe', 'Magadan Standard Time': 'Asia/Magadan', + 'Magallanes Standard Time': 'America/Punta_Arenas', 'Marquesas Standard Time': 'Pacific/Marquesas', 'Mauritius Standard Time': 'Indian/Mauritius', 'Middle East Standard Time': 'Asia/Beirut', @@ -98,6 +99,7 @@ 'Saint Pierre Standard Time': 'America/Miquelon', 'Sakhalin Standard Time': 'Asia/Sakhalin', 'Samoa Standard Time': 'Pacific/Apia', + 'Saratov Standard Time': 'Europe/Saratov', 'Singapore Standard Time': 'Asia/Singapore', 'South Africa Standard Time': 'Africa/Johannesburg', 'Sri Lanka Standard Time': 'Asia/Colombo', @@ -115,6 +117,7 @@ 'US Mountain Standard Time': 'America/Phoenix', 'UTC': 'Etc/GMT', 'UTC+12': 'Etc/GMT-12', + 'UTC+13': 'Etc/GMT-13', 'UTC-02': 'Etc/GMT+2', 'UTC-08': 'Etc/GMT+8', 'UTC-09': 'Etc/GMT+9', @@ -183,6 +186,7 @@ 'Africa/Ouagadougou': 'Greenwich Standard Time', 'Africa/Porto-Novo': 'W. Central Africa Standard Time', 'Africa/Sao_Tome': 'Greenwich Standard Time', + 'Africa/Timbuktu': 'Greenwich Standard Time', 'Africa/Tripoli': 'Libya Standard Time', 'Africa/Tunis': 'W. Central Africa Standard Time', 'Africa/Windhoek': 'Namibia Standard Time', @@ -200,6 +204,7 @@ 'America/Argentina/Ushuaia': 'Argentina Standard Time', 'America/Aruba': 'SA Western Standard Time', 'America/Asuncion': 'Paraguay Standard Time', + 'America/Atka': 'Aleutian Standard Time', 'America/Bahia': 'Bahia Standard Time', 'America/Bahia_Banderas': 'Central Standard Time (Mexico)', 'America/Barbados': 'SA Western Standard Time', @@ -234,6 +239,7 @@ 'America/Edmonton': 'Mountain Standard Time', 'America/Eirunepe': 'SA Pacific Standard Time', 'America/El_Salvador': 'Central America Standard Time', + 'America/Ensenada': 'Pacific Standard Time (Mexico)', 'America/Fort_Nelson': 'US Mountain Standard Time', 'America/Fortaleza': 'SA Eastern Standard Time', 'America/Glace_Bay': 'Atlantic Standard Time', @@ -262,6 +268,7 @@ 'America/Jujuy': 'Argentina Standard Time', 'America/Juneau': 'Alaskan Standard Time', 'America/Kentucky/Monticello': 'Eastern Standard Time', + 'America/Knox_IN': 'Central Standard Time', 'America/Kralendijk': 'SA Western Standard Time', 'America/La_Paz': 'SA Western Standard Time', 'America/Lima': 'SA Pacific Standard Time', @@ -301,9 +308,10 @@ 'America/Phoenix': 'US Mountain Standard Time', 'America/Port-au-Prince': 'Haiti Standard Time', 'America/Port_of_Spain': 'SA Western Standard Time', + 'America/Porto_Acre': 'SA Pacific Standard Time', 'America/Porto_Velho': 'SA Western Standard Time', 'America/Puerto_Rico': 'SA Western Standard Time', - 'America/Punta_Arenas': 'SA Eastern Standard Time', + 'America/Punta_Arenas': 'Magallanes Standard Time', 'America/Rainy_River': 'Central Standard Time', 'America/Rankin_Inlet': 'Central Standard Time', 'America/Recife': 'SA Eastern Standard Time', @@ -316,6 +324,7 @@ 'America/Santo_Domingo': 'SA Western Standard Time', 'America/Sao_Paulo': 'E. South America Standard Time', 'America/Scoresbysund': 'Azores Standard Time', + 'America/Shiprock': 'Mountain Standard Time', 'America/Sitka': 'Alaskan Standard Time', 'America/St_Barthelemy': 'SA Western Standard Time', 'America/St_Johns': 'Newfoundland Standard Time', @@ -331,6 +340,7 @@ 'America/Toronto': 'Eastern Standard Time', 'America/Tortola': 'SA Western Standard Time', 'America/Vancouver': 'Pacific Standard Time', + 'America/Virgin': 'SA Western Standard Time', 'America/Whitehorse': 'Pacific Standard Time', 'America/Winnipeg': 'Central Standard Time', 'America/Yakutat': 'Alaskan Standard Time', @@ -341,8 +351,9 @@ 'Antarctica/Macquarie': 'Central Pacific Standard Time', 'Antarctica/Mawson': 'West Asia Standard Time', 'Antarctica/McMurdo': 'New Zealand Standard Time', - 'Antarctica/Palmer': 'SA Eastern Standard Time', + 'Antarctica/Palmer': 'Magallanes Standard Time', 'Antarctica/Rothera': 'SA Eastern Standard Time', + 'Antarctica/South_Pole': 'New Zealand Standard Time', 'Antarctica/Syowa': 'E. Africa Standard Time', 'Antarctica/Vostok': 'Central Asia Standard Time', 'Arctic/Longyearbyen': 'W. Europe Standard Time', @@ -353,6 +364,7 @@ 'Asia/Aqtau': 'West Asia Standard Time', 'Asia/Aqtobe': 'West Asia Standard Time', 'Asia/Ashgabat': 'West Asia Standard Time', + 'Asia/Ashkhabad': 'West Asia Standard Time', 'Asia/Atyrau': 'West Asia Standard Time', 'Asia/Baghdad': 'Arabic Standard Time', 'Asia/Bahrain': 'Arab Standard Time', @@ -365,7 +377,10 @@ 'Asia/Calcutta': 'India Standard Time', 'Asia/Chita': 'Transbaikal Standard Time', 'Asia/Choibalsan': 'Ulaanbaatar Standard Time', + 'Asia/Chongqing': 'China Standard Time', + 'Asia/Chungking': 'China Standard Time', 'Asia/Colombo': 'Sri Lanka Standard Time', + 'Asia/Dacca': 'Bangladesh Standard Time', 'Asia/Damascus': 'Syria Standard Time', 'Asia/Dhaka': 'Bangladesh Standard Time', 'Asia/Dili': 'Tokyo Standard Time', @@ -373,6 +388,7 @@ 'Asia/Dushanbe': 'West Asia Standard Time', 'Asia/Famagusta': 'Turkey Standard Time', 'Asia/Gaza': 'West Bank Standard Time', + 'Asia/Harbin': 'China Standard Time', 'Asia/Hebron': 'West Bank Standard Time', 'Asia/Hong_Kong': 'China Standard Time', 'Asia/Hovd': 'W. Mongolia Standard Time', @@ -383,12 +399,14 @@ 'Asia/Kabul': 'Afghanistan Standard Time', 'Asia/Kamchatka': 'Russia Time Zone 11', 'Asia/Karachi': 'Pakistan Standard Time', + 'Asia/Kashgar': 'Central Asia Standard Time', 'Asia/Katmandu': 'Nepal Standard Time', 'Asia/Khandyga': 'Yakutsk Standard Time', 'Asia/Krasnoyarsk': 'North Asia Standard Time', 'Asia/Kuala_Lumpur': 'Singapore Standard Time', 'Asia/Kuching': 'Singapore Standard Time', 'Asia/Kuwait': 'Arab Standard Time', + 'Asia/Macao': 'China Standard Time', 'Asia/Macau': 'China Standard Time', 'Asia/Magadan': 'Magadan Standard Time', 'Asia/Makassar': 'Singapore Standard Time', @@ -417,10 +435,14 @@ 'Asia/Tashkent': 'West Asia Standard Time', 'Asia/Tbilisi': 'Georgian Standard Time', 'Asia/Tehran': 'Iran Standard Time', + 'Asia/Tel_Aviv': 'Israel Standard Time', + 'Asia/Thimbu': 'Bangladesh Standard Time', 'Asia/Thimphu': 'Bangladesh Standard Time', 'Asia/Tokyo': 'Tokyo Standard Time', 'Asia/Tomsk': 'Tomsk Standard Time', + 'Asia/Ujung_Pandang': 'Singapore Standard Time', 'Asia/Ulaanbaatar': 'Ulaanbaatar Standard Time', + 'Asia/Ulan_Bator': 'Ulaanbaatar Standard Time', 'Asia/Urumqi': 'Central Asia Standard Time', 'Asia/Ust-Nera': 'Vladivostok Standard Time', 'Asia/Vientiane': 'SE Asia Standard Time', @@ -433,25 +455,54 @@ 'Atlantic/Canary': 'GMT Standard Time', 'Atlantic/Cape_Verde': 'Cape Verde Standard Time', 'Atlantic/Faeroe': 'GMT Standard Time', + 'Atlantic/Jan_Mayen': 'W. Europe Standard Time', 'Atlantic/Madeira': 'GMT Standard Time', 'Atlantic/Reykjavik': 'Greenwich Standard Time', 'Atlantic/South_Georgia': 'UTC-02', 'Atlantic/St_Helena': 'Greenwich Standard Time', 'Atlantic/Stanley': 'SA Eastern Standard Time', + 'Australia/ACT': 'AUS Eastern Standard Time', 'Australia/Adelaide': 'Cen. Australia Standard Time', 'Australia/Brisbane': 'E. Australia Standard Time', 'Australia/Broken_Hill': 'Cen. Australia Standard Time', + 'Australia/Canberra': 'AUS Eastern Standard Time', 'Australia/Currie': 'Tasmania Standard Time', 'Australia/Darwin': 'AUS Central Standard Time', 'Australia/Eucla': 'Aus Central W. Standard Time', 'Australia/Hobart': 'Tasmania Standard Time', + 'Australia/LHI': 'Lord Howe Standard Time', 'Australia/Lindeman': 'E. Australia Standard Time', 'Australia/Lord_Howe': 'Lord Howe Standard Time', 'Australia/Melbourne': 'AUS Eastern Standard Time', + 'Australia/NSW': 'AUS Eastern Standard Time', + 'Australia/North': 'AUS Central Standard Time', 'Australia/Perth': 'W. Australia Standard Time', + 'Australia/Queensland': 'E. Australia Standard Time', + 'Australia/South': 'Cen. Australia Standard Time', 'Australia/Sydney': 'AUS Eastern Standard Time', + 'Australia/Tasmania': 'Tasmania Standard Time', + 'Australia/Victoria': 'AUS Eastern Standard Time', + 'Australia/West': 'W. Australia Standard Time', + 'Australia/Yancowinna': 'Cen. Australia Standard Time', + 'Brazil/Acre': 'SA Pacific Standard Time', + 'Brazil/DeNoronha': 'UTC-02', + 'Brazil/East': 'E. South America Standard Time', + 'Brazil/West': 'SA Western Standard Time', 'CST6CDT': 'Central Standard Time', + 'Canada/Atlantic': 'Atlantic Standard Time', + 'Canada/Central': 'Central Standard Time', + 'Canada/Eastern': 'Eastern Standard Time', + 'Canada/Mountain': 'Mountain Standard Time', + 'Canada/Newfoundland': 'Newfoundland Standard Time', + 'Canada/Pacific': 'Pacific Standard Time', + 'Canada/Saskatchewan': 'Canada Central Standard Time', + 'Canada/Yukon': 'Pacific Standard Time', + 'Chile/Continental': 'Pacific SA Standard Time', + 'Chile/EasterIsland': 'Easter Island Standard Time', + 'Cuba': 'Cuba Standard Time', 'EST5EDT': 'Eastern Standard Time', + 'Egypt': 'Egypt Standard Time', + 'Eire': 'GMT Standard Time', 'Etc/GMT': 'UTC', 'Etc/GMT+1': 'Cape Verde Standard Time', 'Etc/GMT+10': 'Hawaiian Standard Time', @@ -469,7 +520,7 @@ 'Etc/GMT-10': 'West Pacific Standard Time', 'Etc/GMT-11': 'Central Pacific Standard Time', 'Etc/GMT-12': 'UTC+12', - 'Etc/GMT-13': 'Tonga Standard Time', + 'Etc/GMT-13': 'UTC+13', 'Etc/GMT-14': 'Line Islands Standard Time', 'Etc/GMT-2': 'South Africa Standard Time', 'Etc/GMT-3': 'E. Africa Standard Time', @@ -484,6 +535,7 @@ 'Europe/Andorra': 'W. Europe Standard Time', 'Europe/Astrakhan': 'Astrakhan Standard Time', 'Europe/Athens': 'GTB Standard Time', + 'Europe/Belfast': 'GMT Standard Time', 'Europe/Belgrade': 'Central Europe Standard Time', 'Europe/Berlin': 'W. Europe Standard Time', 'Europe/Bratislava': 'Central Europe Standard Time', @@ -522,13 +574,14 @@ 'Europe/Samara': 'Russia Time Zone 3', 'Europe/San_Marino': 'W. Europe Standard Time', 'Europe/Sarajevo': 'Central European Standard Time', - 'Europe/Saratov': 'Astrakhan Standard Time', + 'Europe/Saratov': 'Saratov Standard Time', 'Europe/Simferopol': 'Russian Standard Time', 'Europe/Skopje': 'Central European Standard Time', 'Europe/Sofia': 'FLE Standard Time', 'Europe/Stockholm': 'W. Europe Standard Time', 'Europe/Tallinn': 'FLE Standard Time', 'Europe/Tirane': 'Central Europe Standard Time', + 'Europe/Tiraspol': 'E. Europe Standard Time', 'Europe/Ulyanovsk': 'Astrakhan Standard Time', 'Europe/Uzhgorod': 'FLE Standard Time', 'Europe/Vaduz': 'W. Europe Standard Time', @@ -540,6 +593,14 @@ 'Europe/Zagreb': 'Central European Standard Time', 'Europe/Zaporozhye': 'FLE Standard Time', 'Europe/Zurich': 'W. Europe Standard Time', + 'GB': 'GMT Standard Time', + 'GB-Eire': 'GMT Standard Time', + 'GMT+0': 'UTC', + 'GMT-0': 'UTC', + 'GMT0': 'UTC', + 'Greenwich': 'UTC', + 'Hongkong': 'China Standard Time', + 'Iceland': 'Greenwich Standard Time', 'Indian/Antananarivo': 'E. Africa Standard Time', 'Indian/Chagos': 'Central Asia Standard Time', 'Indian/Christmas': 'SE Asia Standard Time', @@ -551,7 +612,20 @@ 'Indian/Mauritius': 'Mauritius Standard Time', 'Indian/Mayotte': 'E. Africa Standard Time', 'Indian/Reunion': 'Mauritius Standard Time', + 'Iran': 'Iran Standard Time', + 'Israel': 'Israel Standard Time', + 'Jamaica': 'SA Pacific Standard Time', + 'Japan': 'Tokyo Standard Time', + 'Kwajalein': 'UTC+12', + 'Libya': 'Libya Standard Time', 'MST7MDT': 'Mountain Standard Time', + 'Mexico/BajaNorte': 'Pacific Standard Time (Mexico)', + 'Mexico/BajaSur': 'Mountain Standard Time (Mexico)', + 'Mexico/General': 'Central Standard Time (Mexico)', + 'NZ': 'New Zealand Standard Time', + 'NZ-CHAT': 'Chatham Islands Standard Time', + 'Navajo': 'Mountain Standard Time', + 'PRC': 'China Standard Time', 'PST8PDT': 'Pacific Standard Time', 'Pacific/Apia': 'Samoa Standard Time', 'Pacific/Auckland': 'New Zealand Standard Time', @@ -559,8 +633,8 @@ 'Pacific/Chatham': 'Chatham Islands Standard Time', 'Pacific/Easter': 'Easter Island Standard Time', 'Pacific/Efate': 'Central Pacific Standard Time', - 'Pacific/Enderbury': 'Tonga Standard Time', - 'Pacific/Fakaofo': 'Tonga Standard Time', + 'Pacific/Enderbury': 'UTC+13', + 'Pacific/Fakaofo': 'UTC+13', 'Pacific/Fiji': 'Fiji Standard Time', 'Pacific/Funafuti': 'UTC+12', 'Pacific/Galapagos': 'Central America Standard Time', @@ -586,9 +660,31 @@ 'Pacific/Port_Moresby': 'West Pacific Standard Time', 'Pacific/Rarotonga': 'Hawaiian Standard Time', 'Pacific/Saipan': 'West Pacific Standard Time', + 'Pacific/Samoa': 'UTC-11', 'Pacific/Tahiti': 'Hawaiian Standard Time', 'Pacific/Tarawa': 'UTC+12', 'Pacific/Tongatapu': 'Tonga Standard Time', 'Pacific/Truk': 'West Pacific Standard Time', 'Pacific/Wake': 'UTC+12', - 'Pacific/Wallis': 'UTC+12'} + 'Pacific/Wallis': 'UTC+12', + 'Poland': 'Central European Standard Time', + 'Portugal': 'GMT Standard Time', + 'ROC': 'Taipei Standard Time', + 'ROK': 'Korea Standard Time', + 'Singapore': 'Singapore Standard Time', + 'Turkey': 'Turkey Standard Time', + 'US/Alaska': 'Alaskan Standard Time', + 'US/Aleutian': 'Aleutian Standard Time', + 'US/Arizona': 'US Mountain Standard Time', + 'US/Central': 'Central Standard Time', + 'US/Eastern': 'Eastern Standard Time', + 'US/Hawaii': 'Hawaiian Standard Time', + 'US/Indiana-Starke': 'Central Standard Time', + 'US/Michigan': 'Eastern Standard Time', + 'US/Mountain': 'Mountain Standard Time', + 'US/Pacific': 'Pacific Standard Time', + 'US/Samoa': 'UTC-11', + 'UTC': 'UTC', + 'Universal': 'UTC', + 'W-SU': 'Russian Standard Time', + 'Zulu': 'UTC'} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/PKG-INFO new/tzlocal-1.5.1/tzlocal.egg-info/PKG-INFO --- old/tzlocal-1.4/tzlocal.egg-info/PKG-INFO 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,234 +0,0 @@ -Metadata-Version: 1.1 -Name: tzlocal -Version: 1.4 -Summary: tzinfo object for the local timezone -Home-page: https://github.com/regebro/tzlocal -Author: Lennart Regebro -Author-email: [email protected] -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, 22, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>) - - - Maintainer - ---------- - - * Lennart Regebro, [email protected] - - Contributors - ------------ - - * Marc Van Olmen - * Benjamen Meyer - * Manuel Ebert - * Xiaokun Zhu - * Cameris - * Edward Betts - * McK KIM - * Cris Ewing - * Ayala Shachar - * Lev Maximov - * Jakub Wilk - * John Quarles - - (Sorry if I forgot someone) - - License - ------- - - * CC0 1.0 Universal http://creativecommons.org/publicdomain/zero/1.0/ - - - Changes - ======= - - 1.4 (2017-04-18) - ---------------- - - - I use MIT on my other projects, so relicensing. - - - 1.4b1 (2017-04-14) - ------------------ - - - Dropping support for Python versions nobody uses (2.5, 3.1, 3.2), adding 3.6 - Python 3.1 and 3.2 still works, 2.5 has been broken for some time. - - - Ayalash's OS X fix didn't work on Python 2.7, fixed that. - - - 1.3.2 (2017-04-12) - ------------------ - - - Ensure closing of subprocess on OS X (ayalash) - - - Removed unused imports (jwilk) - - - Closes stdout and stderr to get rid of ResourceWarnings (johnwquarles) - - - Updated Windows timezones (axil) - - - 1.3 (2016-10-15) - ---------------- - - - #34: Added support for /var/db/zoneinfo - - - 1.2.2 (2016-03-02) - ------------------ - - - #30: Fixed a bug on OS X. - - - 1.2.1 (2016-02-28) - ------------------ - - - Tests failed if TZ was set in the environment. (EdwardBetts) - - - Replaces os.popen() with subprocess.Popen() for OS X to - handle when systemsetup doesn't exist. (mckabi, cewing) - - - 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 :: 5 - Production/Stable -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: Microsoft :: Windows -Classifier: Operating System :: Unix -Classifier: Operating System :: MacOS :: MacOS X -Classifier: Programming Language :: Python :: 2.6 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.3 -Classifier: Programming Language :: Python :: 3.4 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/SOURCES.txt new/tzlocal-1.5.1/tzlocal.egg-info/SOURCES.txt --- old/tzlocal-1.4/tzlocal.egg-info/SOURCES.txt 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/SOURCES.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1,27 +0,0 @@ -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/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/vardbzoneinfo/var/db/zoneinfo -tzlocal/test_data/zone_setting/etc/sysconfig/clock \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/dependency_links.txt new/tzlocal-1.5.1/tzlocal.egg-info/dependency_links.txt --- old/tzlocal-1.4/tzlocal.egg-info/dependency_links.txt 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/dependency_links.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/requires.txt new/tzlocal-1.5.1/tzlocal.egg-info/requires.txt --- old/tzlocal-1.4/tzlocal.egg-info/requires.txt 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/requires.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -pytz diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/top_level.txt new/tzlocal-1.5.1/tzlocal.egg-info/top_level.txt --- old/tzlocal-1.4/tzlocal.egg-info/top_level.txt 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/top_level.txt 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -tzlocal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/tzlocal.egg-info/zip-safe new/tzlocal-1.5.1/tzlocal.egg-info/zip-safe --- old/tzlocal-1.4/tzlocal.egg-info/zip-safe 2017-04-18 18:51:45.000000000 +0200 +++ new/tzlocal-1.5.1/tzlocal.egg-info/zip-safe 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tzlocal-1.4/update_windows_mappings.py new/tzlocal-1.5.1/update_windows_mappings.py --- old/tzlocal-1.4/update_windows_mappings.py 1970-01-01 01:00:00.000000000 +0100 +++ new/tzlocal-1.5.1/update_windows_mappings.py 2017-12-01 10:37:45.000000000 +0100 @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 + +# 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. + +import ftplib +import logging +from io import BytesIO +from pprint import pprint +import tarfile +from urllib.parse import urlparse +from urllib.request import urlopen +from xml.dom import minidom + +WIN_ZONES_URL = 'http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml' +ZONEINFO_URL = 'ftp://ftp.iana.org/tz/tzdata-latest.tar.gz' + +logging.basicConfig(level=logging.INFO) +log = logging.getLogger() + + +def update_old_names(): + """Fetches the list of old tz names and returns a mapping""" + + url = urlparse(ZONEINFO_URL) + log.info('Connecting to %s' % url.netloc) + ftp = ftplib.FTP(url.netloc) + ftp.login() + gzfile = BytesIO() + + log.info('Fetching zoneinfo database') + ftp.retrbinary('RETR ' + url.path, gzfile.write) + gzfile.seek(0) + + log.info('Extracting backwards data') + archive = tarfile.open(mode="r:gz", fileobj=gzfile) + backward = {} + for line in archive.extractfile('backward').readlines(): + if line[0] == '#': + continue + if len(line.strip()) == 0: + continue + parts = line.split() + if parts[0] != b'Link': + continue + + backward[parts[2].decode('ascii')] = parts[1].decode('ascii') + + return backward + + +def update_windows_zones(): + backward = update_old_names() + + log.info('Fetching Windows mapping info from unicode.org') + source = urlopen(WIN_ZONES_URL).read() + dom = minidom.parseString(source) + + for element in dom.getElementsByTagName('mapTimezones'): + if element.getAttribute('type') == 'windows': + break + + log.info('Making windows mapping') + 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] + if win_tz[mapping.getAttribute('other')].startswith('Etc'): + print (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') + + log.info('Adding backwards data') + # Map in the backwards compatible zone names + for backward_compat_name, standard_name in backward.items(): + win_zone = tz_win.get(standard_name, None) + if win_zone: + tz_win[backward_compat_name] = win_zone + + # Etc/UTC is a common but non-standard alias for Etc/GMT: + tz_win['Etc/UTC'] = 'UTC' + + log.info('Writing mapping') + with open('tzlocal/windows_tz.py', "wt") as out: + out.write("# This file is autogenerated by the update_windows_mapping.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) + + log.info('Done') + + +if __name__ == '__main__': + update_windows_zones()
