Current Path: > > opt > hc_python > > lib > python3.12 > > 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 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__pycache__ | Directory | - | - | |
__init__.py | File | 2946 bytes | April 04 2025 08:02:35. | |
_hypothesis_plugin.py | File | 14847 bytes | April 04 2025 08:02:35. | |
annotated_types.py | File | 3157 bytes | April 04 2025 08:02:35. | |
class_validators.py | File | 14672 bytes | April 04 2025 08:02:35. | |
color.py | File | 16844 bytes | April 04 2025 08:02:35. | |
config.py | File | 6532 bytes | April 04 2025 08:02:35. | |
dataclasses.py | File | 18172 bytes | April 04 2025 08:02:35. | |
datetime_parse.py | File | 7724 bytes | April 04 2025 08:02:35. | |
decorator.py | File | 10339 bytes | April 04 2025 08:02:35. | |
env_settings.py | File | 14105 bytes | April 04 2025 08:02:35. | |
error_wrappers.py | File | 5196 bytes | April 04 2025 08:02:35. | |
errors.py | File | 17726 bytes | April 04 2025 08:02:35. | |
fields.py | File | 50649 bytes | April 04 2025 08:02:35. | |
generics.py | File | 17871 bytes | April 04 2025 08:02:35. | |
json.py | File | 3390 bytes | April 04 2025 08:02:35. | |
main.py | File | 44541 bytes | April 04 2025 08:02:35. | |
mypy.py | File | 38774 bytes | April 04 2025 08:02:35. | |
networks.py | File | 22124 bytes | April 04 2025 08:02:35. | |
parse.py | File | 1821 bytes | April 04 2025 08:02:35. | |
py.typed | File | 0 bytes | April 04 2025 08:02:35. | |
schema.py | File | 47760 bytes | April 04 2025 08:02:35. | |
tools.py | File | 2881 bytes | April 04 2025 08:02:35. | |
types.py | File | 35455 bytes | April 04 2025 08:02:35. | |
typing.py | File | 19387 bytes | April 04 2025 08:02:35. | |
utils.py | File | 25919 bytes | April 04 2025 08:02:35. | |
validators.py | File | 21996 bytes | April 04 2025 08:02:35. | |
version.py | File | 1039 bytes | April 04 2025 08:02:35. |
import json import pickle from enum import Enum from pathlib import Path from typing import Any, Callable, Union from pydantic.v1.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