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 6071041

Browse files
committedApr 2, 2018
Fix #3006 -- use documented dateutil API for time zone list
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 2d759c5 commit 6071041

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed
 

‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Features
3838
Bugfixes
3939
--------
4040

41+
* Use documented dateutil API for time zone list (Issue #3006)
4142
* Handle trailing slash redirects with query strings correctly in
4243
``nikola serve`` (Issue #3000)
4344
* Fix w3c validation errors for itemscope entries in default themes

‎nikola/plugins/command/init.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import dateutil.zoneinfo
3838
from mako.template import Template
3939
from pkg_resources import resource_filename
40-
import tarfile
4140

4241
import nikola
4342
from nikola.nikola import DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
@@ -384,15 +383,15 @@ def tzhandler(default, toconf):
384383

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

398397
if tz is not None:

‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
doit>=0.30.1
22
Pygments>=1.6
33
Pillow>=2.4.0
4-
python-dateutil>=2.4.0
4+
python-dateutil>=2.6.0
55
docutils>=0.13
66
mako>=1.0.0
77
Markdown>=2.4.0

0 commit comments

Comments
 (0)
Please sign in to comment.