Simplify region filtering by setting a default value

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2019-12-28 13:36:57 +01:00
parent bb905fd0b9
commit ff562b8a9e

View file

@ -70,7 +70,7 @@ def update_locales(locales, regions, years):
for line in lines.split('\n'):
if line:
j = json.loads(line)
if j['region'] == '' or regions is None or len(regions) == 0 or j['region'] in regions:
if not j['region'] or not regions or j['region'] in regions:
day = j['date'].replace("-", "_")
desc = j['description']
fh.write(" {} = {}\n".format(day, desc))
@ -104,7 +104,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Update holiday data files. Simply run 'refresh' to update all of them.")
parser.add_argument('--locale', nargs='+', help='Specific locale to update.')
parser.add_argument('--region', nargs='+', help='Specific locale region to update.')
parser.add_argument('--region', nargs='+', help='Specific locale region to update.', default=[])
parser.add_argument('--year', nargs='+', help='Specific year to fetch.', type=int, default=[])
args = parser.parse_args()