Merge pull request #414 from JackDandy/feature/ChangeZoneinfo

Change zoneinfo update/loader to be compatible with dateutil 2.4.2.
This commit is contained in:
JackDandy 2015-06-14 02:18:52 +01:00
commit d94394231f
5 changed files with 22 additions and 9 deletions

View file

@ -43,6 +43,7 @@
* Update SimpleJSON library 2.0.9 to 3.7.3 (0bcdf20)
* Update xmltodict library 0.9.0 to 0.9.2 (579a005)
* Update dateutil library 2.2 to 2.4.2 (a6b8925)
* Change zoneinfo update/loader to be compatible with dateutil 2.4.2
[develop changelog]
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)

View file

@ -3,3 +3,4 @@ Libs with customisations...
/tornado
/lib/requests/packages/urllib3/connectionpool.py
/lib/requests/packages/urllib3/util/ssl_.py
/lib/dateutil/zoneinfo/__init__.py

1
lib/dateutil/zoneinfo/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.tar.gz

View file

@ -16,7 +16,17 @@ from dateutil.tz import tzfile
__all__ = ["gettz", "gettz_db_metadata", "rebuild"]
_ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
def getzoneinfofile():
filenames = sorted(os.listdir(os.path.join(os.path.dirname(__file__))))
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
_ZONEFILENAME = getzoneinfofile()
# _ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
_METADATA_FN = 'METADATA'
# python2.6 compatability. Note that TarFile.__exit__ != TarFile.close, but

View file

@ -48,10 +48,10 @@ def _remove_zoneinfo_failed(filename):
# helper to remove old unneeded zoneinfo files
def _remove_old_zoneinfo():
if lib.dateutil.zoneinfo.ZONEINFOFILE is not None:
cur_zoneinfo = ek.ek(basename, lib.dateutil.zoneinfo.ZONEINFOFILE)
else:
zonefilename = lib.dateutil.zoneinfo._ZONEFILENAME
if None is zonefilename:
return
cur_zoneinfo = ek.ek(basename, zonefilename)
cur_file = helpers.real_path(ek.ek(join, ek.ek(os.path.dirname, lib.dateutil.zoneinfo.__file__), cur_zoneinfo))
@ -83,10 +83,10 @@ def _update_zoneinfo():
logger.WARNING)
return
if lib.dateutil.zoneinfo.ZONEINFOFILE is not None:
cur_zoneinfo = ek.ek(basename, lib.dateutil.zoneinfo.ZONEINFOFILE)
else:
cur_zoneinfo = None
zonefilename = lib.dateutil.zoneinfo._ZONEFILENAME
cur_zoneinfo = zonefilename
if None is not cur_zoneinfo:
cur_zoneinfo = ek.ek(basename, zonefilename)
(new_zoneinfo, zoneinfo_md5) = url_data.decode('utf-8').strip().rsplit(u' ')
if (cur_zoneinfo is not None) and (new_zoneinfo == cur_zoneinfo):
@ -215,7 +215,7 @@ def get_network_timezone(network, network_dict):
return sb_timezone
try:
if lib.dateutil.zoneinfo.ZONEINFOFILE is not None:
if lib.dateutil.zoneinfo._ZONEFILENAME is not None:
try:
n_t = tz.gettz(network_dict[network])
except: