<s> '''<STR_LIT>''' <EOL> import re <EOL> from pyfbsdk import FBSystem <EOL> from pyfbsdk import FBProgress <EOL> kAllSceneComponents = FBSystem ( ) . Scene . Components <EOL> def deselect ( pattern = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> kwargs [ '<STR_LIT>' ] = True <EOL> if not hasattr ( pattern , '<STR_LIT>' ) : <EOL> pattern = [ pattern ] <EOL> for item in pattern : <EOL> matched = ls ( pattern = item , ** kwargs ) <EOL> for obj in matched : <EOL> try : <EOL> obj . component . Selected = False <EOL> except : <EOL> obj . Selected = False <EOL> def select ( pattern = None , add = False , toggle = False , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if not hasattr ( pattern , "<STR_LIT>" ) : <EOL> pattern = [ pattern ] <EOL> kwargs . pop ( '<STR_LIT>' , None ) <EOL> if not add and not toggle : <EOL> deselect ( pattern = None , ** kwargs ) <EOL> if toggle : <EOL> def selectFunc ( x ) : <EOL> try : <EOL> x . component . Selected = not x . component . Selected <EOL> except : <EOL> x . Selected = not x . Selected <EOL> else : <EOL> def selectFunc ( x ) : <EOL> try : <EOL> x . component . Selected = True <EOL> except : <EOL> x . Selected = True <EOL> for item in pattern : <EOL> matched = ls ( pattern = item , ** kwargs ) <EOL> map ( selectFunc , matched ) <EOL> def delete ( pattern = None , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if not hasattr ( pattern , "<STR_LIT>" ) : <EOL> pattern = [ pattern ] <EOL> for item in pattern : <EOL> matched = ls ( pattern = item , ** kwargs ) <EOL> for obj in matched : <EOL> try : <EOL> obj . component . FBDelete ( ) <EOL> except : <EOL> obj . FBDelete ( ) <EOL> def ls ( pattern = None , _type = None , selected = None , visible = None , includeNamespace = True ) : <EOL> '''<STR_LIT>''' <EOL> if pattern : <EOL> if includeNamespace : <EOL> getName = lambda x : getattr ( x , '<STR_LIT>' , x . Name ) <EOL> else : <EOL> getName = lambda x : x . Name <EOL> if '<STR_LIT:*>' in pattern : <EOL> pattern = pattern . replace ( '<STR_LIT:*>' , '<STR_LIT>' ) <EOL> passesNameTest = lambda x : re . match ( pattern , getName ( x ) ) <EOL> else : <EOL> passesNameTest = lambda x : pattern == getName ( x ) <EOL> else : <EOL> passesNameTest = lambda x : True <EOL> if selected is not None : <EOL> passesSelectionTest = lambda x : x . Selected == selected <EOL> else : <EOL> passesSelectionTest = lambda x : True <EOL> if visible is not None : <EOL> passesVisibilityTest = lambda x : visible == bool ( getattr ( x , '<STR_LIT>' , False ) ) <EOL> else : <EOL> passesVisibilityTest = lambda x : True <EOL> if _type : <EOL> if isinstance ( _type , basestring ) : <EOL> try : <EOL> _type = eval ( _type ) <EOL> except NameError : <EOL> raise NameError ( "<STR_LIT>" % _type ) <EOL> passesTypeTest = lambda x : isinstance ( x , _type ) <EOL> else : <EOL> passesTypeTest = lambda x : True <EOL> matchList = [ ] <EOL> for cmpnt in kAllSceneComponents : <EOL> if not passesSelectionTest ( cmpnt ) : <EOL> continue <EOL> if not passesVisibilityTest ( cmpnt ) : <EOL> continue <EOL> if not passesTypeTest ( cmpnt ) : <EOL> continue <EOL> if passesNameTest ( cmpnt ) : <EOL> try : <EOL> pmbCmpnt = cmpnt . ConvertToPyMoBu ( ) <EOL> except : <EOL> pmbCmpnt = cmpnt <EOL> matchList . append ( pmbCmpnt ) <EOL> return matchList <EOL> def progressBarIterator ( func , items ) : <EOL> '''<STR_LIT>''' <EOL> progressBar = FBProgress ( ) <EOL> progressBar . Caption = str ( func . __name__ ) <EOL> ret = [ ] <EOL> num = len ( items ) <EOL> try : <EOL> for i , item in enumerate ( items ) : <EOL> progressBar . Text = str ( item ) <EOL> progressBar . Percent = int ( i / num ) <EOL> ret . append ( func ( item ) ) <EOL> finally : <EOL> progressBar . FBDelete ( ) <EOL> return ret <EOL> def decorated ( origFunc , newFunc , decoration = None ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( origFunc , '<STR_LIT>' ) : <EOL> import inspect <EOL> newFunc . __doc__ = "<STR_LIT>" % ( <EOL> inspect . formatargspec ( * inspect . getargspec ( origFunc ) ) , <EOL> inspect . getdoc ( origFunc ) or "<STR_LIT>" ) <EOL> else : <EOL> newFunc . __doc__ = origFunc . __doc__ or "<STR_LIT>" <EOL> newFunc . __doc__ += "<STR_LIT>" % ( decoration or "<STR_LIT>" % ( newFunc . __module__ , newFunc . __name__ ) ) <EOL> newFunc . __name__ = origFunc . __name__ <EOL> newFunc . __module__ = origFunc . __module__ <EOL> newFunc . __dict__ = origFunc . __dict__ <EOL> newFunc . _decorated = True <EOL> def decorator ( func ) : <EOL> """<STR_LIT>""" <EOL> def decoratorFunc ( origFunc , * x ) : <EOL> args = ( origFunc , ) + x <EOL> if x : <EOL> origFunc = x [ <NUM_LIT:0> ] <EOL> newFunc = func ( * args ) <EOL> decorated ( origFunc , newFunc , "<STR_LIT>" % ( func . __module__ , func . __name__ ) ) <EOL> return newFunc <EOL> decorated ( func , decoratorFunc , "<STR_LIT>" % ( __name__ , "<STR_LIT>" ) ) <EOL> return decoratorFunc </s>
