summaryrefslogtreecommitdiffstats
path: root/tests/tools/list-class-hierarchy.py
blob: a4faf60ab5e8e9ec63ea15c39de3bd59962c75ce (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/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()
    symbols = []
    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
        else:
            symbols.append(mel)

        if isclass(mobj):
            symbols += recurse_into(mel,mobj)

    return symbols

if __name__=='__main__':
    modules = [ 'QtCore',
                'QtGui',
                'QtHelp',
               #'QtMultimedia',
                'QtNetwork',
                'QtOpenGL',
                'QtScript',
                'QtScriptTools',
                'QtSql',
                'QtSvg',
                'QtTest',
               #'QtUiTools',
                'QtWebKit',
                'QtXml',
                'QtXmlPatterns' ]

    libraries = ["PySide", "PyQt4"]
    librarySymbols = {}
    for l in libraries:
        dictionary = []
        if l =="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)

        for m in modules:
            exec "from %s import %s" % (l,m) in globals(), locals()
            dictionary += recurse_into(m, eval(m))
        librarySymbols[l] = dictionary

    print "PyQt4: ", len(librarySymbols["PyQt4"]), " PySide: ", len(librarySymbols["PySide"])

    for symbol in librarySymbols["PyQt4"]:
        if not (symbol in librarySymbols["PySide"]):
            print "Symbol not found in PySide:", symbol