clarifying output

This commit is contained in:
Alarig Le Lay 2020-11-30 12:32:05 +01:00
parent 2b8f378a9d
commit a974495bea
No known key found for this signature in database
GPG Key ID: C865491BF197B54F
1 changed files with 9 additions and 11 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import csv
@ -16,7 +17,7 @@ import sys
parser = argparse.ArgumentParser(description='''Find cities code from UNLOCODE.
If the exact name is found when a country code is given, only this match will
be shown, all the MATCHES are displayed otherwise. The font case isnt taken in
%s/EXACT_MATCH/EXACT_MATCH/account but the accents are. ''')
account but the accents are.''')
parser.add_argument('--city', dest='city', type=str, required=True,
help='City name, will be looked for inside the CSV files')
parser.add_argument('--country', dest='country', type=str, required=False,
@ -45,14 +46,7 @@ def csvloop(file):
entries = csv.reader(file)
for entry in entries:
if len( > 0:
if == entry[1].lower():
def print_results(exactitude, result_list):
"""Stupid function to print results based on very basic formating
@ -88,7 +82,11 @@ if len(EXACT_MATCH) > 0:
print_results('Exact match', EXACT_MATCH)
# If the country hasnt been provided but the cit(y|es) exist(s)
elif len(MULTIPLE_MATCHES) > 0:
print_results('Multiple MATCHES', MULTIPLE_MATCHES)
print_results('Multiple matches', MULTIPLE_MATCHES)
# Otherwise, throw some garbage to the user
print_results('Non-exact MATCHES', MATCHES)
if len( > 0:
print('Country code has been provided, but no match has been found.',
print('Falling back to worldwide lookup.', file=sys.stderr)
print_results('Non-exact matches', MATCHES)