OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
elastic_transport
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
01/09/2025 02:18:04 AM
rwxr-xr-x
📄
__init__.py
3.91 KB
05/14/2024 03:17:35 PM
rw-r--r--
📁
__pycache__
-
05/14/2024 03:17:35 PM
rwxr-xr-x
📄
_async_transport.py
19.74 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_compat.py
3.47 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_exceptions.py
3.78 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_models.py
12.56 KB
05/14/2024 03:17:35 PM
rw-r--r--
📁
_node
-
05/14/2024 03:17:35 PM
rwxr-xr-x
📄
_node_pool.py
14.67 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_otel.py
2.98 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_response.py
6.25 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_serializer.py
8.41 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_transport.py
22.95 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_utils.py
3.28 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
_version.py
811 bytes
05/14/2024 03:17:35 PM
rw-r--r--
📄
client_utils.py
8.02 KB
05/14/2024 03:17:35 PM
rw-r--r--
📄
py.typed
0 bytes
05/14/2024 03:17:35 PM
rw-r--r--
Editing: _compat.py
Close
# Licensed to Elasticsearch B.V. under one or more contributor # license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright # ownership. Elasticsearch B.V. licenses this file to you under # the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import inspect import sys from pathlib import Path from typing import Any, Awaitable, TypeVar, Union from urllib.parse import quote as _quote from urllib.parse import urlencode, urlparse string_types = (str, bytes) if sys.version_info >= (3, 7): # dict is insert ordered on Python 3.7+ ordered_dict = dict else: from collections import OrderedDict as ordered_dict T = TypeVar("T") async def await_if_coro(coro: Union[T, Awaitable[T]]) -> T: if inspect.iscoroutine(coro): return await coro # type: ignore return coro # type: ignore _QUOTE_ALWAYS_SAFE = frozenset( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-~" ) def quote(string: str, safe: str = "/") -> str: # Redefines 'urllib.parse.quote()' to always have the '~' character # within the 'ALWAYS_SAFE' list. The character was added in Python 3.7 safe = "".join(_QUOTE_ALWAYS_SAFE.union(set(safe))) return _quote(string, safe) try: from threading import Lock except ImportError: class Lock: # type: ignore def __enter__(self) -> None: pass def __exit__(self, *_: Any) -> None: pass def acquire(self, _: bool = True) -> bool: return True def release(self) -> None: pass def warn_stacklevel() -> int: """Dynamically determine warning stacklevel for warnings based on the call stack""" try: # Grab the root module from the current module '__name__' module_name = __name__.partition(".")[0] module_path = Path(sys.modules[module_name].__file__) # type: ignore[arg-type] # If the module is a folder we're looking at # subdirectories, otherwise we're looking for # an exact match. module_is_folder = module_path.name == "__init__.py" if module_is_folder: module_path = module_path.parent # Look through frames until we find a file that # isn't a part of our module, then return that stacklevel. for level, frame in enumerate(inspect.stack()): # Garbage collecting frames frame_filename = Path(frame.filename) del frame if ( # If the module is a folder we look at subdirectory module_is_folder and module_path not in frame_filename.parents ) or ( # Otherwise we're looking for an exact match. not module_is_folder and module_path != frame_filename ): return level except KeyError: pass return 0 __all__ = [ "await_if_coro", "ordered_dict", "quote", "urlparse", "urlencode", "string_types", "Lock", ]