Report the v1 and v2 patterns separately

This commit is contained in:
Mark Haines 2016-02-05 15:43:27 +00:00
parent b052621f67
commit 77c7ed0e93
1 changed files with 12 additions and 4 deletions

View File

@ -6,8 +6,13 @@ import os
import sys import sys
import yaml import yaml
PATTERNS = [] PATTERNS_V1 = []
PATTERNS_V2 = []
RESULT = {
"v1": PATTERNS_V1,
"v2": PATTERNS_V2,
}
class CallVisitor(ast.NodeVisitor): class CallVisitor(ast.NodeVisitor):
def visit_Call(self, node): def visit_Call(self, node):
@ -16,10 +21,11 @@ class CallVisitor(ast.NodeVisitor):
else: else:
return return
if name == "client_path_patterns": if name == "client_path_patterns":
PATTERNS.append(node.args[0].s) PATTERNS_V1.append(node.args[0].s)
elif name == "client_v2_patterns": elif name == "client_v2_patterns":
PATTERNS.append(node.args[0].s) PATTERNS_V2.append(node.args[0].s)
def find_patterns_in_code(input_code): def find_patterns_in_code(input_code):
@ -50,5 +56,7 @@ for directory in args.directories:
filepath = os.path.join(root, filename) filepath = os.path.join(root, filename)
find_patterns_in_file(filepath) find_patterns_in_file(filepath)
PATTERNS_V1.sort()
PATTERNS_V2.sort()
yaml.dump(sorted(PATTERNS), sys.stdout, default_flow_style=False) yaml.dump(RESULT, sys.stdout, default_flow_style=False)