azure-sdk-tools/packaging_tools/code_report.py
def find_autorest_generated_folder(module_prefix="azure"):
    """Find all Autorest generated code in that module prefix.
    This actually looks for a "models" package only (not file). We could be smarter if necessary.
    """
    _LOGGER.info(f"Looking for Autorest generated package in {module_prefix}")

    # Manually skip some namespaces for now
    if module_prefix in ["azure.cli", "azure.storage", "azure.servicemanagement", "azure.servicebus"]:
        _LOGGER.info(f"Skip {module_prefix}")
        return []

    result = []
    try:
        _LOGGER.debug(f"Try {module_prefix}")
        model_module = importlib.import_module(".models", module_prefix)
        # If not exception, we MIGHT have found it, but cannot be a file.
        # Keep continue to try to break it, file module have no __path__
        model_module.__path__
        _LOGGER.info(f"Found {module_prefix}")
        result.append(module_prefix)
    except (ModuleNotFoundError, AttributeError):
        # No model, might dig deeper
        prefix_module = importlib.import_module(module_prefix)
        for _, sub_package, ispkg in pkgutil.iter_modules(prefix_module.__path__, module_prefix+"."):
            if ispkg:
                result += find_autorest_generated_folder(sub_package)
    return result
def find_autorest_generated_folder(module_prefix="azure"):
    """Find all Autorest generated code in that module prefix.
    This actually looks for a "models" package only (not file). We could be smarter if necessary.
    """
    _LOGGER.info(f"Looking for Autorest generated package in {module_prefix}")

    # Manually skip some namespaces for now
    if module_prefix in ["azure.cli", "azure.storage", "azure.servicemanagement", "azure.servicebus"]:
        _LOGGER.info(f"Skip {module_prefix}")
        return []

    result = []
    try:
        _LOGGER.debug(f"Try {module_prefix}")
        model_module = importlib.import_module(".models", module_prefix)
        # If not exception, we MIGHT have found it, but cannot be a file.
        # Keep continue to try to break it, file module have no __path__
        model_module.__path__
        _LOGGER.info(f"Found {module_prefix}")
        result.append(module_prefix)
    except (ModuleNotFoundError, AttributeError):
        # No model, might dig deeper
        prefix_module = importlib.import_module(module_prefix)
        for _, sub_package, ispkg in pkgutil.iter_modules(prefix_module.__path__, module_prefix+"."):
            if ispkg:
                result += find_autorest_generated_folder(sub_package)
    return result
def find_autorest_generated_folder ( module_prefix = "azure" ) : _LOGGER . info ( f"Looking for Autorest generated package in {module_prefix}" ) # Manually skip some namespaces for now if module_prefix in [ "azure.cli" , "azure.storage" , "azure.servicemanagement" , "azure.servicebus" ] : _LOGGER . info ( f"Skip {module_prefix}" ) return [ ] result = [ ] try : _LOGGER . debug ( f"Try {module_prefix}" ) model_module = importlib . import_module ( ".models" , module_prefix ) # If not exception, we MIGHT have found it, but cannot be a file. # Keep continue to try to break it, file module have no __path__ model_module . __path__ _LOGGER . info ( f"Found {module_prefix}" ) result . append ( module_prefix ) except ( ModuleNotFoundError , AttributeError ) : # No model, might dig deeper prefix_module = importlib . import_module ( module_prefix ) for _ , sub_package , ispkg in pkgutil . iter_modules ( prefix_module . __path__ , module_prefix + "." ) : if ispkg : result += find_autorest_generated_folder ( sub_package ) return result
Find all Autorest generated code in that module prefix.
    This actually looks for a "models" package only (not file). We could be smarter if necessary.
Find all Autorest generated code in that module prefix . This actually looks for a models package only ( not file ) . We could be smarter if necessary .