diff options
author | Anders Einar Hilden <hildenae@gmail.com> | 2015-07-05 20:08:58 +0200 |
---|---|---|
committer | Anders Einar Hilden <hildenae@gmail.com> | 2015-07-05 20:08:58 +0200 |
commit | 693d31aace56df93911e9114b6c5cfe7d30bfe36 (patch) | |
tree | 4c33822d6f3f01f7feacdecf3febaa1d77c6545e /python | |
parent | 24a0618550c568f3a1c6318387ce78559dc1ef6d (diff) |
Python: Fix handling of "all" categories
Diffstat (limited to 'python')
-rwxr-xr-x | python/etatsbasen.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/python/etatsbasen.py b/python/etatsbasen.py index 24e6267..65785a3 100755 --- a/python/etatsbasen.py +++ b/python/etatsbasen.py @@ -38,6 +38,8 @@ rename = { def filter_orgstructid(row, categories): if row == None: return None + if len(categories) == 1 and categories[0] == "all": + return row if int(row["orgstructid"]) in categories: return row else: @@ -61,7 +63,6 @@ def filter_email(row): return row - def printCSV(options): print(options) with open(options["inputfile"], newline='') as csvfile: @@ -100,7 +101,10 @@ if __name__ == "__main__": else: options["headers"] = None try: - options["categories"] = [ int(x) for x in args.c.split(',') ] + if args.c == "all": + options["categories"] = ["all"] + else: + options["categories"] = [ int(x) for x in args.c.split(',') ] except ValueError as ve: print("Failed to parse \"-c %s\"; Categories must comma separated list of only integers" % (args.c), file=sys.stderr) sys.exit(0) |