summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniemeyer <>2005-12-22 20:16:54 +0000
committerniemeyer <>2005-12-22 20:16:54 +0000
commit4c1bcb178aa972d9ddb0a7da9c461d6788ac7e5d (patch)
tree9816b417be7494e16bb4307c92c20d0644e47b48
parent39f25fedce0c9e06419a7bf9d83525ad073e77ff (diff)
downloaddateutil-4c1bcb178aa972d9ddb0a7da9c461d6788ac7e5d.tar.gz
Get the latest zoneinfo file when many are available.
-rw-r--r--dateutil/zoneinfo/__init__.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/dateutil/zoneinfo/__init__.py b/dateutil/zoneinfo/__init__.py
index 856fcf1..9bed626 100644
--- a/dateutil/zoneinfo/__init__.py
+++ b/dateutil/zoneinfo/__init__.py
@@ -20,11 +20,18 @@ class tzfile(tzfile):
def __reduce__(self):
return (gettz, (self._filename,))
-ZONEINFOFILE = None
-for entry in os.listdir(os.path.dirname(__file__)):
- if entry.startswith("zoneinfo") and ".tar." in entry:
- ZONEINFOFILE = os.path.join(os.path.dirname(__file__), entry)
- break
+def getzoneinfofile():
+ filenames = os.listdir(os.path.join(os.path.dirname(__file__)))
+ filenames.sort()
+ filenames.reverse()
+ for entry in filenames:
+ if entry.startswith("zoneinfo") and ".tar." in entry:
+ return os.path.join(os.path.dirname(__file__), entry)
+ return None
+
+ZONEINFOFILE = getzoneinfofile()
+
+del getzoneinfofile
def setcachesize(size):
global CACHESIZE, CACHE