From 0fde2f779e431d8e354f2a656156a47bf3bc96ac Mon Sep 17 00:00:00 2001 From: JackDandy Date: Sun, 14 Jun 2015 02:11:37 +0100 Subject: [PATCH] Change zoneinfo update/loader to be compatible with dateutil 2.4.2. --- CHANGES.md | 1 + HACKS.txt | 1 + lib/dateutil/zoneinfo/.gitignore | 1 + lib/dateutil/zoneinfo/__init__.py | 12 +++++++++++- sickbeard/network_timezones.py | 16 ++++++++-------- 5 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 lib/dateutil/zoneinfo/.gitignore diff --git a/CHANGES.md b/CHANGES.md index c8b48cb8..3a6380ec 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/HACKS.txt b/HACKS.txt index cbae91d6..ea962cb7 100644 --- a/HACKS.txt +++ b/HACKS.txt @@ -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 diff --git a/lib/dateutil/zoneinfo/.gitignore b/lib/dateutil/zoneinfo/.gitignore new file mode 100644 index 00000000..335ec957 --- /dev/null +++ b/lib/dateutil/zoneinfo/.gitignore @@ -0,0 +1 @@ +*.tar.gz diff --git a/lib/dateutil/zoneinfo/__init__.py b/lib/dateutil/zoneinfo/__init__.py index ff59639c..473d0998 100644 --- a/lib/dateutil/zoneinfo/__init__.py +++ b/lib/dateutil/zoneinfo/__init__.py @@ -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 diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index d4563c8d..dca1a8f3 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -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: