def createTypeNameToMfnClsMap( ): """Parse a file associating node type names with the best compatible MFn function set and return a dictionary with the data :return: dict(((nodeTypeNameStr : api.MFnCls), ...)) dictionary with nodetypeName MFn class mapping""" typenameToClsMap = dict() cfile = cacheFilePath( "nodeTypeToMfnCls", "map" ) fobj = open( cfile, 'r' ) pf = PipeSeparatedFile( fobj ) version = pf.beginReading( ) # don't care about version for nodeTypeName, mfnTypeName in pf.readColumnLine( ): found = False for apimod in apiModules(): try: typenameToClsMap[ nodeTypeName ] = getattr( apimod, mfnTypeName ) found = True break # it worked, there is only one matching class except AttributeError: pass # END for each api module if not found: log.debug("Couldn't find mfn class named %s" % mfnTypeName) # END for each type/mfnclass pair fobj.close() return typenameToClsMap
def createTypeNameToMfnClsMap(): """Parse a file associating node type names with the best compatible MFn function set and return a dictionary with the data :return: dict(((nodeTypeNameStr : api.MFnCls), ...)) dictionary with nodetypeName MFn class mapping""" typenameToClsMap = dict() cfile = cacheFilePath("nodeTypeToMfnCls", "map") fobj = open(cfile, 'r') pf = PipeSeparatedFile(fobj) version = pf.beginReading() # don't care about version for nodeTypeName, mfnTypeName in pf.readColumnLine(): found = False for apimod in apiModules(): try: typenameToClsMap[nodeTypeName] = getattr(apimod, mfnTypeName) found = True break # it worked, there is only one matching class except AttributeError: pass # END for each api module if not found: log.debug("Couldn't find mfn class named %s" % mfnTypeName) # END for each type/mfnclass pair fobj.close() return typenameToClsMap
def _initFromFile( self, filepath ): """Initialize the database with values from the given file :note: the file must have been written using the `writeToFile` method""" self.clear() fobj = open( filepath, 'r' ) pf = PipeSeparatedFile( fobj ) pf.beginReading( ) # get the entries for tokens in pf.readColumnLine( ): key = tokens[ 1 ] self[ key ] = MMethodDescriptor( flag=tokens[0], rvalfunc=tokens[2], newname=tokens[3] )
def _initFromFile(self, filepath): """Initialize the database with values from the given file :note: the file must have been written using the `writeToFile` method""" self.clear() fobj = open(filepath, 'r') pf = PipeSeparatedFile(fobj) pf.beginReading() # get the entries for tokens in pf.readColumnLine(): key = tokens[1] self[key] = MMethodDescriptor(flag=tokens[0], rvalfunc=tokens[2], newname=tokens[3])