File: find_extended.py

package info (click to toggle)
python-box2d 2.3.2~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,596 kB
  • ctags: 5,116
  • sloc: python: 14,384; cpp: 13,393; makefile: 9
file content (46 lines) | stat: -rw-r--r-- 1,116 bytes parent folder | download | duplicates (2)
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
from __future__ import print_function
import glob
import re
import os
from all_classes import *

files = glob.glob('../Box2D/Box2D_*.i')
classes = {}
ignore_files = [
        'Box2D_kwargs.i', 
        'Box2D_dir.i', 
        ]

def find_extended(path):
    f = open(path, "r")
    fn = os.path.split(path)[1]
    for line in f.readlines():
        m=re.search('%extend\s*(.*)\s*{', line)
        if m:
            cls=m.groups()[0].strip()
            if cls in classes:
                if fn not in classes[cls]:
                    classes[cls].append(fn)
            else:
                classes[cls] = [fn]

    f.close()

for file in files:
    if os.path.split(file)[1] not in ignore_files:
        find_extended(file)

print("%19s  %s" % ('Class', 'Extended in'))
remaining=list(all_classes)
for key, value in list(classes.items()):
    print("%20s %s" % (key, ', '.join(value)))
    remaining.remove(key)

ignore_unmodified=[s for s in remaining if s[-3:] == 'Def']
#ignore_unmodified += []

print()
print("Unmodified classes")
for cls in remaining:
    if cls not in ignore_unmodified:
        print(cls)