✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ premium290.web-hosting.com ​🇻​♯➤ 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 63.250.38.37 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.217.6
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/cloudlinux/venv/lib/python3.11/site-packages/pydantic/v1//json.py
import datetime
from collections import deque
from decimal import Decimal
from enum import Enum
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
from pathlib import Path
from re import Pattern
from types import GeneratorType
from typing import Any, Callable, Dict, Type, Union
from uuid import UUID

from .color import Color
from .networks import NameEmail
from .types import SecretBytes, SecretStr

__all__ = 'pydantic_encoder', 'custom_pydantic_encoder', 'timedelta_isoformat'


def isoformat(o: Union[datetime.date, datetime.time]) -> str:
    return o.isoformat()


def decimal_encoder(dec_value: Decimal) -> Union[int, float]:
    """
    Encodes a Decimal as int of there's no exponent, otherwise float

    This is useful when we use ConstrainedDecimal to represent Numeric(x,0)
    where a integer (but not int typed) is used. Encoding this as a float
    results in failed round-tripping between encode and parse.
    Our Id type is a prime example of this.

    >>> decimal_encoder(Decimal("1.0"))
    1.0

    >>> decimal_encoder(Decimal("1"))
    1
    """
    if dec_value.as_tuple().exponent >= 0:
        return int(dec_value)
    else:
        return float(dec_value)


ENCODERS_BY_TYPE: Dict[Type[Any], Callable[[Any], Any]] = {
    bytes: lambda o: o.decode(),
    Color: str,
    datetime.date: isoformat,
    datetime.datetime: isoformat,
    datetime.time: isoformat,
    datetime.timedelta: lambda td: td.total_seconds(),
    Decimal: decimal_encoder,
    Enum: lambda o: o.value,
    frozenset: list,
    deque: list,
    GeneratorType: list,
    IPv4Address: str,
    IPv4Interface: str,
    IPv4Network: str,
    IPv6Address: str,
    IPv6Interface: str,
    IPv6Network: str,
    NameEmail: str,
    Path: str,
    Pattern: lambda o: o.pattern,
    SecretBytes: str,
    SecretStr: str,
    set: list,
    UUID: str,
}


def pydantic_encoder(obj: Any) -> Any:
    from dataclasses import asdict, is_dataclass

    from .main import BaseModel

    if isinstance(obj, BaseModel):
        return obj.dict()
    elif is_dataclass(obj):
        return asdict(obj)

    # Check the class type and its superclasses for a matching encoder
    for base in obj.__class__.__mro__[:-1]:
        try:
            encoder = ENCODERS_BY_TYPE[base]
        except KeyError:
            continue
        return encoder(obj)
    else:  # We have exited the for loop without finding a suitable encoder
        raise TypeError(f"Object of type '{obj.__class__.__name__}' is not JSON serializable")


def custom_pydantic_encoder(type_encoders: Dict[Any, Callable[[Type[Any]], Any]], obj: Any) -> Any:
    # Check the class type and its superclasses for a matching encoder
    for base in obj.__class__.__mro__[:-1]:
        try:
            encoder = type_encoders[base]
        except KeyError:
            continue

        return encoder(obj)
    else:  # We have exited the for loop without finding a suitable encoder
        return pydantic_encoder(obj)


def timedelta_isoformat(td: datetime.timedelta) -> str:
    """
    ISO 8601 encoding for Python timedelta object.
    """
    minutes, seconds = divmod(td.seconds, 60)
    hours, minutes = divmod(minutes, 60)
    return f'{"-" if td.days < 0 else ""}P{abs(td.days)}DT{hours:d}H{minutes:d}M{seconds:d}.{td.microseconds:06d}S'


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
6 Mar 2024 12.27 AM
root / root
0755
__pycache__
--
6 Mar 2024 12.27 AM
root / root
0755
__init__.py
2.706 KB
6 Mar 2024 12.27 AM
root / root
0644
_hypothesis_plugin.py
14.496 KB
6 Mar 2024 12.27 AM
root / root
0644
annotated_types.py
3.051 KB
6 Mar 2024 12.27 AM
root / root
0644
class_validators.py
14.253 KB
6 Mar 2024 12.27 AM
root / root
0644
color.py
16.417 KB
6 Mar 2024 12.27 AM
root / root
0644
config.py
6.325 KB
6 Mar 2024 12.27 AM
root / root
0644
dataclasses.py
17.104 KB
6 Mar 2024 12.27 AM
root / root
0644
datetime_parse.py
7.533 KB
6 Mar 2024 12.27 AM
root / root
0644
decorator.py
10.022 KB
6 Mar 2024 12.27 AM
root / root
0644
env_settings.py
13.71 KB
6 Mar 2024 12.27 AM
root / root
0644
error_wrappers.py
5.021 KB
6 Mar 2024 12.27 AM
root / root
0644
errors.py
17.278 KB
6 Mar 2024 12.27 AM
root / root
0644
fields.py
49.305 KB
6 Mar 2024 12.27 AM
root / root
0644
generics.py
17.388 KB
6 Mar 2024 12.27 AM
root / root
0644
json.py
3.268 KB
6 Mar 2024 12.27 AM
root / root
0644
main.py
43.338 KB
6 Mar 2024 12.27 AM
root / root
0644
mypy.py
37.837 KB
6 Mar 2024 12.27 AM
root / root
0644
networks.py
21.542 KB
6 Mar 2024 12.27 AM
root / root
0644
parse.py
1.768 KB
6 Mar 2024 12.27 AM
root / root
0644
py.typed
0 KB
6 Mar 2024 12.27 AM
root / root
0644
schema.py
46.499 KB
6 Mar 2024 12.27 AM
root / root
0644
tools.py
2.76 KB
6 Mar 2024 12.27 AM
root / root
0644
types.py
34.551 KB
6 Mar 2024 12.27 AM
root / root
0644
typing.py
18.551 KB
6 Mar 2024 12.27 AM
root / root
0644
utils.py
25.204 KB
6 Mar 2024 12.27 AM
root / root
0644
validators.py
21.374 KB
6 Mar 2024 12.27 AM
root / root
0644
version.py
1.015 KB
6 Mar 2024 12.27 AM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF