def getModuleUsingFQN(fqn, pythonpath): filename = getPathOfModuleOrPackage(fqn,pythonpath) if filename is not None: if os.path.isdir(filename): return getModule(os.path.join(filename,"__init__.py")) else: return getModule(filename) else: return None
def getModuleOrPackageUsingFQN(fqn, dirpath=None): pythonpath = getPythonPath() #print_ "getModuleOrPackageUsingFQN",pythonpath,fqn if dirpath is not None: assert os.path.isdir(dirpath) pythonpath = [dirpath] + pythonpath filename = getPathOfModuleOrPackage(fqn, pythonpath) #print_ "getModuleOrPackageUsingFQN - filename",filename if filename is not None: if os.path.isdir(filename): return getPackage(filename) else: return getModule(filename) else: return None
def getModuleOrPackageUsingFQN(fqn, dirpath=None): pythonpath = getPythonPath() #print "getModuleOrPackageUsingFQN",pythonpath,fqn if dirpath is not None: assert os.path.isdir(dirpath) pythonpath = [dirpath] + pythonpath filename = getPathOfModuleOrPackage(fqn,pythonpath) #print "getModuleOrPackageUsingFQN - filename",filename if filename is not None: if os.path.isdir(filename): return getPackage(filename) else: return getModule(filename) else: return None
def generatePackageDependencies(fileInPackage): rejectPackagePaths = [getPackageBaseDirectory(fileInPackage)] for fname in generateModuleFilenamesInPackage(fileInPackage): try: f = file(fname) src = f.read() finally: f.close() packagepath = None for line in src.splitlines(): match = fromRegex.search(line) or importregex.search(line) if match is not None: modulepath = match.group(1) packagename = modulepath.split('.')[0] packagepath = getPathOfModuleOrPackage(packagename, getPythonPath()) if packagepath is not None and \ packagepath not in rejectPackagePaths: rejectPackagePaths.append(packagepath) # avoid duplicates yield packagepath