403Webshell
Server IP : 172.67.206.42  /  Your IP : 104.23.197.33
Web Server : Apache
System : Linux server.localhost.com 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User : pahana ( 1029)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/landscape/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/landscape/lib/format.py
import inspect
import re


def format_object(object):
    """
    Returns a fully-qualified name for the specified object, such as
    'landscape.lib.format.format_object()'.
    """
    if inspect.ismethod(object):
        # FIXME If the method is implemented on a base class of
        # object's class, the module name and function name will be
        # from the base class and the method's class name will be from
        # object's class.
        name = repr(object).split(" ")[2]
        return f"{object.__module__}.{name}()"
    elif inspect.isfunction(object):
        name = repr(object).split(" ")[1]
        return f"{object.__module__}.{name}()"
    return f"{object.__class__.__module__}.{object.__class__.__name__}"


def format_delta(seconds):
    if not seconds:
        seconds = 0.0
    return f"{float(seconds):.02f}s"


def format_percent(percent):
    if not percent:
        percent = 0.0
    return f"{float(percent):.02f}%"


def expandvars(pattern: str, **kwargs) -> str:
    """Expand the pattern by replacing the params with values in `kwargs`.

    This implements a small subset of shell parameter expansion and the
    patterns can only be in the following forms:
        - ${parameter}
        - ${parameter:offset} - start at `offset` to the end
        - ${parameter:offset:length} - start at `offset` to `offset + length`
    For simplicity, `offset` and `length` MUST be positive values.
    """
    regex = re.compile(
        r"\$\{([a-zA-Z][a-zA-Z0-9]*)(?::([0-9]+))?(?::([0-9]+))?\}",
        re.MULTILINE,
    )
    values = {k: str(v) for k, v in kwargs.items()}

    def _replace(match):
        param = match.group(1)
        result = values[param.lower()]

        offset, length = match.group(2), match.group(3)
        if offset:
            start = int(offset)
            end = None
            if length:
                end = start + int(length)
            return result[start:end]

        return result

    return re.sub(regex, _replace, pattern)

Youez - 2016 - github.com/yon3zu
LinuXploit