REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.42 KB
Close
/proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/pydantic/deprecated/parse.py
Text
Base64
from __future__ import annotations import json import pickle import warnings from enum import Enum from pathlib import Path from typing import TYPE_CHECKING, Any, Callable from typing_extensions import deprecated from ..warnings import PydanticDeprecatedSince20 if not TYPE_CHECKING: # See PyCharm issues https://youtrack.jetbrains.com/issue/PY-21915 # and https://youtrack.jetbrains.com/issue/PY-51428 DeprecationWarning = PydanticDeprecatedSince20 class Protocol(str, Enum): json = 'json' pickle = 'pickle' @deprecated('load_str_bytes is deprecated.', category=PydanticDeprecatedSince20) def load_str_bytes( b: str | bytes, *, content_type: str | None = None, encoding: str = 'utf8', proto: Protocol | None = None, allow_pickle: bool = False, json_loads: Callable[[str], Any] = json.loads, ) -> Any: warnings.warn('load_str_bytes is deprecated.', DeprecationWarning, stacklevel=2) 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}') @deprecated('load_file is deprecated.', category=PydanticDeprecatedSince20) def load_file( path: str | Path, *, content_type: str | None = None, encoding: str = 'utf8', proto: Protocol | None = None, allow_pickle: bool = False, json_loads: Callable[[str], Any] = json.loads, ) -> Any: warnings.warn('load_file is deprecated.', DeprecationWarning, stacklevel=2) 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 )
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 8
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
class_validators.py
9.62 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
config.py
2.55 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
copy_internals.py
7.42 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
decorator.py
10.65 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
json.py
4.36 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
parse.py
2.42 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tools.py
3.20 KB
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
0 B
lrw-r--r--
2024-03-21 11:39:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).