From 2af8803dcc2dd27bbc462670220f05d6b801fce4 Mon Sep 17 00:00:00 2001 From: yzqzss Date: Wed, 4 Dec 2024 17:27:03 +0800 Subject: [PATCH] minor refactor: exnamespaces --- wikiteam3/dumpgenerator/cli/cli.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/wikiteam3/dumpgenerator/cli/cli.py b/wikiteam3/dumpgenerator/cli/cli.py index a2049422..4436ca14 100644 --- a/wikiteam3/dumpgenerator/cli/cli.py +++ b/wikiteam3/dumpgenerator/cli/cli.py @@ -501,19 +501,13 @@ def sleep(self, response=None): # Process namespace exclusions if args.exnamespaces: - # if re.search(r"[^\d, \-]", args.exnamespaces): - if any([not i.isdigit() for i in args.exnamespaces.split(",")]): + try: + exnamespaces = [int(i) for i in ns.split(",")] + except ValueError: print( "Invalid namespace values.\nValid format is integer(s) separated by commas" ) sys.exit(1) - else: - ns = args.exnamespaces.replace(" ", "") - if ns.lower() == "all": - print("You cannot exclude all namespaces.") - sys.exit(1) - else: - exnamespaces = [int(i) for i in ns.split(",")] config = Config(