# Buggy code
def tzhandler(default, toconf):
    print(
        "\nPlease choose the correct time zone for your blog. Nikola uses the tz database."
    )
    print("You can find your time zone here:")
    print("https://en.wikipedia.org/wiki/List_of_tz_database_time_zones")
    print("")
    answered = False
    while not answered:
        try:
            lz = get_localzone()
        except Exception:
            lz = None
        answer = ask("Time zone", lz if lz else "UTC")
        tz = dateutil.tz.gettz(answer)

        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]
                print("    Picking '{0}'.".format(answer))
            elif len(zonenames) > 1:
                print("    The following time zones match your query:")
                print("        " + "\n        ".join(zonenames))
                continue

        if tz is not None:
            time = datetime.datetime.now(tz).strftime("%H:%M:%S")
            print("    Current time in {0}: {1}".format(answer, time))
            answered = ask_yesno("Use this time zone?", True)
        else:
            print("    ERROR: No matches found.  Please try again.")

    SAMPLE_CONF["TIMEZONE"] = answer


# Traceback (ValueError)
# nikola init
[..]
Time zone [UTC]: Berlin
[2018-04-01T17:00:31Z] WARNING: UserWarning: /usr/lib64/python3.5/site-packages/dateutil/zoneinfo/__init__.py:26: I/O error(2): No such file or directory
WARNING: Time zone not found.  Searching list of time zones for a match.
Traceback (most recent call last):
File "/usr/lib64/python3.5/site-packages/doit/doit_cmd.py", line 168, in run
return command.parse_execute(args)
File "/usr/lib64/python3.5/site-packages/doit/cmd_base.py", line 122, in parse_execute
return self.execute(params, args)
File "/usr/lib64/python3.5/site-packages/nikola/plugin_categories.py", line 134, in execute
return self._execute(options, args)
File "/usr/lib64/python3.5/site-packages/nikola/plugins/command/init.py", line 495, in _execute
st = self.ask_questions(target=target, demo=options.get('demo'))
File "/usr/lib64/python3.5/site-packages/nikola/plugins/command/init.py", line 467, in ask_questions
query(default, toconf)
File "/usr/lib64/python3.5/site-packages/nikola/plugins/command/init.py", line 390, in tzhandler
zonesfile = tarfile.open(fileobj=dateutil.zoneinfo.getzoneinfofile_stream())
File "/usr/lib64/python3.5/tarfile.py", line 1548, in open
raise ValueError("nothing to open")
ValueError: nothing to open

# Fixed code
def tzhandler(default, toconf):
    print(
        "\nPlease choose the correct time zone for your blog. Nikola uses the tz database."
    )
    print("You can find your time zone here:")
    print("https://en.wikipedia.org/wiki/List_of_tz_database_time_zones")
    print("")
    answered = False
    while not answered:
        try:
            lz = get_localzone()
        except Exception:
            lz = None
        answer = ask("Time zone", lz if lz else "UTC")
        tz = dateutil.tz.gettz(answer)

        if tz is None:
            print(
                "    WARNING: Time zone not found.  Searching list of time zones for a match."
            )
            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(matching_zones) > 1:
                print("    The following time zones match your query:")
                print("        " + "\n        ".join(matching_zones))
                continue

        if tz is not None:
            time = datetime.datetime.now(tz).strftime("%H:%M:%S")
            print("    Current time in {0}: {1}".format(answer, time))
            answered = ask_yesno("Use this time zone?", True)
        else:
            print("    ERROR: No matches found.  Please try again.")

    SAMPLE_CONF["TIMEZONE"] = answer