utils.PackageTools

 1def get_matching_module(modules: list[str], snippet: str) -> str | None:
 2    """
 3    Finds the correct module to a snippet
 4
 5    :param modules: A list of known modules.
 6    :param snippet: A snippet of a module string.
 7    :return: The matching module string or `None`.
 8    """
 9    for module in modules:
10        if snippet == module.split('.')[-1]:
11            return module
12    return None
def get_matching_module(modules: list[str], snippet: str) -> str | None:
 2def get_matching_module(modules: list[str], snippet: str) -> str | None:
 3    """
 4    Finds the correct module to a snippet
 5
 6    :param modules: A list of known modules.
 7    :param snippet: A snippet of a module string.
 8    :return: The matching module string or `None`.
 9    """
10    for module in modules:
11        if snippet == module.split('.')[-1]:
12            return module
13    return None

Finds the correct module to a snippet

Parameters
  • modules: A list of known modules.
  • snippet: A snippet of a module string.
Returns

The matching module string or None.