Ejemplo n.º 1
0
def getPackage(directory_path):
    from bike.parsing.pathutils import getRootDirectory
    rootdir = getRootDirectory(directory_path)
    if rootdir == directory_path:
        return getRoot()
    else:
        return Package(directory_path, os.path.basename(directory_path))
Ejemplo n.º 2
0
def generateModuleFilenamesInPythonPath(contextFilename):
    files = []
    rootdir = getRootDirectory(contextFilename)
    if rootdir in getPythonPath():
        # just search the pythonpath
        for path in getPythonPath():
            for file in getFilesForName(path):
                if file not in files:   # check for duplicates
                    files.append(file)
                    yield file
    else:
        # search the package hierarchy containing contextFilename
        # in addition to pythonpath
        basedir = getPackageBaseDirectory(contextFilename)
        for path in [basedir] + getPythonPath():
            for file in getFilesForName(path):
                if file not in files:   # check for duplicates
                    files.append(file)
                    yield file

        # and search the files immediately above the package hierarchy
        for file in getFilesForName(os.path.join(rootdir,"*.py")):
            if file not in files:   # check for duplicates
                files.append(file)
                yield file
Ejemplo n.º 3
0
def generateModuleFilenamesInPythonPath(contextFilename):
    files = []
    rootdir = getRootDirectory(contextFilename)
    if rootdir in getPythonPath():
        # just search the pythonpath
        for path in getPythonPath():
            for file in getFilesForName(path):
                if file not in files:  # check for duplicates
                    files.append(file)
                    yield file
    else:
        # search the package hierarchy containing contextFilename
        # in addition to pythonpath
        basedir = getPackageBaseDirectory(contextFilename)
        for path in [basedir] + getPythonPath():
            for file in getFilesForName(path):
                if file not in files:  # check for duplicates
                    files.append(file)
                    yield file

        # and search the files immediately above the package hierarchy
        for file in getFilesForName(os.path.join(rootdir, "*.py")):
            if file not in files:  # check for duplicates
                files.append(file)
                yield file
Ejemplo n.º 4
0
def getPackage(directory_path):
    from bike.parsing.pathutils import getRootDirectory
    rootdir = getRootDirectory(directory_path)
    if rootdir == directory_path:
        return getRoot()
    else:
        return Package(directory_path,
                       os.path.basename(directory_path))