SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > > site-packages > pydantic > v1


Operation   : Linux premium131.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
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11//site-packages/pydantic/v1

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 2771 bytes March 06 2024 00:27:04.
_hypothesis_plugin.py File 14844 bytes March 06 2024 00:27:04.
annotated_types.py File 3124 bytes March 06 2024 00:27:04.
class_validators.py File 14595 bytes March 06 2024 00:27:04.
color.py File 16811 bytes March 06 2024 00:27:04.
config.py File 6477 bytes March 06 2024 00:27:04.
dataclasses.py File 17515 bytes March 06 2024 00:27:04.
datetime_parse.py File 7714 bytes March 06 2024 00:27:04.
decorator.py File 10263 bytes March 06 2024 00:27:04.
env_settings.py File 14039 bytes March 06 2024 00:27:04.
error_wrappers.py File 5142 bytes March 06 2024 00:27:04.
errors.py File 17693 bytes March 06 2024 00:27:04.
fields.py File 50488 bytes March 06 2024 00:27:04.
generics.py File 17805 bytes March 06 2024 00:27:04.
json.py File 3346 bytes March 06 2024 00:27:04.
main.py File 44378 bytes March 06 2024 00:27:04.
mypy.py File 38745 bytes March 06 2024 00:27:04.
networks.py File 22059 bytes March 06 2024 00:27:04.
parse.py File 1810 bytes March 06 2024 00:27:04.
py.typed File 0 bytes March 06 2024 00:27:04.
schema.py File 47615 bytes March 06 2024 00:27:04.
tools.py File 2826 bytes March 06 2024 00:27:04.
types.py File 35380 bytes March 06 2024 00:27:04.
typing.py File 18996 bytes March 06 2024 00:27:04.
utils.py File 25809 bytes March 06 2024 00:27:04.
validators.py File 21887 bytes March 06 2024 00:27:04.
version.py File 1039 bytes March 06 2024 00:27:04.

Reading File: //opt/cloudlinux/venv/lib64/python3.11//site-packages/pydantic/v1/parse.py

import json
import pickle
from enum import Enum
from pathlib import Path
from typing import Any, Callable, Union

from .types import StrBytes


class Protocol(str, Enum):
    json = 'json'
    pickle = 'pickle'


def load_str_bytes(
    b: StrBytes,
    *,
    content_type: str = None,
    encoding: str = 'utf8',
    proto: Protocol = None,
    allow_pickle: bool = False,
    json_loads: Callable[[str], Any] = json.loads,
) -> Any:
    if proto is None and content_type:
        if content_type.endswith(('json', 'javascript')):
            pass
        elif allow_pickle and content_type.endswith('pickle'):
            proto = Protocol.pickle
        else:
            raise TypeError(f'Unknown content-type: {content_type}')

    proto = proto or Protocol.json

    if proto == Protocol.json:
        if isinstance(b, bytes):
            b = b.decode(encoding)
        return json_loads(b)
    elif proto == Protocol.pickle:
        if not allow_pickle:
            raise RuntimeError('Trying to decode with pickle with allow_pickle=False')
        bb = b if isinstance(b, bytes) else b.encode()
        return pickle.loads(bb)
    else:
        raise TypeError(f'Unknown protocol: {proto}')


def load_file(
    path: Union[str, Path],
    *,
    content_type: str = None,
    encoding: str = 'utf8',
    proto: Protocol = None,
    allow_pickle: bool = False,
    json_loads: Callable[[str], Any] = json.loads,
) -> Any:
    path = Path(path)
    b = path.read_bytes()
    if content_type is None:
        if path.suffix in ('.js', '.json'):
            proto = Protocol.json
        elif path.suffix == '.pkl':
            proto = Protocol.pickle

    return load_str_bytes(
        b, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads
    )

SILENT KILLER Tool