Skip to content

Commit e0e03a6

Browse files
committed
Minor
1 parent 987bd67 commit e0e03a6

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎language_tool/country_codes.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"Namibia": "NA",
126126
"Nauru": "NR",
127127
"Nepal": "NP",
128-
"Netherlands": "NL", # Kingdom of the Netherlands
128+
"Netherlands": "NL", # Kingdom of the Netherlands
129129
"New Zealand": "NZ",
130130
"Nicaragua": "NI",
131131
"Niger": "NE",
@@ -172,6 +172,7 @@
172172
"Suriname": "SR",
173173
"Swaziland": "SZ",
174174
"Sweden": "SE",
175+
"Swiss": "CH", # Switzerland
175176
"Switzerland": "CH",
176177
"Syria": "SY",
177178
"São Tomé and Príncipe": "ST",
@@ -203,21 +204,15 @@
203204
"Zimbabwe": "ZW",
204205
}
205206

206-
LANGUAGE_TO_COUNTRY = {
207-
"Swiss": "CH",
208-
}
209-
210207

211208
def get_country_code(country_name):
209+
"""Lookup two-letter country code from country name.
210+
"""
212211
if country_name in COUNTRY_CODES.values():
213212
return country_name
214213

215214
matches = difflib.get_close_matches(country_name, COUNTRY_CODES, 1)
216215
if matches:
217216
return COUNTRY_CODES[matches[0]]
218217

219-
matches = difflib.get_close_matches(country_name, LANGUAGE_TO_COUNTRY, 1)
220-
if matches:
221-
return LANGUAGE_TO_COUNTRY[matches[0]]
222-
223218
raise KeyError(country_name)

0 commit comments

Comments
 (0)