mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 03:03:57 +08:00
* lgtm in readme, and mac nui fixes
* call super inits in radars
* unused imports, dup lines
* more radars, more unused imports
* pass CP into RadarInterfaceBase
* more fixups
* unused imports
* delete unused lines
* ugh, new unused import
Co-authored-by: George Hotz <geohot@gmail.com>
old-commit-hash: 1295cfe06c
42 lines
992 B
Python
Executable File
42 lines
992 B
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import ast
|
|
import stat
|
|
import subprocess
|
|
|
|
fouts = set([x.decode('utf-8') for x in subprocess.check_output(['git', 'ls-files']).strip().split()])
|
|
|
|
pyf = []
|
|
for d in ["cereal", "common", "scripts", "selfdrive", "tools"]:
|
|
for root, dirs, files in os.walk(d):
|
|
for f in files:
|
|
if f.endswith(".py"):
|
|
pyf.append(os.path.join(root, f))
|
|
|
|
imps = set()
|
|
|
|
class Analyzer(ast.NodeVisitor):
|
|
def visit_Import(self, node):
|
|
for alias in node.names:
|
|
imps.add(alias.name)
|
|
self.generic_visit(node)
|
|
def visit_ImportFrom(self, node):
|
|
imps.add(node.module)
|
|
self.generic_visit(node)
|
|
|
|
tlns = 0
|
|
for f in sorted(pyf):
|
|
if f not in fouts:
|
|
continue
|
|
xbit = bool(os.stat(f)[stat.ST_MODE] & stat.S_IXUSR)
|
|
src = open(f).read()
|
|
lns = len(src.split("\n"))
|
|
tree = ast.parse(src)
|
|
Analyzer().visit(tree)
|
|
print("%5d %s %s" % (lns, f, xbit))
|
|
tlns += lns
|
|
|
|
print("%d lines of parsed openpilot python" % tlns)
|
|
#print(sorted(list(imps)))
|
|
|