GRAYBYTE WORDPRESS FILE MANAGER4343

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils//importer.py
"""
Provides utilities for dynamically loading packages/modules.
"""
import importlib
import importlib.util
import logging
import pkgutil
from pathlib import Path
from typing import Generator, List, Union

logger = logging.getLogger(__name__)


def get_module_by_path(
    module_name: str, file_path: Union[str, Path]
) -> "module":  # noqa: F821
    """
    Execute and return module from *file_path*
    """
    # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
    spec = importlib.util.spec_from_file_location(module_name, file_path)
    module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    return module


def iter_modules(
    paths: List[Union[str, Path]]
) -> Generator["module", None, None]:  # noqa: F821
    """
    Yields all modules from *paths*
    """
    for module in pkgutil.iter_modules(paths):
        if not module.ispkg:
            path = Path(module.module_finder.path) / f"{module.name}.py"
            yield get_module_by_path(module.name, path)


def load(name: str, missing_ok=False) -> None:
    """
    Import *name* module, if *name* is a package import all submodules.
    If *name* module/package is not found:
     - raise ModuleNotFoundError if *missing_ok* is False
     - ignore it if *missing_ok* is True
    """
    try:
        spec = importlib.util.find_spec(name)
    except ModuleNotFoundError:
        if not missing_ok:
            raise
        return
    # import *name* itself, for package it is __init__.py
    importlib.import_module(name)
    if spec.loader.is_package(spec.name):
        package = name
        for module in pkgutil.iter_modules(spec.submodule_search_locations):
            importlib.import_module(f"{package}.{module.name}")


def load_packages(packages: tuple, missing_ok=False) -> None:
    for package in packages:
        load(package, missing_ok=missing_ok)


def get(*, module, name, default):
    """
    Return object with *name* from specific *module*.
    If object was not found return *default*
    """
    try:
        m = importlib.import_module(module)
    except ModuleNotFoundError:
        return default
    return getattr(m, name, default)


def exists(name):
    try:
        spec = importlib.util.find_spec(name)
    except ModuleNotFoundError:
        return False
    return spec is not None


class LazyImport:
    def __init__(self, module_name: str):
        self._module_name = module_name
        self._module = None

    @property
    def module(self):
        if self._module is None:
            self._module = importlib.import_module(self._module_name)
        return self._module

    def __getattr__(self, attr):
        return getattr(self.module, attr)

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 11 2025 07:52:56
root / root
0755
__pycache__
--
July 11 2025 07:52:56
root / root
0755
__init__.py
52.547 KB
July 09 2025 15:10:25
root / root
0644
_shutil.py
0.776 KB
July 09 2025 15:10:25
root / root
0644
antivirus_mode.py
0.485 KB
July 09 2025 15:10:25
root / root
0644
async_utils.py
0.701 KB
July 09 2025 15:10:25
root / root
0644
benchmark.py
0.525 KB
July 09 2025 15:10:25
root / root
0644
buffer.py
1.24 KB
July 09 2025 15:10:25
root / root
0644
check_db.py
7.716 KB
July 09 2025 15:10:25
root / root
0644
check_lock.py
0.621 KB
July 09 2025 15:10:25
root / root
0644
cli.py
7.077 KB
July 09 2025 15:10:25
root / root
0644
common.py
14.411 KB
July 09 2025 15:10:25
root / root
0644
config.py
0.976 KB
July 09 2025 15:10:25
root / root
0644
cronjob.py
0.881 KB
July 09 2025 15:10:25
root / root
0644
doctor.py
1.002 KB
July 09 2025 15:10:25
root / root
0644
hyperscan.py
0.146 KB
July 09 2025 15:10:25
root / root
0644
importer.py
2.666 KB
July 09 2025 15:10:25
root / root
0644
ipecho.py
1.9 KB
July 09 2025 15:10:25
root / root
0644
json.py
0.931 KB
July 09 2025 15:10:25
root / root
0644
kwconfig.py
1.563 KB
July 09 2025 15:10:25
root / root
0644
parsers.py
11.119 KB
July 09 2025 15:10:25
root / root
0644
resource_limits.py
2.292 KB
July 09 2025 15:10:25
root / root
0644
safe_fileops.py
7.987 KB
July 09 2025 15:10:25
root / root
0644
safe_sequence.py
0.354 KB
July 09 2025 15:10:25
root / root
0644
serialization.py
1.716 KB
July 09 2025 15:10:25
root / root
0644
sshutil.py
7.943 KB
July 09 2025 15:10:25
root / root
0644
subprocess.py
1.533 KB
July 09 2025 15:10:25
root / root
0644
support.py
5.204 KB
July 09 2025 15:10:25
root / root
0644
threads.py
0.981 KB
July 09 2025 15:10:25
root / root
0644
validate.py
4.272 KB
July 09 2025 15:10:25
root / root
0644
whmcs.py
7.602 KB
July 09 2025 15:10:25
root / root
0644
wordpress_mu_plugin.py
1.406 KB
July 09 2025 15:10:25
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF