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 from functools import lru_cache from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Optional, Type, TypeVar, Union from pydantic.v1.parse import Protocol, load_file, load_str_bytes from pydantic.v1.types import StrBytes from pydantic.v1.typing import display_as_type __all__ = ('parse_file_as', 'parse_obj_as', 'parse_raw_as', 'schema_of', 'schema_json_of') NameFactory = Union[str, Callable[[Type[Any]], str]] if TYPE_CHECKING: from pydantic.v1.typing import DictStrAny def _generate_parsing_type_name(type_: Any) -> str: return f'ParsingModel[{display_as_type(type_)}]' @lru_cache(maxsize=2048) def _get_parsing_type(type_: Any, *, type_name: Optional[NameFactory] = None) -> Any: from pydantic.v1.main import create_model if type_name is None: type_name = _generate_parsing_type_name if not isinstance(type_name, str): type_name = type_name(type_) return create_model(type_name, __root__=(type_, ...)) T = TypeVar('T') def parse_obj_as(type_: Type[T], obj: Any, *, type_name: Optional[NameFactory] = None) -> T: model_type = _get_parsing_type(type_, type_name=type_name) # type: ignore[arg-type] return model_type(__root__=obj).__root__ def parse_file_as( type_: Type[T], 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, type_name: Optional[NameFactory] = None, ) -> T: obj = load_file( path, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads, ) return parse_obj_as(type_, obj, type_name=type_name) def parse_raw_as( type_: Type[T], b: StrBytes, *, content_type: str = None, encoding: str = 'utf8', proto: Protocol = None, allow_pickle: bool = False, json_loads: Callable[[str], Any] = json.loads, type_name: Optional[NameFactory] = None, ) -> T: obj = load_str_bytes( b, proto=proto, content_type=content_type, encoding=encoding, allow_pickle=allow_pickle, json_loads=json_loads, ) return parse_obj_as(type_, obj, type_name=type_name) def schema_of(type_: Any, *, title: Optional[NameFactory] = None, **schema_kwargs: Any) -> 'DictStrAny': """Generate a JSON schema (as dict) for the passed model or dynamically generated one""" return _get_parsing_type(type_, type_name=title).schema(**schema_kwargs) def schema_json_of(type_: Any, *, title: Optional[NameFactory] = None, **schema_json_kwargs: Any) -> str: """Generate a JSON schema (as JSON) for the passed model or dynamically generated one""" return _get_parsing_type(type_, type_name=title).schema_json(**schema_json_kwargs)
SILENT KILLER Tool