diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-10-25 04:01:50 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-10-25 04:01:50 +0000 |
| commit | 9b2eee91b52ed097d7837ad0400af6d4b78b13a1 (patch) | |
| tree | 00b54563ca9c15dd7ab6882f53f698a95a4dc36a | |
| parent | 1b81c5bde02dd290fb0d37bc67c19b066f1e7fc8 (diff) | |
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>
| -rwxr-xr-x | tools/cmd_check.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tools/cmd_check.py b/tools/cmd_check.py index e632c3ecc5..5bd8032b70 100755 --- a/tools/cmd_check.py +++ b/tools/cmd_check.py @@ -10,8 +10,8 @@ from pprint import pprint # patterns used to extract commands command_patterns = [ - r'DEF.*\(.*\n\s*([a-z_]*_cmd)', - r'ALIAS.*\(.*\n\s*([a-z_]*_cmd)', + r'DEF.*\(.*\n\s*([0-9a-z_]*_cmd)', + r'ALIAS.*\(.*\n\s*([0-9a-z_]*_cmd)', ] # patterns that count as installing the command @@ -30,8 +30,9 @@ def process(filename): with open(filename) as cf: try: sourcetext = cf.read() - if os.path.isfile(filename.replace('.c', '.h')): - with open(filename) as hf: + headerfile = filename.replace('.c', '.h') + if os.path.isfile(headerfile): + with open(headerfile) as hf: headertext = hf.read() except: 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 for pattern in command_patterns: - for match in re.findall(pattern, sourcetext, re.M): - if re.search(match, headertext) is None: - cmds.append(match) - + matches = re.findall(pattern, sourcetext, re.M) + cmds += filter(lambda x: re.search(x, headertext) is None, matches) + # build list of not installed commands for cmd in cmds: 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) if len(uninstalled) > 0: |
