import importlib


def module_installed(module: str) -> bool:
    """
    Determines if a given module string can be resolved

    Determine if the module referenced by string, can be imported by trying
    an import in two ways:

    - direct import of the module
    - import of the module minus the last part, then see if the last part is
      an attribute of the module.

    Parts of course, are separated by dots.

    :param module: module reference
    :return: True if importable, False otherwise
    """
    have_module = False
    try:
        importlib.__import__(module)
    except ModuleNotFoundError:
        mod_path, dot, cls = module.rpartition('.')
        if not mod_path:
            return False
        try:
            mod = importlib.import_module(mod_path)
        except ModuleNotFoundError:
            return False
        else:
            if hasattr(mod, cls):
                have_module = True
    else:
        have_module = True

    return have_module