Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #1599 -- fix zoneinfo reading (dateutil 2.4.0)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 23, 2015
1 parent 4d334f7 commit aea500e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,7 @@ Features
Bugfixes
--------

* Fix zoneinfo reading in ``nikola init`` (Issue #1599)
* Fix ``.islink`` detection for galleries (via Issue #1536)
* Links to languages point to site root and not the blog (Issue #1008)
* Brand link is now language-specific (Issue #1573)
Expand Down
10 changes: 6 additions & 4 deletions nikola/plugins/command/init.py
Expand Up @@ -319,13 +319,15 @@ def tzhandler(default, toconf):
tz = dateutil.tz.gettz(answer)

if tz is None:
print(" WARNING: Time zone not found. Searching most common timezones for a match.")
zonesfile = tarfile.TarFile.open(os.path.join(dateutil.zoneinfo.ZONEINFOFILE))
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]
print(" Picking '{0}'.".format(answer))
elif len(zonenames) > 1:
print(" Could not pick one timezone. Choose one of the following:")
print(" The following time zones match your query:")
print(' ' + '\n '.join(zonenames))
continue

Expand All @@ -334,7 +336,7 @@ def tzhandler(default, toconf):
print(" Current time in {0}: {1}".format(answer, time))
answered = ask_yesno("Use this time zone?", True)
else:
print(" ERROR: Time zone not found. Please try again. Time zones are case-sensitive.")
print(" ERROR: No matches found. Please try again.")

SAMPLE_CONF['TIMEZONE'] = answer

Expand Down

0 comments on commit aea500e

Please sign in to comment.