-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagging.py
executable file
·51 lines (40 loc) · 1.19 KB
/
tagging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import ctags, sys
from ctags import CTags, TagEntry
import pygraphviz as pgv
try:
tagFile = CTags('tags')
except:
sys.exit(1)
entry = TagEntry()
patterns = {}
files = {}
# TAG_PARTIALMATCH - begin with
# TAG_FULLMATCH - full length matching
# TAG_IGNORECASE - disable binary search
# TAG_OBSERVECASE - case sensitive and allowed binary search to perform
# Find the next tag matching the name and options supplied to the
# most recent call to tagFile.find(). (replace the entry if found)
status = tagFile.next(entry)
while status:
fileName, pattern = entry['file'], entry['name']
if fileName not in files:
files[fileName] = [pattern]
else:
files[fileName] += [pattern]
if pattern not in patterns:
patterns[pattern] = [fileName]
else:
patterns[pattern] += [fileName]
status = tagFile.next(entry)
patternGraph = pgv.AGraph()
for pattern in patterns.keys():
for fileName in patterns[pattern]:
patternGraph.add_edge(pattern, fileName)
fileGraph = pgv.AGraph()
for fileName in files.keys():
for pattern in files[fileName]:
fileGraph.add_edge(fileName, pattern)
patternGraph.layout()
patternGraph.draw('patterns.png', prog='circo')
fileGraph.layout()
fileGraph.draw('files.png', prog='circo')