<s> """<STR_LIT>""" <EOL> from traits . api import List <EOL> from mayavi . core . pipeline_base import PipelineBase <EOL> class Component ( PipelineBase ) : <EOL> __version__ = <NUM_LIT:0> <EOL> inputs = List ( record = False ) <EOL> sources = List ( record = False ) <EOL> def __init__ ( self , ** traits ) : <EOL> super ( Component , self ) . __init__ ( ** traits ) <EOL> self . setup_pipeline ( ) <EOL> def __get_pure_state__ ( self ) : <EOL> d = super ( Component , self ) . __get_pure_state__ ( ) <EOL> for x in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> d . pop ( x , None ) <EOL> return d <EOL> def setup_pipeline ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def update_pipeline ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def update_data ( self ) : <EOL> """<STR_LIT>""" <EOL> self . render ( ) <EOL> self . data_changed = True <EOL> def start ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . running : <EOL> return <EOL> self . _setup_event_handlers ( ) <EOL> self . update_pipeline ( ) <EOL> super ( Component , self ) . start ( ) <EOL> def stop ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . running : <EOL> return <EOL> self . _teardown_event_handlers ( ) <EOL> super ( Component , self ) . stop ( ) <EOL> def _inputs_changed ( self , old , new ) : <EOL> if self . running : <EOL> self . update_pipeline ( ) <EOL> self . _setup_events ( old , new ) <EOL> def _inputs_items_changed ( self , list_event ) : <EOL> if self . running : <EOL> self . update_pipeline ( ) <EOL> self . _setup_events ( list_event . removed , list_event . added ) <EOL> def _sources_changed ( self , old , new ) : <EOL> if self . running : <EOL> self . update_pipeline ( ) <EOL> self . _setup_events ( old , new ) <EOL> def _sources_items_changed ( self , list_event ) : <EOL> if self . running : <EOL> self . update_pipeline ( ) <EOL> self . _setup_events ( list_event . removed , list_event . added ) <EOL> def _setup_event_handlers ( self ) : <EOL> self . _setup_events ( [ ] , self . inputs ) <EOL> self . _setup_events ( [ ] , self . sources ) <EOL> def _teardown_event_handlers ( self ) : <EOL> self . _setup_events ( self . inputs , [ ] ) <EOL> self . _setup_events ( self . sources , [ ] ) <EOL> def _setup_events ( self , removed , added ) : <EOL> for object in removed : <EOL> object . on_trait_event ( self . update_pipeline , '<STR_LIT>' , <EOL> remove = True ) <EOL> object . on_trait_event ( self . update_data , '<STR_LIT>' , <EOL> remove = True ) <EOL> for object in added : <EOL> object . on_trait_event ( self . update_pipeline , '<STR_LIT>' ) <EOL> object . on_trait_event ( self . update_data , '<STR_LIT>' ) </s>
