summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Pieviläinen <hukka@tsume>2013-10-31 14:17:54 +0200
committerTomi Pieviläinen <hukka@tsume>2013-10-31 14:17:54 +0200
commit4628efe7016fbc9fc1d670b490320d58f48e33c7 (patch)
tree5bd0b365cde0b5bc9df9cc3b0787704e1e0cdd82
parent11a2deb52fda4fa8c42030093a693124b52091ae (diff)
downloaddateutil-4628efe7016fbc9fc1d670b490320d58f48e33c7.tar.gz
More information about updating the zoneinfo database.
-rw-r--r--README17
-rw-r--r--dateutil/zoneinfo/__init__.py25
2 files changed, 38 insertions, 4 deletions
diff --git a/README b/README
index 9453699..39735e7 100644
--- a/README
+++ b/README
@@ -80,7 +80,9 @@ The following files are available.
* attachment:python-dateutil-1.0-1.noarch.rpm
== Author ==
-The dateutil module was written by GustavoNiemeyer <gustavo@niemeyer.net>.
+The dateutil module was written by Gustavo Niemeyer <gustavo@niemeyer.net> and
+is currently maintained by Tomi Pieviläinen <tomi.pievilainen@iki.fi>. The latest
+code is available in [https://launchpad.net/dateutil Launchpad].
== Documentation ==
The following modules are available.
@@ -1967,4 +1969,17 @@ Example:
tzfile('Brazil/East')
}}}
+== Building ==
+When you get the source, it does not contain the internal zoneinfo
+database. To get (and update) the database, run the updatezinfo.py script. Make sure
+that the zic command is in your path, and that you have network connectivity
+to get the latest timezone information from IANA. If you have downloaded
+the timezone data earlier, you can give the tarball as a parameter to
+updatezinfo.py.
+
+== Testing ==
+dateutil has a comprehensive test suite, which can be run simply by running the
+test.py script in the project root. Note that if you don't have the internal
+zoneinfo database, some tests will fail. Apart from that, all tests should pass.
+
## vim:ft=moin
diff --git a/dateutil/zoneinfo/__init__.py b/dateutil/zoneinfo/__init__.py
index a1b3487..81db140 100644
--- a/dateutil/zoneinfo/__init__.py
+++ b/dateutil/zoneinfo/__init__.py
@@ -5,9 +5,12 @@ Copyright (c) 2003-2005 Gustavo Niemeyer <gustavo@niemeyer.net>
This module offers extensions to the standard Python
datetime module.
"""
-from dateutil.tz import tzfile
-from tarfile import TarFile
+import logging
import os
+from subprocess import call
+from tarfile import TarFile
+
+from dateutil.tz import tzfile
__author__ = "Tomi Pieviläinen <tomi.pievilainen@iki.fi>"
__license__ = "Simplified BSD"
@@ -58,6 +61,11 @@ def gettz(name):
return tzinfo
def rebuild(filename, tag=None, format="gz"):
+ """Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*
+
+ filename is the timezone tarball from ftp.iana.org/tz.
+
+ """
import tempfile, shutil
tmpdir = tempfile.mkdtemp()
zonedir = os.path.join(tmpdir, "zoneinfo")
@@ -75,7 +83,18 @@ def rebuild(filename, tag=None, format="gz"):
name == "leapseconds"):
tf.extract(name, tmpdir)
filepath = os.path.join(tmpdir, name)
- os.system("zic -d %s %s" % (zonedir, filepath))
+ try:
+ # zic will return errors for nontz files in the package
+ # such as the Makefile or README, so check_call cannot
+ # be used (or at least extra checks would be needed)
+ call(["zic", "-d", zonedir, filepath])
+ except OSError as e:
+ if e.errno == 2:
+ logging.error(
+ "Could not find zic. Perhaps you need to install "
+ "libc-bin or some other package that provides it, "
+ "or it's not in your PATH?")
+ raise
tf.close()
target = os.path.join(moduledir, targetname)
for entry in os.listdir(moduledir):