mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 20:51:17 +00:00
tools: Fix bug whereby no searches were made
Bad assignment in header file parsing resulted in all commands being pruned before searching for installations. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
1b81c5bde0
commit
9b2eee91b5
@ -10,8 +10,8 @@ from pprint import pprint
|
|||||||
|
|
||||||
# patterns used to extract commands
|
# patterns used to extract commands
|
||||||
command_patterns = [
|
command_patterns = [
|
||||||
r'DEF.*\(.*\n\s*([a-z_]*_cmd)',
|
r'DEF.*\(.*\n\s*([0-9a-z_]*_cmd)',
|
||||||
r'ALIAS.*\(.*\n\s*([a-z_]*_cmd)',
|
r'ALIAS.*\(.*\n\s*([0-9a-z_]*_cmd)',
|
||||||
]
|
]
|
||||||
|
|
||||||
# patterns that count as installing the command
|
# patterns that count as installing the command
|
||||||
@ -30,8 +30,9 @@ def process(filename):
|
|||||||
with open(filename) as cf:
|
with open(filename) as cf:
|
||||||
try:
|
try:
|
||||||
sourcetext = cf.read()
|
sourcetext = cf.read()
|
||||||
if os.path.isfile(filename.replace('.c', '.h')):
|
headerfile = filename.replace('.c', '.h')
|
||||||
with open(filename) as hf:
|
if os.path.isfile(headerfile):
|
||||||
|
with open(headerfile) as hf:
|
||||||
headertext = hf.read()
|
headertext = hf.read()
|
||||||
except:
|
except:
|
||||||
print('Error reading {0}, skipping'.format(filename))
|
print('Error reading {0}, skipping'.format(filename))
|
||||||
@ -39,14 +40,13 @@ def process(filename):
|
|||||||
|
|
||||||
# build list of defined commands that aren't mentioned in header
|
# build list of defined commands that aren't mentioned in header
|
||||||
for pattern in command_patterns:
|
for pattern in command_patterns:
|
||||||
for match in re.findall(pattern, sourcetext, re.M):
|
matches = re.findall(pattern, sourcetext, re.M)
|
||||||
if re.search(match, headertext) is None:
|
cmds += filter(lambda x: re.search(x, headertext) is None, matches)
|
||||||
cmds.append(match)
|
|
||||||
|
|
||||||
# build list of not installed commands
|
# build list of not installed commands
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
pats = [ ip.format(cmd) for ip in install_patterns ]
|
pats = [ ip.format(cmd) for ip in install_patterns ]
|
||||||
if not any([ re.search(pat, sourcetext) is not None for pat in pats ]):
|
if all([ re.search(pat, sourcetext) is None for pat in pats ]):
|
||||||
uninstalled.append(cmd)
|
uninstalled.append(cmd)
|
||||||
|
|
||||||
if len(uninstalled) > 0:
|
if len(uninstalled) > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user