def __init__(self, **traits): """ Initializes the object. """ super(ObjectDebugger, self).__init__(**traits) self.module = CBModuleFile(path=self.file_name, python_path=self.python_path, object=self.object) do_later(self.select_object)
def __init__ ( self, **traits ): """ Initializes the object. """ super( ObjectDebugger, self ).__init__( **traits ) self.module = CBModuleFile( path = self.file_name, python_path = self.python_path, object = self.object ) do_later( self.select_object )
def _file_name_changed ( self, file_name ): """ Handles the 'file_name' trait being changed. """ if exists( file_name ): file_name = abspath( str( file_name ) ) for path in sys.path: path = join( abspath( path ), '' ) if path == file_name[ : len( path ) ]: root = self.root for mf in root.favorites: if file_name == mf.path: break else: root.favorites = ([ CBModuleFile( path = file_name, python_path = path ) ] + root.favorites)[: self.max_favorites ] self.update = not self.update return
class ObjectDebugger ( HasPrivateTraits ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # The object that created this view: object_source = Any # The path of the file being debugged: file_name = File # The Python path the file was found in: python_path = Directory # The name to use on the debugger page: name = Property # The object being debugged: object = Any # The module descriptor for the file: module = Instance( CBModuleFile ) # The currently selected object class: selected = Any #--------------------------------------------------------------------------- # Traits view definitions: #--------------------------------------------------------------------------- view = View( Item( 'module', id = 'browser', show_label = False, editor = TreeEditor( nodes = cb_tree_nodes, editable = False, selected = 'selected' ), resizable = True ), id = 'etsdevtools.developer.tools.object_source.ObjectDebugger', resizable = True ) #--------------------------------------------------------------------------- # Initializes the object: #--------------------------------------------------------------------------- def __init__ ( self, **traits ): """ Initializes the object. """ super( ObjectDebugger, self ).__init__( **traits ) self.module = CBModuleFile( path = self.file_name, python_path = self.python_path, object = self.object ) do_later( self.select_object ) #--------------------------------------------------------------------------- # Selects the class of the current object in the class browser: #--------------------------------------------------------------------------- def select_object ( self ): """ Selects the class of the current object in the class browser. """ name = self.object.__class__.__name__ for cb_class in self.module.get_children(): if name == cb_class.name: self.selected = cb_class break #--------------------------------------------------------------------------- # Handles the 'selected' trait being changed: #--------------------------------------------------------------------------- def _selected_changed ( self, selected ): """ Handles a tree node being selected. """ # Read the object's text to force it to calculate the starting # line number of number of lines in the text fragment: ignore = selected.text # Set the file position for the object: self.object_source.file_position = FilePosition( name = selected.name, file_name = selected.path, line = selected.line_number + 1, lines = selected.lines, object = self.object ) #--------------------------------------------------------------------------- # The implementation of the 'name' property: #--------------------------------------------------------------------------- def _get_name ( self ): return basename( self.file_name )
class ObjectDebugger(HasPrivateTraits): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # The object that created this view: object_source = Any # The path of the file being debugged: file_name = File # The Python path the file was found in: python_path = Directory # The name to use on the debugger page: name = Property # The object being debugged: object = Any # The module descriptor for the file: module = Instance(CBModuleFile) # The currently selected object class: selected = Any #--------------------------------------------------------------------------- # Traits view definitions: #--------------------------------------------------------------------------- view = View(Item('module', id='browser', show_label=False, editor=TreeEditor(nodes=cb_tree_nodes, editable=False, selected='selected'), resizable=True), id='etsdevtools.developer.tools.object_source.ObjectDebugger', resizable=True) #--------------------------------------------------------------------------- # Initializes the object: #--------------------------------------------------------------------------- def __init__(self, **traits): """ Initializes the object. """ super(ObjectDebugger, self).__init__(**traits) self.module = CBModuleFile(path=self.file_name, python_path=self.python_path, object=self.object) do_later(self.select_object) #--------------------------------------------------------------------------- # Selects the class of the current object in the class browser: #--------------------------------------------------------------------------- def select_object(self): """ Selects the class of the current object in the class browser. """ name = self.object.__class__.__name__ for cb_class in self.module.get_children(): if name == cb_class.name: self.selected = cb_class break #--------------------------------------------------------------------------- # Handles the 'selected' trait being changed: #--------------------------------------------------------------------------- def _selected_changed(self, selected): """ Handles a tree node being selected. """ # Read the object's text to force it to calculate the starting # line number of number of lines in the text fragment: ignore = selected.text # Set the file position for the object: self.object_source.file_position = FilePosition( name=selected.name, file_name=selected.path, line=selected.line_number + 1, lines=selected.lines, object=self.object) #--------------------------------------------------------------------------- # The implementation of the 'name' property: #--------------------------------------------------------------------------- def _get_name(self): return basename(self.file_name)