]> git.pld-linux.org Git - packages/python-dateutil.git/blame - system-zoneinfo.patch
- updated to 2.2, now works again with python 2.x (2.6+, with six)
[packages/python-dateutil.git] / system-zoneinfo.patch
CommitLineData
07c95c93
ER
1diff -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
5
6 CACHE = []
7 CACHESIZE = 10
8+USE_SYSTEM_ZONEINFO = True # XXX configure at build time
9
10 class tzfile(tzfile):
11 def __reduce__(self):
12@@ -29,7 +30,8 @@ def getzoneinfofile():
13 return os.path.join(os.path.dirname(__file__), entry)
14 return None
15
16-ZONEINFOFILE = getzoneinfofile()
17+ZONEINFOFILE = getzoneinfofile() if USE_SYSTEM_ZONEINFO else None
18+ZONEINFODIR = (os.getenv("TZDIR") or "/usr/share/zoneinfo").rstrip(os.sep)
19
20 del getzoneinfofile
21
22@@ -39,22 +40,37 @@ def setcachesize(size):
23 del CACHE[size:]
24
25 def gettz(name):
26- tzinfo = None
27- if ZONEINFOFILE:
28- for cachedname, tzinfo in CACHE:
29- if cachedname == name:
30- break
31+ for cachedname, tzinfo in CACHE:
32+ if cachedname == name:
33+ return tzinfo
34+
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)
40+ try:
41+ zonefile = open(filename, "rb")
42+ except:
43+ tzinfo = None
44+ else:
45+ tzinfo = tzfile(zonefile)
46+ zonefile.close()
47+
48+ if tzinfo is None and ZONEINFOFILE:
49+ tf = TarFile.open(ZONEINFOFILE)
50+ try:
51+ zonefile = tf.extractfile(name)
52+ except KeyError:
53+ tzinfo = None
54 else:
55- tf = TarFile.open(ZONEINFOFILE)
56- try:
57- zonefile = tf.extractfile(name)
58- except KeyError:
59- tzinfo = None
60- else:
61- tzinfo = tzfile(zonefile)
62- tf.close()
63- CACHE.insert(0, (name, tzinfo))
64- del CACHE[CACHESIZE:]
65+ tzinfo = tzfile(zonefile)
66+ tf.close()
67+
68+ if tzinfo is not None:
69+ CACHE.insert(0, (name, tzinfo))
70+ del CACHE[CACHESIZE:]
71+
72 return tzinfo
73
74 def rebuild(filename, tag=None, format="gz"):
8665830c
JB
75--- python-dateutil-2.2/setup.py.orig 2013-11-01 09:32:03.000000000 +0100
76+++ python-dateutil-2.2/setup.py 2014-10-19 16:56:34.244854176 +0200
77@@ -16,6 +16,16 @@
07c95c93 78 VERSION = re.search('__version__ = "([^"]+)"',
8665830c 79 codecs.open(TOPDIR + "/dateutil/__init__.py", encoding='utf-8').read()).group(1)
07c95c93
ER
80
81+# XXX We would like to bind this to something like
82+# --system-zoneinfo=/path/to/zoneinfo. Any way of doing this short of
83+# overriding build and install commands?
84+if False:
85+ extra_options = dict(
86+ package_data={"": ["*.tar.gz"]},
87+ )
88+else:
89+ extra_options = {}
90+
91
92 setup(name="python-dateutil",
93 version = VERSION,
8665830c
JB
94@@ -30,7 +40,6 @@
95 datetime module available in the Python standard library.
07c95c93
ER
96 """,
97 packages = ["dateutil", "dateutil.zoneinfo"],
8665830c
JB
98- package_data = {"": ["*.tar.gz"]},
99 include_package_data = True,
100 zip_safe = False,
101 requires = ["six"],
102@@ -47,5 +56,6 @@
103 'Programming Language :: Python :: 3.2',
104 'Programming Language :: Python :: 3.3',
105 'Topic :: Software Development :: Libraries',
106- ]
107+ ],
07c95c93
ER
108+ **extra_options
109 )
This page took 0.120373 seconds and 4 git commands to generate.