3 # ###################################################
4 # Copyright (C) 2008 The OpenAnno Team
6 # This file is part of OpenAnno.
8 # OpenAnno is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the
20 # Free Software Foundation, Inc.,
21 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 # ###################################################
24 if __name__
== '__main__':
28 #find fife and setup search paths
30 os
.execvp(sys
.argv
[1], sys
.argv
[1:])
36 def printTree(obj
, deep
= 0):
39 ignore
= ['__builtins__', 'this', 'grounds', '_instances']
47 for name
in obj
.__dict
__:
48 if name
.startswith('__') and name
.endswith('__'):
52 elif inspect
.ismodule(obj
.__dict
__[name
]) and not obj
.__dict
__[name
].__file
__.startswith('/home'):
54 elif obj
.__dict
__[name
] in already
:
56 elif inspect
.isfunction(obj
.__dict
__[name
]) or inspect
.isclass(obj
.__dict
__[name
]):
59 obj
.__dict
__[name
].__dict
__
63 print (deep
* ' ') + str(name
) + ': ',
64 printTree(obj
.__dict
__[name
], deep
)
65 for name
in obj
.__dict
__:
66 if name
.startswith('__') and name
.endswith('__'):
70 elif inspect
.ismodule(obj
.__dict
__[name
]) and not obj
.__dict
__[name
].__file
__.startswith('/home'):
72 elif obj
.__dict
__[name
] in already
:
74 elif inspect
.isfunction(obj
.__dict
__[name
]) or inspect
.isclass(obj
.__dict
__[name
]):
77 obj
.__dict
__[name
].__dict
__
80 print (deep
* ' ') + str(name
) + ': ',
81 printTree(obj
.__dict
__[name
], deep
)
83 from game
.command
import *
84 def cmd(name
, *pargs
, **kargs
):
85 game
.main
.session
.manager
.execute(eval(name
)(*pargs
, **kargs
))
87 print 'Debuging tools usage:'
88 print 'import debug (already done): load the tools'
89 print 'debug.printTree(<object>): print a tree of an object (the properties, recursive)'
90 print "debug.cmd('name', *args): create a command and execute it throught the manager ex: debug.cmd('unit.Move', game.main.session.selected_instance, x, y)"