def resolvePath(melobj, recurse=False, exclude=(), melPathOnly=False, basePackage=''): """ if passed a directory, get all mel files in the directory if passed a file, ensure it is a mel file if passed a procedure name, find its file Returns tuples of the form (moduleName, melfile). """ if basePackage is None: basePackage = '' files = [] recursedResults = [] filepath = util.path(melobj) if filepath.isfile(): if filepath.ext == '.mel': files = [filepath.truepath()] else: log.warning("File is not a mel script: %s" % (filepath)) files = [] elif filepath.isdir(): files = [f.truepath() for f in filepath.files('[a-zA-Z]*.mel')] if recurse: for dir in filepath.dirs(): recursedResults.extend( resolvePath(dir, recurse=recurse, exclude=exclude, melPathOnly=melPathOnly, basePackage=basePackage + '.' + melparse.pythonizeName(dir.basename()))) #elif not filepath.exists(): else: # see if it's a procedure that we can derive a path from try: info = pm.mel.whatIs(melobj).split(': ')[-1] assert info != 'Unknown', "If providing a procedure or a short file name, ensure the appropriate script is sourced" melfile = util.path(info) files = [melfile.truepath()] except Exception, msg: log.warning("Could not determine mel script from input '%s': %s." % (filepath, msg))
def resolvePath( melobj, recurse=False, exclude=(), melPathOnly=False, basePackage='' ): """ if passed a directory, get all mel files in the directory if passed a file, ensure it is a mel file if passed a procedure name, find its file Returns tuples of the form (moduleName, melfile). """ if basePackage is None: basePackage = '' files = [] recursedResults = [] filepath = util.path( melobj ) if filepath.isfile(): if filepath.ext == '.mel': files = [ filepath.truepath() ] else: log.warning( "File is not a mel script: %s" % (filepath) ) files = [] elif filepath.isdir(): files = [ f.truepath() for f in filepath.files( '[a-zA-Z]*.mel') ] if recurse: for dir in filepath.dirs(): recursedResults.extend(resolvePath(dir, recurse=recurse, exclude=exclude, melPathOnly=melPathOnly, basePackage = basePackage + '.' + melparse.pythonizeName(dir.basename()))) #elif not filepath.exists(): else: # see if it's a procedure that we can derive a path from try: info = pm.mel.whatIs( melobj ).split(': ')[-1] assert info != 'Unknown', "If providing a procedure or a short file name, ensure the appropriate script is sourced" melfile = util.path( info ) files = [ melfile.truepath() ] except Exception, msg: log.warning( "Could not determine mel script from input '%s': %s." % (filepath, msg) )