OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
jsons
Server IP: 2a02:4780:11:1084:0:327f:3464:10
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
09/05/2025 09:36:16 AM
rwxr-xr-x
📄
__init__.py
11.57 KB
03/16/2023 12:57:19 PM
rw-r--r--
📁
__pycache__
-
03/16/2023 12:57:19 PM
rwxr-xr-x
📄
_cache.py
1.23 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_common_impl.py
5.89 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_compatibility_impl.py
3.06 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_datetime_impl.py
4.98 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_dump_impl.py
4.01 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_extra_impl.py
1.7 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_fork_impl.py
1.39 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_key_transformers.py
1.32 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_lizers_impl.py
5.73 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_load_impl.py
8.16 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_multitasking.py
2.34 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_package_info.py
376 bytes
03/16/2023 12:57:19 PM
rw-r--r--
📄
_transform_impl.py
1.48 KB
03/16/2023 12:57:19 PM
rw-r--r--
📄
_validation.py
2.64 KB
03/16/2023 12:57:19 PM
rw-r--r--
📁
classes
-
03/16/2023 12:57:19 PM
rwxr-xr-x
📄
decorators.py
6.62 KB
03/16/2023 12:57:19 PM
rw-r--r--
📁
deserializers
-
03/16/2023 12:57:19 PM
rwxr-xr-x
📄
exceptions.py
6.02 KB
03/16/2023 12:57:19 PM
rw-r--r--
📁
serializers
-
03/16/2023 12:57:19 PM
rwxr-xr-x
Editing: _compatibility_impl.py
Close
""" PRIVATE MODULE: do not import (from) it directly. This module contains functionality for supporting the compatibility of jsons with multiple Python versions. """ import sys import typing from enum import Enum from jsons._cache import cached class Flag(Enum): """ This is a light version of the Flag enum type that was introduced in Python3.6. It supports the use of pipes for members (Flag.A | Flag.B). """ @classmethod def _get_inst(cls, value): try: result = cls(value) except ValueError: pseudo_member = object.__new__(cls) pseudo_member._value_ = value contained = [elem.name for elem in cls if elem in pseudo_member] pseudo_member._name_ = '|'.join(contained) result = pseudo_member return result def __or__(self, other: 'Flag') -> 'Flag': new_value = other.value | self.value return self._get_inst(new_value) def __contains__(self, item: 'Flag') -> bool: return item.value == self.value & item.value __ror__ = __or__ @cached def tuple_with_ellipsis(tup: type) -> bool: # Python3.5: Tuples have __tuple_use_ellipsis__ # Python3.7: Tuples have __args__ use_el = getattr(tup, '__tuple_use_ellipsis__', None) if use_el is None: use_el = tup.__args__[-1] is ... return use_el @cached def get_union_params(un: type) -> list: # Python3.5: Unions have __union_params__ # Python3.7: Unions have __args__ return getattr(un, '__union_params__', getattr(un, '__args__', None)) @cached def get_naked_class(cls: type) -> type: # Python3.5: typing classes have __extra__ # Python3.6: typing classes have __extra__ # Python3.7: typing classes have __origin__ # Return the non-generic class (e.g. dict) of a generic type (e.g. Dict). return getattr(cls, '__extra__', getattr(cls, '__origin__', cls)) @cached def get_type_hints(callable_: callable, fallback_ns=None): # Python3.5: get_type_hints raises on classes without explicit constructor. # Python3.10: get_type_hints on classes does not take the constructor. try: result = typing.get_type_hints(callable_) except AttributeError: result = {} except NameError: # attempt to resolve in global namespace - this works around an # issue in 3.7 whereby __init__ created by dataclasses fails # to find it's context. See https://bugs.python.org/issue34776 if fallback_ns is not None: context_dict = sys.modules[fallback_ns].__dict__ result = typing.get_type_hints(callable_, globalns=context_dict) if sys.version_info.minor >= 10 and type(callable_) is type: annotations_from_init = typing.get_type_hints(callable_.__init__) if 'return' in annotations_from_init: # Python3.10: 'return' is a key that holds the returning type. del annotations_from_init['return'] result = {**result, **annotations_from_init} return result