Static analyzer checks on argparser.krk

This commit is contained in:
K. Lange 2022-03-29 09:21:57 +09:00
parent 7f661c285f
commit c313ba25db

View file

@ -169,7 +169,7 @@ class ArgParser():
optqueue.append(arg) optqueue.append(arg)
argqueue.append(None) argqueue.append(None)
elif '=' in arg: elif '=' in arg:
arg_opt = arg[:arg.index('=')] let arg_opt = arg[:arg.index('=')]
if (arg_opt in self.optmap) and (self.optmap[arg_opt][1] >= ARGUMENTED): if (arg_opt in self.optmap) and (self.optmap[arg_opt][1] >= ARGUMENTED):
optqueue.append(arg_opt) optqueue.append(arg_opt)
argqueue.append(arg[arg.index('=') + 1:]) argqueue.append(arg[arg.index('=') + 1:])
@ -232,7 +232,7 @@ class ArgParser():
if arg[0] == VARIADIC: if arg[0] == VARIADIC:
varopt = self.opts[arg[1][0]] varopt = self.opts[arg[1][0]]
if varopt is not None: if varopt is not None:
additional = ','.join(self.files).split(',') if len(self.files) > 0 else [] let additional = ','.join(self.files).split(',') if len(self.files) > 0 else []
if varopt[0] is None: if varopt[0] is None:
self.opts[arg[1][0]] = additional self.opts[arg[1][0]] = additional
else: else:
@ -263,7 +263,7 @@ class ArgParser():
let desc = self.__longdescription let desc = self.__longdescription
if not use_colours: if not use_colours:
while '\[' in desc: while '\[' in desc:
esc = desc.find('\[') let esc = desc.find('\[')
desc = desc[:esc] + desc[desc.find('m', esc) + 1:] desc = desc[:esc] + desc[desc.find('m', esc) + 1:]
print(desc) print(desc)
print() print()
@ -277,7 +277,7 @@ class ArgParser():
print(' or', end='') print(' or', end='')
if not use_colours: if not use_colours:
while '\[' in line: while '\[' in line:
esc = line.find('\[') let esc = line.find('\[')
line = line[:esc] + line[line.find('m', esc) + 1:] line = line[:esc] + line[line.find('m', esc) + 1:]
print('\t{}'.format(line)) print('\t{}'.format(line))
print() print()