File: browseUML.py

package info (click to toggle)
gaphor 0.13.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,692 kB
  • ctags: 2,971
  • sloc: python: 19,981; xml: 247; makefile: 54; sh: 40
file content (35 lines) | stat: -rwxr-xr-x 644 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python
#
# Print all attributes of a specific class.
#
# Usage: browseUML.py <Classname>
# E.g. browseUML.py Class
#
# Arjan Molenaar.

import sys

sys.path.append("..")

from gaphor.UML import *

done = [ object ]
def print_vars(cls):
    global done
    done.append(cls)
    print cls.__name__ + ":"
    dict = cls.__dict__
    for key in dict.keys():
        print "\t" + key + ":", str(dict[key])
    for base in cls.__bases__:
	if base not in done:
	    print_vars(base)

args = sys.argv[1:]

if args:
    cls = eval(args[0])
    print_vars(cls)
else:
    print "Usage: " + sys.argv[0] + " <UML class name>"
    sys.exit(1)