File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1+ from itertools import chain
2+
13# Default country code.
24default_code = "XX"
35
359361 # "Cruise Ship" has no mapping, i.e. the default val is used
360362}
361363
362- def country_code (country ):
364+ def country_code (country , verbose = True ):
363365 """
364366 Return two letter country code (Alpha-2) according to https://en.wikipedia.org/wiki/ISO_3166-1
365367 Defaults to "XX".
@@ -371,5 +373,15 @@ def country_code(country):
371373 synonym = synonyms [country ]
372374 return is_3166_1 [synonym ]
373375 else :
374- print ("No country_code found for '" + country + "'. Using '" + default_code + "'" )
376+ if verbose :
377+ print ("No country_code found for '" + country + "'. Using '" + default_code + "'" )
375378 return default_code
379+
380+ def country_in_database (country ):
381+ """
382+ Checks if a given country is in the database.
383+ """
384+ if country in chain (is_3166_1 , synonyms ):
385+ return True
386+ else :
387+ return False
You can’t perform that action at this time.
0 commit comments