Skip to content

Instantly share code, notes, and snippets.

@ycros
Created December 7, 2011 15:44
Show Gist options
  • Save ycros/1443261 to your computer and use it in GitHub Desktop.
Save ycros/1443261 to your computer and use it in GitHub Desktop.
__init__.py
import Live
import sys
from _Framework.ControlSurface import ControlSurface
def create_instance(c_instance):
return YcrosTest(c_instance)
class YcrosTest(ControlSurface):
def __init__(self, c_instance):
ControlSurface.__init__(self, c_instance)
self.seen = set()
self.walk_object(Live, 'Live')
def walk_object(self, obj, name, indent=0):
if obj in self.seen:
return
self.seen.add(obj)
ws = ' ' * indent
out = ws + name
if isinstance(obj, str):
self.out(out + ': "' + obj + '"')
elif obj.__class__ == type:
self.out(out + ': type')
elif obj.__class__.__name__ == 'instancemethod' \
or obj.__class__.__name__ == 'builtin_function_or_method':
self.out(out + '()')
elif obj.__class__ == property:
proptype = ''
if hasattr(obj, 'fget'):
proptype += 'GET '
elif hasattr(obj, 'fset'):
proptype += 'SET'
self.out(out + ' [' + proptype.strip() + ']')
else:
self.out(out + ': ' + obj.__class__.__name__)
for prop in dir(obj):
if not prop.startswith('__'):
propobj = getattr(obj, prop)
self.walk_object(propobj, prop, indent+1)
def out(self, *anything):
anything = [str(x) for x in anything]
self.log_message(', '.join(anything))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment