in python/fb_ads_library_api_cli.py [0:0]
def validate_country_param(country_input):
if not country_input:
return ""
country_list = list(filter(lambda x: x.strip(), country_input.split(",")))
if not country_list:
raise argparse.ArgumentTypeError("Country cannot be empty")
valid_country_codes = list(map(lambda x: get_country_code(x), country_list))
invalid_inputs = {
key: value
for (key, value) in zip(country_list, valid_country_codes)
if value is None
}
if invalid_inputs:
raise argparse.ArgumentTypeError(
"Invalid/unsupported country code: %s" % (",".join(invalid_inputs.keys()))
)
else:
return ",".join(valid_country_codes)