]> dev.renevier.net Git - syp.git/blob - openlayers/tools/oldot.py
move templates to a specific directory
[syp.git] / openlayers / tools / oldot.py
1 import re
2 import os    
3 def run():
4     sourceDirectory = "../lib/OpenLayers"    
5     allFiles = []
6     SUFFIX_JAVASCRIPT = ".js"
7     ## Find all the Javascript source files
8     for root, dirs, files in os.walk(sourceDirectory):
9         for filename in files:
10             if filename.endswith(SUFFIX_JAVASCRIPT) and not filename.startswith("."):
11                 filepath = os.path.join(root, filename)[len(sourceDirectory)+1:]
12                 filepath = filepath.replace("\\", "/")
13                 data = open(os.path.join(sourceDirectory, filepath)).read()
14                 parents = re.search("OpenLayers.Class\((.*?){", data, 
15                       re.DOTALL)
16                 if parents:
17                     parents = [x.strip() for x in parents.group(1).strip().strip(",").split(",")]
18                 else: 
19                     parents = []
20                 cls = "OpenLayers.%s" % filepath.strip(".js").replace("/", ".")
21                 allFiles.append([cls, parents])
22     return allFiles
23 print """
24 digraph name {
25   fontname = "Helvetica"
26   fontsize = 8
27   K = 0.6
28
29   node [
30     fontname = "Helvetica"
31     fontsize = 8
32     shape = "plaintext"
33   ]
34 """
35
36 for i in run():
37     print i[0].replace(".", "_")
38     for item in i[1]:
39         if not item: continue
40         print "%s -> %s" % (i[0].replace(".","_"), item.replace(".", "_"))
41     print "; "
42
43 print """}"""