Skip to content
Permalink
Browse files

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

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Apr 7, 2018
1 parent fee4d19 commit 92466d0c70ecc0b8a6692038ec22f0d35aba54fd
Showing with 13 additions and 9 deletions.
  1. +5 −0 CHANGES.txt
  2. +7 −8 nikola/plugins/command/init.py
  3. +1 −1 requirements.txt
@@ -1,3 +1,8 @@
New in v7-maintenance
=====================

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

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

@@ -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
@@ -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:
@@ -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

0 comments on commit 92466d0

Please sign in to comment.
You can’t perform that action at this time.