aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatti Airas <matti.p.airas@nokia.com>2010-09-23 16:16:57 +0300
committerMatti Airas <matti.p.airas@nokia.com>2010-09-23 17:18:16 +0300
commit16579322f177c1fde0336c2b255a4a696ed73e5d (patch)
treeabf142b156101b1af10d7e928c6c8270c7c30e50
parent8048bd0c3bcdb1de33aa69d961402b355d6b07af (diff)
added a tool to compare class hierarchies
-rwxr-xr-xtests/tools/list-class-hierarchy.py95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/tools/list-class-hierarchy.py b/tests/tools/list-class-hierarchy.py
new file mode 100755
index 000000000..381efeecb
--- /dev/null
+++ b/tests/tools/list-class-hierarchy.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+
+# This file is part of PySide: Python for Qt
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# version 2 as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+
+# This is a small script printing out Qt binding class hierarchies
+# for comparison purposes.
+#
+# Usage:
+#
+# ./list-class-hierarchy.py PySide > pyside.list
+# ./list-class-hierarchy.py PyQt4 > pyqt4.list
+#
+# meld pyside.list pyqt4.list
+
+import sys
+import pdb
+from inspect import isclass
+
+ignore = ["staticMetaObject",
+ "pyqtConfigure",
+ "registerUserData",
+ "thread",
+ ]
+
+def recurse_into(el,obj):
+ #s = el.split('.')[-1]
+ #pdb.set_trace()
+ for item in sorted(dir(obj)):
+ if item[0]=='_':
+ continue
+ mel = el + '.' + item
+ try:
+ mobj = eval(mel)
+ except Exception:
+ continue
+ if item in ignore:
+ continue
+ print mel
+ if isclass(mobj):
+ recurse_into(mel,mobj)
+
+if __name__=='__main__':
+ top = sys.argv[1]
+
+ if top=="PyQt4":
+ import sip
+ sip.setapi('QDate',2)
+ sip.setapi('QDateTime',2)
+ sip.setapi('QString',2)
+ sip.setapi('QTextStream',2)
+ sip.setapi('QTime',2)
+ sip.setapi('QUrl',2)
+ sip.setapi('QVariant',2)
+
+ if len(sys.argv)>2:
+ modules = sys.argv[2:]
+ else:
+ modules = [ 'QtCore',
+ 'QtGui',
+ 'QtHelp',
+ #'QtMultimedia',
+ 'QtNetwork',
+ 'QtOpenGL',
+ 'QtScript',
+ 'QtScriptTools',
+ 'QtSql',
+ 'QtSvg',
+ 'QtTest',
+ #'QtUiTools',
+ 'QtWebKit',
+ 'QtXml',
+ 'QtXmlPatterns' ]
+
+ for m in modules:
+ exec "from %s import %s" % (top,m) in globals(), locals()
+ recurse_into(m,eval(m))