dia r4217 - trunk/plug-ins/python
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4217 - trunk/plug-ins/python
- Date: Sat, 24 Jan 2009 14:17:13 +0000 (UTC)
Author: hans
Date: Sat Jan 24 14:17:13 2009
New Revision: 4217
URL: http://svn.gnome.org/viewvc/dia?rev=4217&view=rev
Log:
wdeps.py : 2006-01-23, white space cleanup, now knows how to remove DLLs from the tree
Modified:
trunk/plug-ins/python/wdeps.py
Modified: trunk/plug-ins/python/wdeps.py
==============================================================================
--- trunk/plug-ins/python/wdeps.py (original)
+++ trunk/plug-ins/python/wdeps.py Sat Jan 24 14:17:13 2009
@@ -15,68 +15,107 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-import sys, os, re, string
+import sys, os, re, string, math
+
+g_maxWeight = 1
class Node :
- def __init__ (self, name) :
- self.name = name
- self.deps = {}
- def AddEdge (self, name, symbols) :
- self.deps[name] = Edge(name, symbols)
+ def __init__ (self, name) :
+ self.name = name
+ self.deps = {}
+ def AddEdge (self, name, symbols) :
+ self.deps[name] = Edge(name, symbols)
class Edge :
- def __init__ (self, name, symbols) :
- self.name = name # the target
- self.weight = len(symbols)
- self.symbols = symbols
-
+ def __init__ (self, name, symbols) :
+ global g_maxWeight
+ self.name = name # the target
+ self.weight = len(symbols)
+ if self.weight > g_maxWeight :
+ g_maxWeight = self.weight
+ self.symbols = symbols
+
def GetDeps (sFrom, dAll) :
- "calculates the dependents of the passed in dll"
- sFrom = string.lower(sFrom)
- if not dAll.has_key (sFrom) :
- node = Node (sFrom)
- f = os.popen ("dumpbin /imports " + sFrom)
- name = None
- arr = []
- s = f.readline ()
- while s :
- r = re.match ("^ (.*\.dll)", s)
- if r :
- name = string.lower(r.group(1))
- #print name
- else :
- # import by name
- r2 = re.match ("^[ ]+[0123456789ABCDEF]+[ ]+(\w+)$", s)
- if not r2 :
- r2 = re.match ("^[ ]+Ordinal[ ]+([1234567890]+)$", s)
- if r2 :
- arr.append (r2.group(1))
- elif s[:-1] == "" and name != None and len(arr) > 0 :
- print name, len(arr)
- node.AddEdge (name, arr)
- arr = []
- GetDeps (name, dAll)
- s = f.readline()
- # add to all nodes
- dAll[sFrom] = node
-
+ "calculates the dependents of the passed in dll"
+ sFrom = string.lower(sFrom)
+ if not dAll.has_key (sFrom) :
+ node = Node (sFrom)
+ f = os.popen ("dumpbin /imports " + sFrom)
+ name = None
+ arr = []
+ s = f.readline ()
+ while s :
+ r = re.match ("^ (.*\.dll)", s)
+ if r :
+ name = string.lower(r.group(1))
+ #print name
+ else :
+ # import by name
+ r2 = re.match ("^[ ]+[0123456789ABCDEF]+[ ]+(\w+)$", s)
+ if not r2 :
+ r2 = re.match ("^[ ]+Ordinal[ ]+([1234567890]+)$", s)
+ if r2 :
+ arr.append (r2.group(1))
+ elif s[:-1] == "" and name != None and len(arr) > 0 :
+ #print name, len(arr)
+ node.AddEdge (name, arr)
+ arr = []
+ GetDeps (name, dAll)
+ s = f.readline()
+ # add to all nodes
+ dAll[sFrom] = node
+
+def Remove (deps, list) :
+ "From the deps tree remove the nodes matching list"
+ for s in list :
+ if deps.has_key (s) :
+ del deps[s]
+ for sn in deps.keys() :
+ node = deps[sn]
+ if node.deps.has_key (s) :
+ del node.deps[s]
+
+# some predefined sets of DLLs, either for hiding from the dependencies or maybe to tin them
+dllsSysWin32 = [
+ "version.dll", "winmm.dll",
+ "kernel32.dll", "user32.dll", "gdi32.dll", "comdlg32.dll", "advapi32.dll", "shell32.dll",
+ "comctl32.dll", "ole32.dll", "oleaut32.dll", "winspool.drv", "imm32.dll",
+ "wsock32.dll", "mpr.dll",
+ "uxtheme.dll"]
+dllsCrts = [
+ "msvcrt.dll", "msvcrtd.dll", "msvcp60.dll",
+ "msvcr71.dll", "msvcr71d.dll", "msvcp71.dll"
+ ]
+dllsGtk = [
+ "libglib-2.0-0.dll", "libgmodule-2.0-0.dll", "libgobject-2.0-0.dll", "libgthread-2.0-0.dll",
+ "libpango-1.0-0.dll", "libpangowin32-1.0-0.dll", "libpangoft2-1.0-0.dll", "libpangocairo-1.0-0.dll",
+ "libgdk_pixbuf-2.0-0.dll", "libgdk-win32-2.0-0.dll", "libgtk-win32-2.0-0.dll", "libatk-1.0-0.dll",
+ "libcairo.dll", "libintl-1.dll", "iconv.dll"
+ ]
def main () :
- deps = {}
- GetDeps (sys.argv[1], deps)
+ deps = {}
+ GetDeps (sys.argv[1], deps)
- if len(sys.argv) > 2 :
- # ... dot
- f = open(sys.argv[2], "w")
- f.write ('digraph "' + sys.argv[1] + '" {\n')
- for sn in deps.keys() :
- print sn
- # write weighted edges, could also classify the nodes ...
- node = deps[sn]
- for se in node.deps.keys() :
- print "\t" + se
- edge = node.deps[se]
- if edge.weight > 1 :
- f.write ('"%s" -> "%s [weight=%d]"\n' % (node.name, edge.name, edge.weight))
- f.write("}\n")
+ #print deps
+ Remove (deps, dllsSysWin32)
+ Remove (deps, dllsCrts)
+ #Remove (deps, dllsGtk)
+ # output ...
+ if len(sys.argv) > 2 :
+ # ... dot
+ f = open(sys.argv[2], "w")
+ f.write ('digraph "' + sys.argv[1] + '" {\nratio=0.7\n')
+ for sn in deps.keys() :
+ # write weighted edges, could also classify the nodes ...
+ node = deps[sn]
+ for se in node.deps.keys() :
+ edge = node.deps[se]
+ if edge.weight == 1 :
+ #f.write ('"%s" -> "%s" [weight=%f,label=%s]\n' % (node.name, edge.name, math.log(1)-0.5, edge.symbols[0]))
+ f.write ('"%s" -> "%s" [fontsize=8,label=%s]\n' % (node.name, edge.name, edge.symbols[0]))
+ else :
+ #f.write ('"%s" -> "%s" [weight=%f]\n' % (node.name, edge.name, math.log(edge.weight)-0.5))
+ f.write ('"%s" -> "%s" [label="(%d)",weight=%d]\n' % (node.name, edge.name, edge.weight, edge.weight))
+ f.write("}\n")
if __name__ == '__main__': main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]