<s> """<STR_LIT>""" <EOL> import sys <EOL> import traceback <EOL> import logging <EOL> import vtk <EOL> from apptools . persistence . state_pickler import create_instance <EOL> from traits . etsconfig . api import ETSConfig <EOL> if ETSConfig . toolkit in ( '<STR_LIT:null>' , '<STR_LIT>' ) : <EOL> pyface = None <EOL> else : <EOL> from pyface import api as pyface <EOL> logger = logging . getLogger ( __name__ ) <EOL> def debug ( msg ) : <EOL> """<STR_LIT>""" <EOL> logger . debug ( msg ) <EOL> def warning ( msg , parent = None ) : <EOL> """<STR_LIT>""" <EOL> logger . warn ( msg ) <EOL> if pyface is not None : <EOL> pyface . warning ( parent , msg ) <EOL> def error ( msg , parent = None ) : <EOL> """<STR_LIT>""" <EOL> logger . error ( msg ) <EOL> if pyface is not None : <EOL> pyface . error ( parent , msg ) <EOL> def exception ( msg = '<STR_LIT>' , parent = None ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> type , value , tb = sys . exc_info ( ) <EOL> info = traceback . extract_tb ( tb ) <EOL> filename , lineno , function , text = info [ - <NUM_LIT:1> ] <EOL> exc_msg = "<STR_LIT>" % ( msg , filename , lineno , type . __name__ , str ( value ) , <EOL> function ) <EOL> logger . exception ( msg ) <EOL> if pyface is not None : <EOL> pyface . error ( parent , exc_msg , title = '<STR_LIT>' ) <EOL> finally : <EOL> type = value = tb = None <EOL> def process_ui_events ( ) : <EOL> """<STR_LIT>""" <EOL> if pyface is not None : <EOL> pyface . GUI . process_events ( ) <EOL> def get_engine ( obj ) : <EOL> """<STR_LIT>""" <EOL> from mayavi . core . engine import Engine <EOL> while obj is not None : <EOL> if isinstance ( obj , Engine ) : <EOL> return obj <EOL> else : <EOL> obj = obj . parent <EOL> return None <EOL> def get_output ( obj ) : <EOL> """<STR_LIT>""" <EOL> if obj . is_a ( '<STR_LIT>' ) : <EOL> return obj <EOL> else : <EOL> return obj . output <EOL> def get_object_path ( object , parent , path = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> def _get_child_trait ( obj ) : <EOL> if hasattr ( obj , '<STR_LIT>' ) : <EOL> return '<STR_LIT>' <EOL> elif hasattr ( obj , '<STR_LIT>' ) : <EOL> return '<STR_LIT>' <EOL> return '<STR_LIT>' <EOL> def _finder ( obj , to_find , path ) : <EOL> if obj is to_find : <EOL> return path <EOL> else : <EOL> child_t = _get_child_trait ( obj ) <EOL> if child_t == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> for i , o in enumerate ( getattr ( obj , child_t ) ) : <EOL> pth = _finder ( o , to_find , '<STR_LIT>' % ( path , child_t , i ) ) <EOL> if len ( pth ) > <NUM_LIT:0> : <EOL> return pth <EOL> return '<STR_LIT>' <EOL> return _finder ( parent , object , path ) <EOL> def handle_children_state ( children , kids ) : <EOL> """<STR_LIT>""" <EOL> m_children = list ( children ) <EOL> n_child , n_kid = len ( m_children ) , len ( kids ) <EOL> for i in range ( n_child - n_kid ) : <EOL> m_children . pop ( ) <EOL> for i in range ( n_child ) : <EOL> child , kid = m_children [ i ] , kids [ i ] <EOL> md = kid . __metadata__ <EOL> if ( child . __module__ != md [ '<STR_LIT>' ] ) or ( child . __class__ . __name__ != md [ '<STR_LIT>' ] ) : <EOL> m_children [ i ] = create_instance ( kid ) <EOL> for i in range ( n_kid - n_child ) : <EOL> child = create_instance ( kids [ n_child + i ] ) <EOL> m_children . append ( child ) <EOL> children [ : ] = m_children </s>
