def verify_module(fscache: FileSystemCache, id: str, path: str) -> bool: """Check that all packages containing id have a __init__ file.""" if path.endswith(('__init__.py', '__init__.pyi')): path = os.path.dirname(path) for i in range(id.count('.')): path = os.path.dirname(path) if not any(fscache.isfile_case(os.path.join(path, '__init__{}'.format(extension))) for extension in PYTHON_EXTENSIONS): return False return True
def highest_init_level(fscache: FileSystemCache, id: str, path: str) -> int: """Compute the highest level where an __init__ file is found.""" if path.endswith(('__init__.py', '__init__.pyi')): path = os.path.dirname(path) level = 0 for i in range(id.count('.')): path = os.path.dirname(path) if any(fscache.isfile_case(os.path.join(path, '__init__{}'.format(extension))) for extension in PYTHON_EXTENSIONS): level = i + 1 return level