Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 92466d0

Browse files
committedApr 7, 2018
Use documented dateutil API for time zone list (Issue #3006)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent fee4d19 commit 92466d0

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed
 

‎CHANGES.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
New in v7-maintenance
2+
=====================
3+
4+
* Use documented dateutil API for time zone list (Issue #3006)
5+
16
New in v7.8.14
27
==============
38

‎nikola/plugins/command/init.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import dateutil.zoneinfo
3939
from mako.template import Template
4040
from pkg_resources import resource_filename
41-
import tarfile
4241

4342
import nikola
4443
from nikola.nikola import DEFAULT_TRANSLATIONS_PATTERN, DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
@@ -387,15 +386,15 @@ def tzhandler(default, toconf):
387386

388387
if tz is None:
389388
print(" WARNING: Time zone not found. Searching list of time zones for a match.")
390-
zonesfile = tarfile.open(fileobj=dateutil.zoneinfo.getzoneinfofile_stream())
391-
zonenames = [zone for zone in zonesfile.getnames() if answer.lower() in zone.lower()]
392-
if len(zonenames) == 1:
393-
tz = dateutil.tz.gettz(zonenames[0])
394-
answer = zonenames[0]
389+
all_zones = dateutil.zoneinfo.get_zonefile_instance().zones
390+
matching_zones = [zone for zone in all_zones if answer.lower() in zone.lower()]
391+
if len(matching_zones) == 1:
392+
tz = dateutil.tz.gettz(matching_zones[0])
393+
answer = matching_zones[0]
395394
print(" Picking '{0}'.".format(answer))
396-
elif len(zonenames) > 1:
395+
elif len(matching_zones) > 1:
397396
print(" The following time zones match your query:")
398-
print(' ' + '\n '.join(zonenames))
397+
print(' ' + '\n '.join(matching_zones))
399398
continue
400399

401400
if tz is not None:

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pygments>=1.6
22
Pillow>=2.4.0
3-
python-dateutil>=2.4.0
3+
python-dateutil>=2.6.0
44
docutils>=0.12
55
mako>=1.0.0
66
Markdown>=2.4.0

0 commit comments

Comments
 (0)
Please sign in to comment.