22 lines
580 B
Python
22 lines
580 B
Python
# -*- encoding=utf8 -*-
|
|
|
|
DEFAULT_DOWNLOAD_COUNTRY = "US"
|
|
|
|
|
|
def normalize_country_codes(raw_country_codes):
|
|
if isinstance(raw_country_codes, (list, tuple)):
|
|
raw_items = raw_country_codes
|
|
else:
|
|
raw_items = str(raw_country_codes or "").split(",")
|
|
|
|
country_codes = []
|
|
seen = set()
|
|
for item in raw_items:
|
|
candidate = str(item or "").strip().upper()
|
|
if not candidate or candidate in seen:
|
|
continue
|
|
seen.add(candidate)
|
|
country_codes.append(candidate)
|
|
|
|
return country_codes or [DEFAULT_DOWNLOAD_COUNTRY]
|