5 |
import sys |
import sys |
6 |
import re |
import re |
7 |
|
|
|
if len(sys.argv) == 3: |
|
|
path = sys.argv[1] |
|
|
outFile = sys.argv[2] |
|
|
elif len(sys.argv) == 2: |
|
|
if sys.argv[1] == '--help' or sys.argv[1] == '-h': |
|
|
print "" |
|
|
print " uso: py2dot.py [directorio-a-procesar[archivo-destino]] " |
|
|
print " ejemplo: py2dot /dir test.dot" |
|
|
print "" |
|
|
sys.exit(0) |
|
|
path = sys.argv[1] |
|
|
outFile = 'outfile.dot' |
|
|
else: |
|
|
path = './' |
|
|
outFile = 'outfile.dot' |
|
|
|
|
|
|
|
|
initialDir = os.path.abspath(os.curdir) |
|
8 |
def surfDirs(path): |
def surfDirs(path): |
9 |
if not path.endswith('/'): path = path + '/' |
if not path.endswith('/'): path = path + '/' |
10 |
dirs = os.listdir(path) |
dirs = os.listdir(path) |
13 |
os.chdir(path+iterFile) |
os.chdir(path+iterFile) |
14 |
surfDirs(path+iterFile) |
surfDirs(path+iterFile) |
15 |
|
|
16 |
|
|
17 |
if iterFile.endswith('.py'): |
if iterFile.endswith('.py'): |
18 |
file = open(path+iterFile) |
file = open(path+iterFile) |
19 |
line = file.readline() |
line = file.readline() |
43 |
line = file.readline() |
line = file.readline() |
44 |
file.close() |
file.close() |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
# Main program |
49 |
|
|
50 |
|
if len(sys.argv) == 3: |
51 |
|
path = sys.argv[1] |
52 |
|
outFile = sys.argv[2] |
53 |
|
elif len(sys.argv) == 2: |
54 |
|
if sys.argv[1] == '--help' or sys.argv[1] == '-h': |
55 |
|
print "" |
56 |
|
print " uso: py2dot.py [directorio-a-procesar[archivo-destino]] " |
57 |
|
print " ejemplo: py2dot /dir test.dot" |
58 |
|
print "" |
59 |
|
sys.exit(0) |
60 |
|
if sys.argv[1].startswith('./'): |
61 |
|
path = os.path.abspath(os.curdir) + sys.argv[1][1:] |
62 |
|
else: |
63 |
|
path = sys.argv[1] |
64 |
|
outFile = 'outfile.dot' |
65 |
|
else: |
66 |
|
path = os.path.abspath(os.curdir) |
67 |
|
outFile = 'outfile.dot' |
68 |
|
|
69 |
|
|
70 |
|
initialDir = os.path.abspath(os.curdir) |
71 |
|
|
72 |
|
|
73 |
classes = {} |
classes = {} |
74 |
surfDirs(path) |
surfDirs(path) |
75 |
|
|