Back to index

unity  6.0.0
Functions | Variables
unity-introspection-visualiser Namespace Reference

Functions

def string_rep
def escape
def traverse_tree

Variables

int NEXT_NODE_ID = 1
list NODE_BLACKLIST = ["Result"]
tuple parser = ArgumentParser()
tuple mg = parser.add_mutually_exclusive_group(required=True)
string help = 'Store output in specified file on disk.'
tuple args = parser.parse_args()
tuple introspection_tree = get_state_by_path('/')
tuple graph = pydot.Dot()
tuple gnode_unity = pydot.Node("Unity")
string write_method_name = 'write_'
tuple tf = NamedTemporaryFile(suffix='.png', delete=False)

Function Documentation

def unity-introspection-visualiser.escape (   s)
Escape a string so it can be use in a dot label.

Definition at line 43 of file unity-introspection-visualiser.py.

00043 
00044 def escape(s):
00045     """Escape a string so it can be use in a dot label."""
00046     return pydot.quote_if_necessary(s).replace('<','\\<').replace('>', '\\>').replace("'", "\\'")
00047 

Here is the caller graph for this function:

def unity-introspection-visualiser.string_rep (   dbus_type)
Get a string representation of various dbus types.

Definition at line 27 of file unity-introspection-visualiser.py.

00027 
00028 def string_rep(dbus_type):
00029     """Get a string representation of various dbus types."""
00030     if type(dbus_type) == dbus.Boolean:
00031         return repr(bool(dbus_type))
00032     if type(dbus_type) == dbus.String:
00033         return dbus_type.encode('ascii', errors='ignore')
00034     if type(dbus_type) in (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64):
00035         return repr(int(dbus_type))
00036     if type(dbus_type) == dbus.Double:
00037         return repr(float(dbus_type))
00038     if type(dbus_type) == dbus.Array:
00039         return ', '.join([string_rep(i) for i in dbus_type])
00040     else:
00041         return repr(dbus_type)
00042 

Here is the caller graph for this function:

def unity-introspection-visualiser.traverse_tree (   state,
  parent,
  graph 
)
Recursively traverse state tree, building dot graph as we go.

Definition at line 48 of file unity-introspection-visualiser.py.

00048 
00049 def traverse_tree(state, parent, graph):
00050     """Recursively traverse state tree, building dot graph as we go."""
00051     global NEXT_NODE_ID
00052     lbl = parent.get_comment() + "|"
00053     # first, set labels for this node:
00054     bits = ["%s=%s" % (k, string_rep(state[k])) for k in sorted(state.keys()) if k != 'Children']
00055     lbl += "\l".join(bits)
00056     parent.set_label(escape('"{' + lbl + '}"'))
00057     if state.has_key('Children'):
00058         # Add all array nodes as children of this node.
00059         for child_name, child_state in state['Children']:
00060             if child_name in NODE_BLACKLIST:
00061                 continue
00062             child = pydot.Node(str(NEXT_NODE_ID))
00063             NEXT_NODE_ID+=1
00064             child.set_comment(child_name)
00065             graph.add_node(child)
00066             graph.add_edge(pydot.Edge(parent, child))
00067 
00068             traverse_tree(child_state, child, graph)
00069 

Here is the call graph for this function:


Variable Documentation

tuple unity-introspection-visualiser.args = parser.parse_args()

Definition at line 78 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.gnode_unity = pydot.Node("Unity")

Definition at line 87 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.graph = pydot.Dot()

Definition at line 81 of file unity-introspection-visualiser.py.

string unity-introspection-visualiser.help = 'Store output in specified file on disk.'

Definition at line 74 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.introspection_tree = get_state_by_path('/')

Definition at line 80 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.mg = parser.add_mutually_exclusive_group(required=True)

Definition at line 72 of file unity-introspection-visualiser.py.

int unity-introspection-visualiser.NEXT_NODE_ID = 1

Definition at line 24 of file unity-introspection-visualiser.py.

list unity-introspection-visualiser.NODE_BLACKLIST = ["Result"]

Definition at line 25 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.parser = ArgumentParser()

Definition at line 71 of file unity-introspection-visualiser.py.

tuple unity-introspection-visualiser.tf = NamedTemporaryFile(suffix='.png', delete=False)

Definition at line 101 of file unity-introspection-visualiser.py.

string unity-introspection-visualiser.write_method_name = 'write_'

Definition at line 93 of file unity-introspection-visualiser.py.