GRAYBYTE WORDPRESS FILE MANAGER3362

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/pyrsistent/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/imunify360/venv/lib/python3.11/site-packages/pyrsistent//_helpers.py
from functools import wraps
from pyrsistent._pmap import PMap, pmap
from pyrsistent._pset import PSet, pset
from pyrsistent._pvector import PVector, pvector

def freeze(o, strict=True):
    """
    Recursively convert simple Python containers into pyrsistent versions
    of those containers.

    - list is converted to pvector, recursively
    - dict is converted to pmap, recursively on values (but not keys)
    - set is converted to pset, but not recursively
    - tuple is converted to tuple, recursively.

    If strict == True (default):

    - freeze is called on elements of pvectors
    - freeze is called on values of pmaps

    Sets and dict keys are not recursively frozen because they do not contain
    mutable data by convention. The main exception to this rule is that
    dict keys and set elements are often instances of mutable objects that
    support hash-by-id, which this function can't convert anyway.

    >>> freeze(set([1, 2]))
    pset([1, 2])
    >>> freeze([1, {'a': 3}])
    pvector([1, pmap({'a': 3})])
    >>> freeze((1, []))
    (1, pvector([]))
    """
    typ = type(o)
    if typ is dict or (strict and isinstance(o, PMap)):
        return pmap({k: freeze(v, strict) for k, v in o.items()})
    if typ is list or (strict and isinstance(o, PVector)):
        curried_freeze = lambda x: freeze(x, strict)
        return pvector(map(curried_freeze, o))
    if typ is tuple:
        curried_freeze = lambda x: freeze(x, strict)
        return tuple(map(curried_freeze, o))
    if typ is set:
        # impossible to have anything that needs freezing inside a set or pset
        return pset(o)
    return o


def thaw(o, strict=True):
    """
    Recursively convert pyrsistent containers into simple Python containers.

    - pvector is converted to list, recursively
    - pmap is converted to dict, recursively on values (but not keys)
    - pset is converted to set, but not recursively
    - tuple is converted to tuple, recursively.

    If strict == True (the default):

    - thaw is called on elements of lists
    - thaw is called on values in dicts

    >>> from pyrsistent import s, m, v
    >>> thaw(s(1, 2))
    {1, 2}
    >>> thaw(v(1, m(a=3)))
    [1, {'a': 3}]
    >>> thaw((1, v()))
    (1, [])
    """
    typ = type(o)
    if isinstance(o, PVector) or (strict and typ is list):
        curried_thaw = lambda x: thaw(x, strict)
        return list(map(curried_thaw, o))
    if isinstance(o, PMap) or (strict and typ is dict):
        return {k: thaw(v, strict) for k, v in o.items()}
    if typ is tuple:
        curried_thaw = lambda x: thaw(x, strict)
        return tuple(map(curried_thaw, o))
    if isinstance(o, PSet):
        # impossible to thaw inside psets or sets
        return set(o)
    return o


def mutant(fn):
    """
    Convenience decorator to isolate mutation to within the decorated function (with respect
    to the input arguments).

    All arguments to the decorated function will be frozen so that they are guaranteed not to change.
    The return value is also frozen.
    """
    @wraps(fn)
    def inner_f(*args, **kwargs):
        return freeze(fn(*[freeze(e) for e in args], **dict(freeze(item) for item in kwargs.items())))

    return inner_f

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 11 2025 07:53:06
root / root
0755
__pycache__
--
July 02 2025 08:36:55
root / root
0755
__init__.py
1.444 KB
June 09 2025 11:12:39
root / root
0644
__init__.pyi
7.02 KB
June 09 2025 11:12:39
root / root
0644
_checked_types.py
17.941 KB
June 09 2025 11:12:39
root / root
0644
_field_common.py
11.683 KB
June 09 2025 11:12:39
root / root
0644
_helpers.py
3.156 KB
June 09 2025 11:12:39
root / root
0644
_immutable.py
3.21 KB
June 09 2025 11:12:39
root / root
0644
_pbag.py
6.572 KB
June 09 2025 11:12:39
root / root
0644
_pclass.py
9.475 KB
June 09 2025 11:12:39
root / root
0644
_pdeque.py
11.917 KB
June 09 2025 11:12:39
root / root
0644
_plist.py
8.099 KB
June 09 2025 11:12:39
root / root
0644
_pmap.py
18.341 KB
June 09 2025 11:12:39
root / root
0644
_precord.py
6.867 KB
June 09 2025 11:12:39
root / root
0644
_pset.py
5.56 KB
June 09 2025 11:12:39
root / root
0644
_pvector.py
22.162 KB
June 09 2025 11:12:39
root / root
0644
_toolz.py
3.345 KB
June 09 2025 11:12:39
root / root
0644
_transformations.py
3.711 KB
June 09 2025 11:12:39
root / root
0644
py.typed
0 KB
June 09 2025 11:12:39
root / root
0644
typing.py
1.726 KB
June 09 2025 11:12:39
root / root
0644
typing.pyi
10.172 KB
June 09 2025 11:12:39
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF