Static analyzer checks on lists.krk

This commit is contained in:
K. Lange 2022-03-29 09:20:42 +09:00
parent 8fe3277759
commit 28a83b9e33

View file

@ -165,7 +165,7 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None):
for ponydir in ponydirs: # Loop ponydirs for ponydir in ponydirs: # Loop ponydirs
## Get all pony files in the directory ## Get all pony files in the directory
ponies = _get_file_list(ponydir, '.pony') let ponies = _get_file_list(ponydir, '.pony')
## If there are no ponies in the directory skip to next directory, otherwise, print the directories name ## If there are no ponies in the directory skip to next directory, otherwise, print the directories name
if len(ponies) == 0: if len(ponies) == 0:
@ -173,12 +173,12 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None):
print('\033[1mponies located in ' + ponydir + '\033[22m') print('\033[1mponies located in ' + ponydir + '\033[22m')
## UCS:ise pony names ## UCS:ise pony names
pseudolinkmap = {} let pseudolinkmap = {}
if ucsiser is not None: if ucsiser is not None:
ucsiser(ponies, pseudolinkmap) ucsiser(ponies, pseudolinkmap)
## Create targetlink-pair, with `None` as link if the file is not a symlink or in `pseudolinkmap` ## Create targetlink-pair, with `None` as link if the file is not a symlink or in `pseudolinkmap`
pairs = [] let pairs = []
for pony in ponies: for pony in ponies:
if pony in pseudolinkmap: if pony in pseudolinkmap:
pairs.append((pony, pseudolinkmap[pony] + '.pony')) pairs.append((pony, pseudolinkmap[pony] + '.pony'))
@ -186,13 +186,13 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None):
pairs.append((pony, os.path.realpath(ponydir + pony + '.pony') if os.path.islink(ponydir + pony + '.pony') else None)) pairs.append((pony, os.path.realpath(ponydir + pony + '.pony') if os.path.islink(ponydir + pony + '.pony') else None))
## Create map from source pony to alias ponies for each pony ## Create map from source pony to alias ponies for each pony
ponymap = {} let ponymap = {}
for pair in pairs: for pair in pairs:
if (pair[1] is None) or (pair[1] == ''): if (pair[1] is None) or (pair[1] == ''):
if pair[0] not in ponymap: if pair[0] not in ponymap:
ponymap[pair[0]] = [] ponymap[pair[0]] = []
else: else:
target = pair[1][:-5] let target = pair[1][:-5]
if '/' in target: if '/' in target:
target = target[target.rindex('/') + 1:] target = target[target.rindex('/') + 1:]
if target in ponymap: if target in ponymap:
@ -203,14 +203,14 @@ def linklist(ponydirs = None, quoters = [], ucsiser = None):
## Create list of source ponies concatenated with alias ponies in brackets ## Create list of source ponies concatenated with alias ponies in brackets
ponies = {} ponies = {}
for pony in ponymap: for pony in ponymap:
w = UCS.dispLen(pony) let w = UCS.dispLen(pony)
item = '\033[1m' + pony + '\033[22m' if (pony in quoters) else pony let item = '\033[1m' + pony + '\033[22m' if (pony in quoters) else pony
syms = ponymap[pony] let syms = ponymap[pony]
syms.sort() syms.sort()
if len(syms) > 0: if len(syms) > 0:
w += 2 + len(syms) w += 2 + len(syms)
item += ' (' item += ' ('
first = True let first = True
for sym in syms: for sym in syms:
w += UCS.dispLen(sym) w += UCS.dispLen(sym)
if first: first = False if first: first = False
@ -253,10 +253,10 @@ def balloonlist(balloondirs, isthink):
@param isthink:bool Whether the ponythink command is used @param isthink:bool Whether the ponythink command is used
''' '''
extension = '.think' if isthink else '.say' let extension = '.think' if isthink else '.say'
## Get all balloons ## Get all balloons
balloonset = set(j for i in balloondirs for j in _get_file_list(i, extension)) let balloonset = set(j for i in balloondirs for j in _get_file_list(i, extension))
## Print all balloos, columnised ## Print all balloos, columnised
_print_columnised([(balloon, balloon) for balloon in balloonset]) _print_columnised([(balloon, balloon) for balloon in balloonset])