Ejemplo n.º 1
0
def iter_modules(package, parents=None):
    """
    Iterates recursively the package's modules
    :param package: a package to iterate over
    :param parents: patents of package
    :return: a list of tuples: (
        module: module object,
        parents: list of packages names the the module exists in.
    )
    """
    modules = []
    parents = parents or []
    for _, name, is_package in pkgutil.iter_modules(package.__path__):
        if is_package:
            # name is package name
            package_parents = parents[:]
            son_package = importlib.import_module(".".join([package.__name__, name]), package.__name__)
            path = getattr(son_package, "PATH", name)
            class_name = names.to_class_name(path)
            path_name = getattr(son_package, "PATH", names.to_path(path))
            cli_command_name = getattr(son_package, "CLI_COMMAND_NAME", names.to_command(path))
            package_parents.append(Package(name=name, path=path_name, class_name=class_name, cli_command_name=cli_command_name))
            modules.extend(iter_modules(son_package, package_parents))
        else:
            # name is module name
            module = importlib.import_module(".".join([package.__name__, name]), package.__name__)
            modules.append((module, parents))
    return modules
Ejemplo n.º 2
0
 def client_class_name(cls):
     return names.to_class_name(cls.name())
Ejemplo n.º 3
0
 def client_class_name(cls):
     return names.to_class_name(cls.name())
Ejemplo n.º 4
0
 def _falcon_class_name(path):
     return 'Resource' + names.to_class_name(path)
Ejemplo n.º 5
0
 def _falcon_class_name(path):
     return 'Resource' + names.to_class_name(path)