6 from pathlib
import Path
8 IODA_CONV_PATH = Path(__file__).parent/
"@SCRIPT_LIB_PATH@"
9 if not IODA_CONV_PATH.is_dir():
10 IODA_CONV_PATH = Path(__file__).parent/
'..'/
'lib-python'
11 sys.path.append(
str(IODA_CONV_PATH.resolve()))
13 from utils
import collect_sources
17 code = py_source.text()
18 tree = compile(code, py_source,
"exec", ast.PyCF_ONLY_AST)
19 visitor = mccabe.PathGraphingAstVisitor()
20 visitor.preorder(tree, visitor)
21 for graph
in visitor.graphs.values():
22 if graph.complexity() > max_complexity:
23 text =
"{}:{}:{} {} {}"
24 return text.format(py_source,
25 graph.lineno, graph.column,
26 graph.entity, graph.complexity())
30 max_complexity =
int(sys.argv[1])
33 error =
process(py_source, max_complexity)
41 if __name__ ==
"__main__":
def process(py_source, max_complexity)