class documentation

class SourceFinder: (source)

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method crawl_up Given a .py[i] filename, return module and base directory.
Method crawl_up_dir Undocumented
Method find_sources_in_dir Undocumented
Method get_init_file Check whether a directory contains a file named __init__.py[i].
Method is_explicit_package_base Undocumented
Instance Variable exclude Undocumented
Instance Variable explicit_package_bases Undocumented
Instance Variable fscache Undocumented
Instance Variable namespace_packages Undocumented
Instance Variable verbosity Undocumented
Method _crawl_up_helper Given a directory, maybe returns module and base directory.
def __init__(self, fscache: FileSystemCache, options: Options): (source)

Undocumented

def crawl_up(self, path: str) -> tuple[str, str]: (source)

Given a .py[i] filename, return module and base directory. For example, given "xxx/yyy/foo/bar.py", we might return something like: ("foo.bar", "xxx/yyy") If namespace packages is off, we crawl upwards until we find a directory without an __init__.py If namespace packages is on, we crawl upwards until the nearest explicit base directory. Failing that, we return one past the highest directory containing an __init__.py We won't crawl past directories with invalid package names. The base directory returned is an absolute path.

def crawl_up_dir(self, dir: str) -> tuple[str, str]: (source)

Undocumented

def find_sources_in_dir(self, path: str) -> list[BuildSource]: (source)

Undocumented

def get_init_file(self, dir: str) -> str|None: (source)

Check whether a directory contains a file named __init__.py[i]. If so, return the file's name (with dir prefixed). If not, return None. This prefers .pyi over .py (because of the ordering of PY_EXTENSIONS).

def is_explicit_package_base(self, path: str) -> bool: (source)

Undocumented

Undocumented

explicit_package_bases = (source)

Undocumented

Undocumented

namespace_packages = (source)

Undocumented

verbosity = (source)

Undocumented

@functools.lru_cache()
def _crawl_up_helper(self, dir: str) -> tuple[str, str]|None: (source)

Given a directory, maybe returns module and base directory. We return a non-None value if we were able to find something clearly intended as a base directory (as adjudicated by being an explicit base directory or by containing a package with __init__.py). This distinction is necessary for namespace packages, so that we know when to treat ourselves as a subpackage.