From 7bb03c0b6d2767733c0c448da1ba08ded1c16aa1 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Fri, 28 Sep 2018 14:58:01 +0200 Subject: Now correctly parsing args, we're now able to get argument lists --- refresh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'refresh') diff --git a/refresh b/refresh index d568df1..f6b5cc4 100755 --- a/refresh +++ b/refresh @@ -109,27 +109,29 @@ def hparse(lines, locode, year): sys.stdout.flush() def main(args): - if args.locale != "" and args.locale != None: + if args.locale != [] and args.locale != None: locode = str(args.locale[0]) else: - locode = "de-DE" + locode = ["de-DE"] if args.year != None and args.year != []: year = args.year else: now = datetime.now() - year = datetime.now().year + year = [datetime.now().year] year = unicode(year) - sys.stdout.write("Fetching holiday data from holidata.net...") - sys.stdout.flush() - lines = hfetch(locode, year) - print(" done.") - if lines == "": - print("No lines returned from holidata.net for %s!", locode) - exit(3) - sys.stdout.write("Parsing data") - sys.stdout.flush() - hparse(lines, locode, year) - print(" done.") + for i in args.locale: + for j in args.year: + sys.stdout.write("Fetching holiday data from holidata.net... (%s, %s)" % (i, j)) + sys.stdout.flush() + lines = hfetch(unicode(i), unicode(j)) + print(" done.") + if lines == "": + print("No lines returned from holidata.net for %s!", locode) + exit(3) + sys.stdout.write("Parsing data") + sys.stdout.flush() + hparse(lines, unicode(i), unicode(j)) + print(" done.") if __name__ == "__main__": usage = """See https://holidata.net for details of supported locales and regions.""" -- cgit v1.2.3