1 diff -up python-dateutil-1.5/dateutil/zoneinfo/__init__.py\~ python-dateutil-1.5/dateutil/zoneinfo/__init__.py
2 --- python-dateutil-1.5/dateutil/zoneinfo/__init__.py~ 2005-12-22 19:13:50.000000000 +0100
3 +++ python-dateutil-1.5/dateutil/zoneinfo/__init__.py 2011-08-17 15:24:29.019214748 +0200
4 @@ -15,6 +15,7 @@ __all__ = ["setcachesize", "gettz", "reb
8 +USE_SYSTEM_ZONEINFO = True # XXX configure at build time
12 @@ -29,7 +30,8 @@ def getzoneinfofile():
13 return os.path.join(os.path.dirname(__file__), entry)
16 -ZONEINFOFILE = getzoneinfofile()
17 +ZONEINFOFILE = getzoneinfofile() if USE_SYSTEM_ZONEINFO else None
18 +ZONEINFODIR = (os.getenv("TZDIR") or "/usr/share/zoneinfo").rstrip(os.sep)
22 @@ -39,22 +40,37 @@ def setcachesize(size):
28 - for cachedname, tzinfo in CACHE:
29 - if cachedname == name:
31 + for cachedname, tzinfo in CACHE:
32 + if cachedname == name:
35 + name_parts = name.lstrip('/').split('/')
36 + for part in name_parts:
37 + if part == os.path.pardir or os.path.sep in part:
38 + raise ValueError('Bad path segment: %r' % part)
39 + filename = os.path.join(ZONEINFODIR, *name_parts)
41 + zonefile = open(filename, "rb")
45 + tzinfo = tzfile(zonefile)
48 + if tzinfo is None and ZONEINFOFILE:
49 + tf = TarFile.open(ZONEINFOFILE)
51 + zonefile = tf.extractfile(name)
55 - tf = TarFile.open(ZONEINFOFILE)
57 - zonefile = tf.extractfile(name)
61 - tzinfo = tzfile(zonefile)
63 - CACHE.insert(0, (name, tzinfo))
64 - del CACHE[CACHESIZE:]
65 + tzinfo = tzfile(zonefile)
68 + if tzinfo is not None:
69 + CACHE.insert(0, (name, tzinfo))
70 + del CACHE[CACHESIZE:]
74 def rebuild(filename, tag=None, format="gz"):
75 diff -up python-dateutil-1.5/setup.py\~ python-dateutil-1.5/setup.py
76 --- python-dateutil-1.5/setup.py~ 2010-01-11 10:43:22.000000000 +0100
77 +++ python-dateutil-1.5/setup.py 2011-08-17 15:38:13.206304651 +0200
78 @@ -15,6 +15,16 @@ TOPDIR = os.path.dirname(__file__) or ".
79 VERSION = re.search('__version__ = "([^"]+)"',
80 open(TOPDIR + "/dateutil/__init__.py").read()).group(1)
82 +# XXX We would like to bind this to something like
83 +# --system-zoneinfo=/path/to/zoneinfo. Any way of doing this short of
84 +# overriding build and install commands?
86 + extra_options = dict(
87 + package_data={"": ["*.tar.gz"]},
93 setup(name="python-dateutil",
95 @@ -29,7 +39,7 @@ The dateutil module provides powerful ex
96 datetime module, available in Python 2.3+.
98 packages = ["dateutil", "dateutil.zoneinfo"],
99 - package_data={"": ["*.tar.gz"]},
100 include_package_data=True,