<s> '''<STR_LIT>''' <EOL> from pyfbsdk import * <EOL> from common . diagnostic . pcsLogger import moBuLogger <EOL> from moBu . core . moBuCore import MoBuCore <EOL> from moBu . core . moBuSets import mbSets <EOL> if False : from pyfbsdk_gen_doc import * <EOL> class MoBuNamespace ( MoBuCore ) : <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( MoBuNamespace , self ) . __init__ ( ) <EOL> def addNamespace ( self , node = None , ns = '<STR_LIT>' , hier = False ) : <EOL> '''<STR_LIT>''' <EOL> if not node : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> if not ns : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> if ns in node . LongName : <EOL> moBuLogger . debug ( "<STR_LIT>" % ( ns , node . LongName ) ) <EOL> return False <EOL> try : <EOL> if hier : <EOL> node . ProcessNamespaceHierarchy ( FBNamespaceAction . kFBConcatNamespace , ns , None , False ) <EOL> else : <EOL> node . ProcessObjectNamespace ( FBNamespaceAction . kFBConcatNamespace , ns , None , False ) <EOL> except : <EOL> return False <EOL> return True <EOL> def getAllNamespaces ( self ) : <EOL> '''<STR_LIT>''' <EOL> EXTRAnameSPACES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> allNamespaces = [ ] <EOL> for comp in self . getAllByType ( _type = '<STR_LIT:all>' ) : <EOL> splitByColon = comp . LongName . split ( '<STR_LIT::>' ) <EOL> for i in range ( len ( splitByColon ) - <NUM_LIT:1> ) : <EOL> nSpace = splitByColon [ i ] <EOL> if not nSpace in allNamespaces and not nSpace in EXTRAnameSPACES : <EOL> allNamespaces . append ( nSpace ) <EOL> if len ( splitByColon ) > <NUM_LIT:2> : <EOL> nSpace = splitByColon [ <NUM_LIT:0> ] <EOL> for i in range ( <NUM_LIT:1> , len ( splitByColon ) - <NUM_LIT:1> ) : <EOL> nSpace += '<STR_LIT>' % splitByColon [ i ] <EOL> if not nSpace in allNamespaces and not nSpace in EXTRAnameSPACES : <EOL> allNamespaces . append ( nSpace ) <EOL> if len ( allNamespaces ) == <NUM_LIT:0> : <EOL> allNamespaces = False <EOL> return allNamespaces <EOL> def getNamespace ( self , node = None ) : <EOL> '''<STR_LIT>''' <EOL> if not node : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> nameSpaces = [ ] <EOL> splitByColon = node . LongName . split ( '<STR_LIT::>' ) <EOL> for i in range ( len ( splitByColon ) - <NUM_LIT:1> ) : <EOL> nameSpaces . append ( splitByColon [ i ] ) <EOL> if not nameSpaces : <EOL> return False <EOL> return nameSpaces <EOL> def removeAllNamespaces ( self , node = None , hier = False ) : <EOL> '''<STR_LIT>''' <EOL> if not node : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> try : <EOL> if hier : <EOL> node . ProcessNamespaceHierarchy ( FBNamespaceAction . kFBRemoveAllNamespace , "<STR_LIT>" ) <EOL> else : <EOL> node . ProcessObjectNamespace ( FBNamespaceAction . kFBRemoveAllNamespace , "<STR_LIT>" ) <EOL> except : <EOL> return False <EOL> return True <EOL> def removeAllNamespacesFromScene ( self ) : <EOL> try : <EOL> for lComp in FBSystem ( ) . Scene . Components : <EOL> lComp . ProcessNamespaceHierarchy ( FBNamespaceAction . kFBRemoveAllNamespace , '<STR_LIT>' , '<STR_LIT>' , False ) <EOL> moBuLogger . info ( "<STR_LIT>" ) <EOL> return True <EOL> except : <EOL> moBuLogger . info ( "<STR_LIT>" ) <EOL> return False <EOL> def replaceNamespace ( self , node = None , nsOrig = '<STR_LIT>' , nsReplace = '<STR_LIT>' , hier = False ) : <EOL> '''<STR_LIT>''' <EOL> if not node : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> if not nsOrig : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> if not nsReplace : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> try : <EOL> if hier : <EOL> node . ProcessNamespaceHierarchy ( FBNamespaceAction . kFBReplaceNamespace , nsOrig , nsReplace , False ) <EOL> else : <EOL> node . ProcessObjectNamespace ( FBNamespaceAction . kFBReplaceNamespace , nsOrig , nsReplace , False ) <EOL> except : <EOL> return False <EOL> return True <EOL> def replaceNamespaceOnChar ( self , nSpace = '<STR_LIT>' , quiet = False ) : <EOL> '''<STR_LIT>''' <EOL> success = True <EOL> selected = self . getSelected ( _type = '<STR_LIT:all>' , found = True ) <EOL> if not selected : <EOL> selected = self . getReference ( namespace = '<STR_LIT>' , pyMB = False ) <EOL> if not selected : <EOL> if not quiet : <EOL> moBuLogger . errorDialog ( "<STR_LIT>" ) <EOL> else : <EOL> moBuLogger . error ( "<STR_LIT>" ) <EOL> return False <EOL> if isinstance ( selected , FBSet ) : <EOL> charSet = selected <EOL> else : <EOL> charSet = mbSets . findSetFromObject ( pObject = selected , quiet = quiet ) <EOL> if not charSet : <EOL> return False <EOL> for item in charSet . Items : <EOL> currentNS = None <EOL> if mbNamespace . getNamespace ( node = item ) : <EOL> for ns in mbNamespace . getNamespace ( node = item ) : <EOL> if not '<STR_LIT>' in ns : <EOL> currentNS = ns <EOL> if not mbNamespace . replaceNamespace ( node = item , nsOrig = currentNS , nsReplace = nSpace , hier = False ) : <EOL> moBuLogger . debug ( "<STR_LIT>" % item . LongName ) <EOL> success = False <EOL> else : <EOL> if not nSpace in mbNamespace . getNamespace ( node = item ) : <EOL> if not mbNamespace . addNamespace ( node = item , ns = nSpace , hier = False ) : <EOL> moBuLogger . debug ( "<STR_LIT>" % item . LongName ) <EOL> success = False <EOL> else : <EOL> if not mbNamespace . addNamespace ( node = item , ns = nSpace , hier = False ) : <EOL> moBuLogger . debug ( "<STR_LIT>" % item . LongName ) <EOL> success = False <EOL> if not mbNamespace . addNamespace ( node = charSet , ns = nSpace , hier = False ) : <EOL> moBuLogger . debug ( "<STR_LIT>" % charSet . LongName ) <EOL> return success <EOL> mbNamespace = MoBuNamespace ( ) <EOL> print "<STR_LIT>" </s>
