Skip to content

Commit

Permalink
Use documented dateutil API for time zone list (Issue #3006)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 7, 2018
1 parent fee4d19 commit 92466d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,8 @@
New in v7-maintenance
=====================

* Use documented dateutil API for time zone list (Issue #3006)

New in v7.8.14
==============

Expand Down
15 changes: 7 additions & 8 deletions nikola/plugins/command/init.py
Expand Up @@ -38,7 +38,6 @@
import dateutil.zoneinfo
from mako.template import Template
from pkg_resources import resource_filename
import tarfile

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

if tz is None:
print(" WARNING: Time zone not found. Searching list of time zones for a match.")
zonesfile = tarfile.open(fileobj=dateutil.zoneinfo.getzoneinfofile_stream())
zonenames = [zone for zone in zonesfile.getnames() if answer.lower() in zone.lower()]
if len(zonenames) == 1:
tz = dateutil.tz.gettz(zonenames[0])
answer = zonenames[0]
all_zones = dateutil.zoneinfo.get_zonefile_instance().zones
matching_zones = [zone for zone in all_zones if answer.lower() in zone.lower()]
if len(matching_zones) == 1:
tz = dateutil.tz.gettz(matching_zones[0])
answer = matching_zones[0]
print(" Picking '{0}'.".format(answer))
elif len(zonenames) > 1:
elif len(matching_zones) > 1:
print(" The following time zones match your query:")
print(' ' + '\n '.join(zonenames))
print(' ' + '\n '.join(matching_zones))
continue

if tz is not None:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,6 +1,6 @@
Pygments>=1.6
Pillow>=2.4.0
python-dateutil>=2.4.0
python-dateutil>=2.6.0
docutils>=0.12
mako>=1.0.0
Markdown>=2.4.0
Expand Down

0 comments on commit 92466d0

Please sign in to comment.