summaryrefslogtreecommitdiff
path: root/dev-python/python-dateutil/files/python-dateutil-2.9.0-system-tzdata.patch
blob: 08a983d9f6a2e1bb195517c1cb772eb3e1898c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
diff --git a/src/dateutil/zoneinfo/__init__.py b/src/dateutil/zoneinfo/__init__.py
index 34f11ad..e3f0f94 100644
--- a/src/dateutil/zoneinfo/__init__.py
+++ b/src/dateutil/zoneinfo/__init__.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 import warnings
 import json
+import os
 
 from tarfile import TarFile
 from pkgutil import get_data
@@ -10,7 +11,7 @@ from dateutil.tz import tzfile as _tzfile
 
 __all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"]
 
-ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
+ZONEDIRECTORY = "/usr/share/zoneinfo"
 METADATA_FN = 'METADATA'
 
 
@@ -19,12 +20,14 @@ class tzfile(_tzfile):
         return (gettz, (self._filename,))
 
 
-def getzoneinfofile_stream():
-    try:
-        return BytesIO(get_data(__name__, ZONEFILENAME))
-    except IOError as e:  # TODO  switch to FileNotFoundError?
-        warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
-        return None
+def iter_zones(topdir):
+    for dirpath, dirnames, filenames in os.walk(topdir):
+        for f in filenames:
+            if f.endswith(('.list', '.tab', '.zi', 'leapseconds')):
+                continue
+            fpath = os.path.join(dirpath, f)
+            relpath = os.path.relpath(fpath, topdir)
+            yield (relpath, tzfile(fpath, filename=relpath))
 
 
 class ZoneInfoFile(object):
@@ -48,7 +51,7 @@ class ZoneInfoFile(object):
                     # no metadata in tar file
                     self.metadata = None
         else:
-            self.zones = {}
+            self.zones = dict(iter_zones(ZONEDIRECTORY))
             self.metadata = None
 
     def get(self, name, default=None):
@@ -99,7 +102,7 @@ def get_zonefile_instance(new_instance=False):
         zif = getattr(get_zonefile_instance, '_cached_instance', None)
 
     if zif is None:
-        zif = ZoneInfoFile(getzoneinfofile_stream())
+        zif = ZoneInfoFile()
 
         get_zonefile_instance._cached_instance = zif
 
@@ -140,7 +143,7 @@ def gettz(name):
                   DeprecationWarning)
 
     if len(_CLASS_ZONE_INSTANCE) == 0:
-        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
+        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile())
     return _CLASS_ZONE_INSTANCE[0].zones.get(name)
 
 
@@ -163,5 +166,5 @@ def gettz_db_metadata():
                   DeprecationWarning)
 
     if len(_CLASS_ZONE_INSTANCE) == 0:
-        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
+        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile())
     return _CLASS_ZONE_INSTANCE[0].metadata
diff --git a/tests/test_imports.py b/tests/test_imports.py
index 7d0749e..4256f45 100644
--- a/tests/test_imports.py
+++ b/tests/test_imports.py
@@ -232,9 +232,8 @@ def test_import_zone_info_from():
 def test_import_zone_info_star():
     from dateutil.zoneinfo import gettz
     from dateutil.zoneinfo import gettz_db_metadata
-    from dateutil.zoneinfo import rebuild
 
-    zi_all = (gettz, gettz_db_metadata, rebuild)
+    zi_all = (gettz, gettz_db_metadata)
 
     for var in zi_all:
         assert var is not None