diff options
author | niemeyer <> | 2005-12-22 20:16:54 +0000 |
---|---|---|
committer | niemeyer <> | 2005-12-22 20:16:54 +0000 |
commit | 4c1bcb178aa972d9ddb0a7da9c461d6788ac7e5d (patch) | |
tree | 9816b417be7494e16bb4307c92c20d0644e47b48 | |
parent | 39f25fedce0c9e06419a7bf9d83525ad073e77ff (diff) | |
download | dateutil-4c1bcb178aa972d9ddb0a7da9c461d6788ac7e5d.tar.gz |
Get the latest zoneinfo file when many are available.
-rw-r--r-- | dateutil/zoneinfo/__init__.py | 17 |
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 |