[Python-modules-commits] [python-tzlocal] 01/04: Import python-tzlocal_1.3.orig.tar.gz
Edward Betts
edward at moszumanska.debian.org
Fri Nov 18 17:03:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
edward pushed a commit to branch master
in repository python-tzlocal.
commit 5561ef5fdacdfb9a59c99f97e78a498aadfd91d0
Author: Edward Betts <edward at 4angle.com>
Date: Fri Nov 18 12:43:31 2016 +0000
Import python-tzlocal_1.3.orig.tar.gz
---
CHANGES.txt | 6 +++++
PKG-INFO | 8 +++++-
setup.py | 2 +-
tzlocal.egg-info/PKG-INFO | 8 +++++-
tzlocal.egg-info/SOURCES.txt | 1 +
tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo | 1 +
tzlocal/tests.py | 6 +++++
tzlocal/unix.py | 33 +++++++++++++------------
8 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 051ccca..317191f 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,12 @@
Changes
=======
+1.3 (2016-10-15)
+----------------
+
+- #34: Added support for /var/db/zoneinfo
+
+
1.2.2 (2016-03-02)
------------------
diff --git a/PKG-INFO b/PKG-INFO
index 8c9f14f..a6a5ffe 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: tzlocal
-Version: 1.2.2
+Version: 1.3
Summary: tzinfo object for the local timezone
Home-page: https://github.com/regebro/tzlocal
Author: Lennart Regebro
@@ -95,6 +95,12 @@ Description: tzlocal
Changes
=======
+ 1.3 (2016-10-15)
+ ----------------
+
+ - #34: Added support for /var/db/zoneinfo
+
+
1.2.2 (2016-03-02)
------------------
diff --git a/setup.py b/setup.py
index 5189d6e..a155d4d 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os
-version = '1.2.2'
+version = '1.3'
setup(name='tzlocal',
version=version,
diff --git a/tzlocal.egg-info/PKG-INFO b/tzlocal.egg-info/PKG-INFO
index 8c9f14f..a6a5ffe 100644
--- a/tzlocal.egg-info/PKG-INFO
+++ b/tzlocal.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: tzlocal
-Version: 1.2.2
+Version: 1.3
Summary: tzinfo object for the local timezone
Home-page: https://github.com/regebro/tzlocal
Author: Lennart Regebro
@@ -95,6 +95,12 @@ Description: tzlocal
Changes
=======
+ 1.3 (2016-10-15)
+ ----------------
+
+ - #34: Added support for /var/db/zoneinfo
+
+
1.2.2 (2016-03-02)
------------------
diff --git a/tzlocal.egg-info/SOURCES.txt b/tzlocal.egg-info/SOURCES.txt
index 928b7e8..4735dcd 100644
--- a/tzlocal.egg-info/SOURCES.txt
+++ b/tzlocal.egg-info/SOURCES.txt
@@ -23,4 +23,5 @@ 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 --git a/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo b/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo
new file mode 100644
index 0000000..28b3372
--- /dev/null
+++ b/tzlocal/test_data/vardbzoneinfo/var/db/zoneinfo
@@ -0,0 +1 @@
+Africa/Harare
diff --git a/tzlocal/tests.py b/tzlocal/tests.py
index 6f70f14..e736eb4 100644
--- a/tzlocal/tests.py
+++ b/tzlocal/tests.py
@@ -54,6 +54,12 @@ class TzLocalTests(unittest.TestCase):
tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'symlink_localtime'))
self.assertEqual(tz.zone, 'Africa/Harare')
+ def test_vardbzoneinfo_setting(self):
+ # A ZONE setting in /etc/conf.d/clock, f ex Gentoo
+ local_path = os.path.split(__file__)[0]
+ tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'vardbzoneinfo'))
+ self.assertEqual(tz.zone, 'Africa/Harare')
+
def test_only_localtime(self):
local_path = os.path.split(__file__)[0]
tz = tzlocal.unix._get_localzone(_root=os.path.join(local_path, 'test_data', 'localtime'))
diff --git a/tzlocal/unix.py b/tzlocal/unix.py
index f1eff1e..0d3f4e8 100644
--- a/tzlocal/unix.py
+++ b/tzlocal/unix.py
@@ -44,21 +44,22 @@ def _get_localzone(_root='/'):
# Now look for distribution specific configuration files
# that contain the timezone name.
- tzpath = os.path.join(_root, 'etc/timezone')
- if os.path.exists(tzpath):
- with open(tzpath, 'rb') as tzfile:
- data = tzfile.read()
-
- # 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(' ', '_'))
+ for configfile in ('etc/timezone', 'var/db/zoneinfo'):
+ tzpath = os.path.join(_root, configfile)
+ if os.path.exists(tzpath):
+ with open(tzpath, 'rb') as tzfile:
+ data = tzfile.read()
+
+ # 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(' ', '_'))
# CentOS has a ZONE setting in /etc/sysconfig/clock,
# OpenSUSE has a TIMEZONE setting in /etc/sysconfig/clock and
@@ -90,7 +91,7 @@ def _get_localzone(_root='/'):
# We found a timezone
return pytz.timezone(etctz.replace(' ', '_'))
- # systemd distributions use symlinks that include the zone name,
+ # systemd distributions use symlinks that include the zone name,
# see manpage of localtime(5) and timedatectl(1)
tzpath = os.path.join(_root, 'etc/localtime')
if os.path.exists(tzpath) and os.path.islink(tzpath):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-tzlocal.git
More information about the Python-modules-commits
mailing list