Address N818

https://peps.python.org/pep-0008/#exception-names

Signed-off-by: Alfred Wingate <parona@protonmail.com>
This commit is contained in:
Alfred Wingate 2023-11-16 05:17:14 +02:00
parent 764bcf9ce8
commit 9f7ba6c9cd
No known key found for this signature in database
GPG Key ID: A12750536B5E7010

View File

@ -199,7 +199,7 @@ def print_usage(_error=None, help=None):
# turquoise("`man %s`" % __productname__), file=out) # turquoise("`man %s`" % __productname__), file=out)
class ParseArgsException(Exception): class ParseArgsError(Exception):
"""For parseArgs() -> main() communications.""" """For parseArgs() -> main() communications."""
def __init__(self, value): def __init__(self, value):
@ -220,9 +220,9 @@ def parse_args():
return_code = True return_code = True
for o, a in opts: for o, a in opts:
if o in ("-h", "--help"): if o in ("-h", "--help"):
raise ParseArgsException("help") raise ParseArgsError("help")
elif o in ("-V", "--version"): elif o in ("-V", "--version"):
raise ParseArgsException("version") raise ParseArgsError("version")
elif o in ("-C", "--nocolor"): elif o in ("-C", "--nocolor"):
CONFIG["nocolor"] = True CONFIG["nocolor"] = True
pp.output.nocolor() pp.output.nocolor()
@ -284,13 +284,13 @@ def parse_args():
try: try:
opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts) opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
except getopt.GetoptError: except getopt.GetoptError:
raise ParseArgsException(opts_mode + "-options") raise ParseArgsError(opts_mode + "-options")
# set options accordingly # set options accordingly
option_switch(opts) option_switch(opts)
if len(args) < 1: if len(args) < 1:
raise ParseArgsException("packages") raise ParseArgsError("packages")
return args return args
@ -306,7 +306,7 @@ def main():
# parse command line options and actions # parse command line options and actions
try: try:
queries = parse_args() queries = parse_args()
except ParseArgsException as e: except ParseArgsError as e:
if e.value == "help": if e.value == "help":
print_usage(help="all") print_usage(help="all")
exit_helper(0) exit_helper(0)