Created
August 7, 2018 17:28
-
-
Save fabito/f5a26c7440ecbb722020b360e75c0bdd to your computer and use it in GitHub Desktop.
Simple python script to list all references to the cv namespace.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
from collections import namedtuple, defaultdict | |
import re | |
pattern = re.compile("cv::(\w+)") | |
deps = defaultdict(list) | |
p = Path('.') | |
for i in p.glob('**/*.*pp'): | |
print(i) | |
for line_number, line in enumerate(open(i)): | |
for match in re.finditer(pattern, line): | |
dep = match.groups()[0] | |
data = (i.name, line_number) | |
deps[dep].append(data) | |
with open('deps.txt', 'w') as deps_txt: | |
for d in deps: | |
all_refs = [refs[0] for refs in deps[d]] | |
unique_refs = set(all_refs) | |
deps_txt.write('{},"{}",{}\n'.format(d, ';'.join(unique_refs), len(all_refs))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment