<s> import direct . gui <EOL> import direct . showbase <EOL> import pandac . PandaModules <EOL> import framework . eventmarkers . eventmarkers <EOL> import math <EOL> class BasicStimuli : <EOL> """<STR_LIT>""" <EOL> class destroy_helper : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , objs ) : <EOL> self . objs = objs <EOL> def destroy ( self ) : <EOL> for o in self . objs : <EOL> o . destroy ( ) <EOL> def __init__ ( self ) : <EOL> self . set_engine ( base = base , direct = direct , pandac = pandac . PandaModules ) <EOL> self . audio3d = None <EOL> self . implicit_markers = False <EOL> self . _to_destroy = [ ] <EOL> def marker ( self , markercode ) : <EOL> """<STR_LIT>""" <EOL> framework . eventmarkers . eventmarkers . send_marker ( markercode ) <EOL> def write ( self , <EOL> text , <EOL> duration = <NUM_LIT:1.0> , <EOL> block = True , <EOL> pos = ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> roll = <NUM_LIT:0> , <EOL> scale = <NUM_LIT> , <EOL> fg = None , <EOL> bg = None , <EOL> shadow = None , <EOL> shadowOffset = ( <NUM_LIT> , <NUM_LIT> ) , <EOL> frame = None , <EOL> align = '<STR_LIT>' , <EOL> wordwrap = None , <EOL> drawOrder = None , <EOL> font = '<STR_LIT>' , <EOL> parent = None , <EOL> sort = <NUM_LIT:0> <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if align == '<STR_LIT:left>' : <EOL> align = self . _engine . pandac . TextNode . ALeft <EOL> elif align == '<STR_LIT:right>' : <EOL> align = self . _engine . pandac . TextNode . ARight <EOL> else : <EOL> align = self . _engine . pandac . TextNode . ACenter <EOL> if duration == <NUM_LIT:0> : <EOL> block = False <EOL> if type ( font ) == str : <EOL> font = self . _engine . base . loader . loadFont ( font ) <EOL> obj = self . _engine . direct . gui . OnscreenText . OnscreenText ( text = text , pos = ( pos [ <NUM_LIT:0> ] , pos [ <NUM_LIT:1> ] - scale / <NUM_LIT:4> ) , roll = roll , scale = scale , fg = fg , bg = bg , shadow = shadow , shadowOffset = shadowOffset , frame = frame , align = align , wordwrap = wordwrap , drawOrder = drawOrder , font = font , parent = parent , sort = sort ) <EOL> self . _to_destroy . append ( obj ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> if type ( duration ) == list or type ( duration ) == tuple : <EOL> self . sleep ( duration [ <NUM_LIT:0> ] ) <EOL> self . waitfor ( duration [ <NUM_LIT:1> ] ) <EOL> elif type ( duration ) == str : <EOL> self . waitfor ( duration ) <EOL> else : <EOL> self . sleep ( duration ) <EOL> self . _destroy_object ( obj , <NUM_LIT:255> ) <EOL> else : <EOL> if duration > <NUM_LIT:0> : <EOL> self . _engine . base . taskMgr . doMethodLater ( duration , self . _destroy_object , '<STR_LIT>' , extraArgs = [ obj , <NUM_LIT:255> ] ) <EOL> return obj <EOL> def crosshair ( self , <EOL> duration = <NUM_LIT:1.0> , <EOL> block = True , <EOL> pos = ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> size = <NUM_LIT> , <EOL> width = <NUM_LIT> , <EOL> color = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) , <EOL> parent = None <EOL> ) : <EOL> """<STR_LIT>""" <EOL> obj1 = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( pos [ <NUM_LIT:0> ] , <NUM_LIT:0> , pos [ <NUM_LIT:1> ] ) , scale = ( size , <NUM_LIT:1> , width ) , color = color , parent = parent ) <EOL> self . _to_destroy . append ( obj1 ) <EOL> obj1 . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> obj2 = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( pos [ <NUM_LIT:0> ] , <NUM_LIT:0> , pos [ <NUM_LIT:1> ] ) , scale = ( width , <NUM_LIT:1> , size ) , color = color , parent = parent ) <EOL> self . _to_destroy . append ( obj2 ) <EOL> obj2 . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> if type ( duration ) == list or type ( duration ) == tuple : <EOL> self . sleep ( duration [ <NUM_LIT:0> ] ) <EOL> self . waitfor ( duration [ <NUM_LIT:1> ] ) <EOL> elif type ( duration ) == str : <EOL> self . waitfor ( duration ) <EOL> else : <EOL> self . sleep ( duration ) <EOL> self . _destroy_object ( [ obj1 , obj2 ] , <NUM_LIT> ) <EOL> else : <EOL> if duration > <NUM_LIT:0> : <EOL> self . _engine . base . taskMgr . doMethodLater ( duration , self . _destroy_object , '<STR_LIT>' , extraArgs = [ [ obj1 , obj2 ] , <NUM_LIT> ] ) <EOL> return self . destroy_helper ( [ obj1 , obj2 ] ) <EOL> def rectangle ( self , <EOL> rect = None , <EOL> duration = <NUM_LIT:1.0> , <EOL> block = True , <EOL> color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> parent = None , <EOL> depth = <NUM_LIT:0> , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if duration == <NUM_LIT:0> : <EOL> block = False <EOL> l = rect [ <NUM_LIT:0> ] ; r = rect [ <NUM_LIT:1> ] ; t = rect [ <NUM_LIT:2> ] ; b = rect [ <NUM_LIT:3> ] <EOL> obj = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( ( l + r ) / <NUM_LIT:2> , depth , ( b + t ) / <NUM_LIT:2> ) , scale = ( ( r - l ) / <NUM_LIT:2> , <NUM_LIT:1> , ( b - t ) / <NUM_LIT:2> ) , color = color , parent = parent ) <EOL> self . _to_destroy . append ( obj ) <EOL> obj . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> if type ( duration ) == list or type ( duration ) == tuple : <EOL> self . sleep ( duration [ <NUM_LIT:0> ] ) <EOL> self . waitfor ( duration [ <NUM_LIT:1> ] ) <EOL> elif type ( duration ) == str : <EOL> self . waitfor ( duration ) <EOL> else : <EOL> self . sleep ( duration ) <EOL> self . _destroy_object ( obj , <NUM_LIT> ) <EOL> else : <EOL> if duration > <NUM_LIT:0> : <EOL> self . _engine . base . taskMgr . doMethodLater ( duration , self . _destroy_object , '<STR_LIT>' , extraArgs = [ obj , <NUM_LIT> ] ) <EOL> return obj <EOL> def frame ( self , <EOL> rect = None , <EOL> thickness = ( <NUM_LIT> , <NUM_LIT> ) , <EOL> duration = <NUM_LIT:1.0> , <EOL> block = True , <EOL> color = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> parent = None , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> l = rect [ <NUM_LIT:0> ] ; r = rect [ <NUM_LIT:1> ] ; t = rect [ <NUM_LIT:2> ] ; b = rect [ <NUM_LIT:3> ] <EOL> w = thickness [ <NUM_LIT:0> ] ; h = thickness [ <NUM_LIT:1> ] <EOL> L = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( l - w / <NUM_LIT:2> , <NUM_LIT:0> , ( b + t ) / <NUM_LIT:2> ) , scale = ( w / <NUM_LIT:2> , <NUM_LIT:1> , w + ( b - t ) / <NUM_LIT:2> ) , color = color , parent = parent ) <EOL> L . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> self . _to_destroy . append ( L ) <EOL> R = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( r + w / <NUM_LIT:2> , <NUM_LIT:0> , ( b + t ) / <NUM_LIT:2> ) , scale = ( w / <NUM_LIT:2> , <NUM_LIT:1> , w + ( b - t ) / <NUM_LIT:2> ) , color = color , parent = parent ) <EOL> R . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> self . _to_destroy . append ( R ) <EOL> T = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( ( l + r ) / <NUM_LIT:2> , <NUM_LIT:0> , t - h / <NUM_LIT:2> ) , scale = ( h + ( r - l ) / <NUM_LIT:2> , <NUM_LIT:1> , h / <NUM_LIT:2> ) , color = color , parent = parent ) <EOL> T . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> self . _to_destroy . append ( T ) <EOL> B = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = '<STR_LIT>' , pos = ( ( l + r ) / <NUM_LIT:2> , <NUM_LIT:0> , b + h / <NUM_LIT:2> ) , scale = ( h + ( r - l ) / <NUM_LIT:2> , <NUM_LIT:1> , h / <NUM_LIT:2> ) , color = color , parent = parent ) <EOL> B . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> self . _to_destroy . append ( B ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> if type ( duration ) == list or type ( duration ) == tuple : <EOL> self . sleep ( duration [ <NUM_LIT:0> ] ) <EOL> self . waitfor ( duration [ <NUM_LIT:1> ] ) <EOL> elif type ( duration ) == str : <EOL> self . waitfor ( duration ) <EOL> else : <EOL> self . sleep ( duration ) <EOL> self . _destroy_object ( [ L , R , T , B ] , <NUM_LIT> ) <EOL> else : <EOL> if duration > <NUM_LIT:0> : <EOL> self . _engine . base . taskMgr . doMethodLater ( duration , self . _destroy_object , '<STR_LIT>' , extraArgs = [ [ L , R , T , B ] , <NUM_LIT> ] ) <EOL> return self . destroy_helper ( [ L , R , T , B ] ) <EOL> def picture ( self , <EOL> image , <EOL> duration = <NUM_LIT:1.0> , <EOL> block = True , <EOL> pos = None , <EOL> hpr = None , <EOL> scale = None , <EOL> color = None , <EOL> parent = None , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if pos is not None and type ( pos ) not in ( int , float ) and len ( pos ) == <NUM_LIT:2> : <EOL> pos = ( pos [ <NUM_LIT:0> ] , <NUM_LIT:0> , pos [ <NUM_LIT:1> ] ) <EOL> if scale is not None and type ( scale ) not in ( int , float ) and len ( scale ) == <NUM_LIT:2> : <EOL> scale = ( scale [ <NUM_LIT:0> ] , <NUM_LIT:1> , scale [ <NUM_LIT:1> ] ) <EOL> if hpr is not None and type ( scale ) not in ( int , float ) and len ( hpr ) == <NUM_LIT:1> : <EOL> hpr = ( <NUM_LIT:0> , <NUM_LIT:0> , hpr ) <EOL> if duration == <NUM_LIT:0> : <EOL> block = False <EOL> obj = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = image , pos = pos , hpr = hpr , scale = scale , color = color , parent = parent ) <EOL> self . _to_destroy . append ( obj ) <EOL> obj . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> if type ( duration ) == list or type ( duration ) == tuple : <EOL> self . sleep ( duration [ <NUM_LIT:0> ] ) <EOL> self . waitfor ( duration [ <NUM_LIT:1> ] ) <EOL> elif type ( duration ) == str : <EOL> self . waitfor ( duration ) <EOL> else : <EOL> self . sleep ( duration ) <EOL> self . _destroy_object ( obj , <NUM_LIT> ) <EOL> else : <EOL> if duration > <NUM_LIT:0> : <EOL> self . _engine . base . taskMgr . doMethodLater ( duration , self . _destroy_object , '<STR_LIT>' , extraArgs = [ obj , <NUM_LIT> ] ) <EOL> return obj <EOL> def sound ( self , <EOL> filename , <EOL> block = False , <EOL> volume = <NUM_LIT:0.1> , <EOL> direction = <NUM_LIT:0.0> , <EOL> playrate = <NUM_LIT:1.0> , <EOL> timeoffset = <NUM_LIT:0.0> , <EOL> looping = False , <EOL> loopcount = None , <EOL> surround = False , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> if surround : <EOL> if self . audio3d is None : <EOL> self . audio3d = self . _engine . direct . showbase . Audio3DManager . Audio3DManager ( self . _engine . base . sfxManagerList [ <NUM_LIT:0> ] , None ) <EOL> obj = self . audio3d . loadSfx ( filename ) <EOL> self . _to_destroy . append ( obj ) <EOL> obj . set3dAttributes ( <NUM_LIT:1.0> * math . sin ( direction ) , <NUM_LIT:1.0> * math . cos ( direction ) , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> obj . setVolume ( volume ) <EOL> else : <EOL> obj = self . _engine . base . loader . loadSfx ( filename ) <EOL> self . _to_destroy . append ( obj ) <EOL> obj . setVolume ( volume ) <EOL> obj . setBalance ( direction ) <EOL> length = obj . length ( ) <EOL> if loopcount is not None : <EOL> obj . setLoopCount ( loopcount ) <EOL> length *= loopcount <EOL> if looping : <EOL> obj . setLoop ( True ) <EOL> length = <NUM_LIT> <EOL> if timeoffset > <NUM_LIT:0.0> : <EOL> obj . setTime ( timeoffset ) <EOL> length -= timeoffset <EOL> obj . setPlayRate ( playrate ) <EOL> length *= playrate <EOL> obj . play ( ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> self . sleep ( length ) <EOL> self . _destroy_object ( obj , <NUM_LIT> ) <EOL> else : <EOL> self . _engine . base . taskMgr . doMethodLater ( length , self . _destroy_object , '<STR_LIT>' , extraArgs = [ None , <NUM_LIT> ] ) <EOL> return obj <EOL> def movie ( self , <EOL> filename , <EOL> block = False , <EOL> pos = None , <EOL> hpr = None , <EOL> scale = None , <EOL> color = None , <EOL> parent = None , <EOL> volume = <NUM_LIT:0.1> , <EOL> direction = <NUM_LIT:0.0> , <EOL> timeoffset = <NUM_LIT:0.0> , <EOL> playrate = <NUM_LIT:1.0> , <EOL> looping = False , <EOL> loopcount = None , <EOL> aspect = None , <EOL> pixelscale = False , <EOL> contentoffset = ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> contentscale = None , <EOL> bordercolor = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> snd = self . _engine . base . loader . loadSfx ( filename ) <EOL> if snd . length ( ) == <NUM_LIT:0.0> : <EOL> snd = None <EOL> except : <EOL> snd = None <EOL> if snd is not None : <EOL> self . _to_destroy . append ( snd ) <EOL> snd . setVolume ( volume ) <EOL> snd . setBalance ( direction ) <EOL> tex = self . _engine . base . loader . loadTexture ( filename ) <EOL> self . _to_destroy . append ( tex ) <EOL> tex . setBorderColor ( ( bordercolor [ <NUM_LIT:0> ] , bordercolor [ <NUM_LIT:1> ] , bordercolor [ <NUM_LIT:2> ] , bordercolor [ <NUM_LIT:3> ] ) ) <EOL> tex . setWrapU ( self . _engine . pandac . Texture . WMBorderColor ) <EOL> tex . setWrapV ( self . _engine . pandac . Texture . WMBorderColor ) <EOL> if snd is not None : <EOL> tex . synchronizeTo ( snd ) <EOL> if snd is not None : <EOL> length = snd . length ( ) <EOL> playable = snd <EOL> else : <EOL> length = tex . getTime ( ) <EOL> playable = tex <EOL> if playrate != <NUM_LIT:1.0> : <EOL> playable . setPlayRate ( playrate ) <EOL> length /= playrate <EOL> if loopcount is not None : <EOL> playable . setLoopCount ( loopcount ) <EOL> length = length * loopcount <EOL> playable . setLoop ( looping ) <EOL> if looping : <EOL> length = <NUM_LIT> <EOL> if timeoffset > <NUM_LIT:0.0> : <EOL> playable . setTime ( timeoffset ) <EOL> length -= timeoffset <EOL> if aspect is None : <EOL> aspect = tex . getVideoWidth ( ) / float ( tex . getVideoHeight ( ) ) <EOL> if contentscale is None : <EOL> contentscale = ( float ( tex . getVideoWidth ( ) ) / tex . getXSize ( ) , float ( tex . getVideoHeight ( ) ) / tex . getYSize ( ) ) <EOL> if scale is None : <EOL> scale = <NUM_LIT:1.0> <EOL> if type ( scale ) in ( int , float ) : <EOL> scale = [ scale , scale ] <EOL> if len ( scale ) == <NUM_LIT:2> : <EOL> scale = ( scale [ <NUM_LIT:0> ] , <NUM_LIT:1> , scale [ <NUM_LIT:1> ] ) <EOL> if pixelscale or parent == pixel2d : <EOL> scale [ <NUM_LIT:0> ] *= tex . getVideoWidth ( ) <EOL> scale [ <NUM_LIT:2> ] *= tex . getVideoHeight ( ) <EOL> else : <EOL> if aspect >= <NUM_LIT:1.0> : <EOL> scale [ <NUM_LIT:2> ] /= float ( aspect ) <EOL> else : <EOL> scale [ <NUM_LIT:0> ] *= float ( aspect ) <EOL> if pos is not None and type ( pos ) not in ( int , float ) and len ( pos ) == <NUM_LIT:2> : <EOL> pos = ( pos [ <NUM_LIT:0> ] , <NUM_LIT:0> , pos [ <NUM_LIT:1> ] ) <EOL> if hpr is not None and type ( scale ) not in ( int , float ) and len ( hpr ) == <NUM_LIT:1> : <EOL> hpr = ( <NUM_LIT:0> , <NUM_LIT:0> , hpr ) <EOL> img = self . _engine . direct . gui . OnscreenImage . OnscreenImage ( image = tex , pos = pos , hpr = hpr , scale = scale , color = color , parent = parent ) <EOL> self . _to_destroy . append ( img ) <EOL> img . setTransparency ( self . _engine . pandac . TransparencyAttrib . MAlpha ) <EOL> img . setTexScale ( self . _engine . pandac . TextureStage . getDefault ( ) , contentscale [ <NUM_LIT:0> ] , contentscale [ <NUM_LIT:1> ] ) <EOL> img . setTexOffset ( self . _engine . pandac . TextureStage . getDefault ( ) , contentoffset [ <NUM_LIT:0> ] , contentoffset [ <NUM_LIT:1> ] ) <EOL> playable . play ( ) <EOL> if self . implicit_markers : <EOL> self . marker ( <NUM_LIT> ) <EOL> if block : <EOL> self . sleep ( length ) <EOL> self . _destroy_object ( img , <NUM_LIT> ) <EOL> else : <EOL> self . _engine . base . taskMgr . doMethodLater ( length , self . _destroy_object , '<STR_LIT>' , extraArgs = [ [ img , tex , snd ] , <NUM_LIT> ] ) <EOL> return playable <EOL> def precache_sound ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> return self . _engine . base . loader . loadSfx ( filename ) <EOL> def precache_picture ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> return self . _engine . base . loader . loadTexture ( filename ) <EOL> def precache_model ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> return self . _engine . base . loader . loadModel ( filename ) <EOL> def precache_movie ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> try : <EOL> self . _engine . base . loader . loadTexture ( filename ) <EOL> except : <EOL> pass <EOL> try : <EOL> return self . _engine . base . loader . loadSfx ( filename ) <EOL> except : <EOL> pass <EOL> def uncache_sound ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> h = self . _engine . base . loader . loadSfx ( filename ) <EOL> self . _engine . base . loader . unloadSfx ( h ) <EOL> def uncache_picture ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> h = self . _engine . base . loader . loadTexture ( filename ) <EOL> self . _engine . base . loader . unloadTexture ( h ) <EOL> def uncache_movie ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if filename is None : <EOL> return <EOL> try : <EOL> h = self . _engine . base . loader . loadTexture ( filename ) <EOL> self . _engine . base . loader . unloadTexture ( h ) <EOL> except : <EOL> pass <EOL> try : <EOL> h = self . _engine . base . loader . loadSfx ( filename ) <EOL> self . _engine . base . loader . unloadSfx ( h ) <EOL> except : <EOL> pass <EOL> def log_setup_parameters ( self , extra_msg = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> self . marker ( '<STR_LIT>' % ( self . __class__ , str ( self . __dict__ ) . replace ( '<STR_LIT:">' , '<STR_LIT>' ) , extra_msg ) ) <EOL> def set_engine ( self , <EOL> base , <EOL> direct , <EOL> pandac ) : <EOL> """<STR_LIT>""" <EOL> class Engine : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , base , direct , pandac ) : <EOL> self . base = base <EOL> self . direct = direct <EOL> self . pandac = pandac <EOL> self . _engine = Engine ( base , direct , pandac ) <EOL> def _destroy_object ( self , obj , id = - <NUM_LIT:1> ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if id > <NUM_LIT:0> and self . implicit_markers : <EOL> self . marker ( id ) <EOL> if not ( type ( obj ) == list or type ( obj ) == tuple ) : <EOL> obj = [ obj ] <EOL> for o in obj : <EOL> if o is not None : <EOL> if hasattr ( o , '<STR_LIT>' ) : <EOL> o . destroy ( ) <EOL> elif hasattr ( o , '<STR_LIT>' ) : <EOL> o . stop ( ) <EOL> else : <EOL> del o <EOL> self . _to_destroy . remove ( o ) <EOL> except : <EOL> pass </s>
