o
    i                     @   s  d Z ddlZddlZedZejd dkrOddlZddlmZ	 ddl
mZ ddlmZ G dd	 d	eZed
ZedZdd ZeZeZeZdd Zdd Zn6ddlZddlZddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 eZe Zdd Zdd Zejdkrddl!m"Z" ndd Z"ejdkrddlm#Z# n	G dd dej$Z#d+dd Z%d!d" Z&d#d$ Z'd%d& Z(d'd( Z)d)d* Z*dS ),zJ
Imports for compatibility with Python 2, Python 3 and Google App Engine.
    Nzdatadog.util   )UserDict)StringIO)urlparsec                   @   s   e Zd Zdd Zdd ZdS )
LazyLoaderc                 C   s
   || _ d S N)module_name)selfr    r
   G/home/ubuntu/.local/lib/python3.10/site-packages/datadog/util/compat.py__init__   s   
zLazyLoader.__init__c                 C   s   dd l }|| j}t||S )Nr   )	importlibimport_moduler   getattr)r	   namer   modr
   r
   r   __getattr__   s   
zLazyLoader.__getattr__N)__name__
__module____qualname__r   r   r
   r
   r
   r   r      s    r   zurllib.requestconfigparserc                   C   s   t  S r   )r   ConfigParserr
   r
   r
   r   r   )      r   c                 C   s   t |  S r   )iteritemsdr
   r
   r   	iteritems0   s   r   c                 C   s   t | S r   nextr   r
   r
   r   iternext3   r   r!   )r   )imap)IterableUserDictc                 C      |   S r   )r   r   r
   r
   r   r   E   r   c                 C   r$   r   r   r    r
   r
   r   r!   H   r   )r      )iscoroutinefunctionc                  O   s   dS )NFr
   )argskwargsr
   r
   r   r&   R      r&   )      )NullHandlerc                   @   s   e Zd Zdd ZdS )r,   c                 C   s   d S r   r
   )r	   recordr
   r
   r   emit\   r)   zNullHandler.emitN)r   r   r   r.   r
   r
   r
   r   r,   [   s    r,   c                 C   s   t j| |fkS )zD
    Assert that the Python version is higher than `$maj.$min`.
    )sysversion_info)majorminorr
   r
   r   _is_py_version_higher_than`   s   r3   c                   C   s   t dS )z4
    Assert that Python is version 3 or higher.
    r   r3   r
   r
   r
   r   is_p3kg   s   r5   c                   C   
   t ddS )z6
    Assert that Python is version 3.2 or higher.
    r   r*   r4   r
   r
   r
   r   is_higher_py32n      
r7   c                   C   r6   )z6
    Assert that Python is version 3.5 or higher.
    r   r%   r4   r
   r
   r
   r   is_higher_py35u   r8   r9   c                   C   s
   dt jv S )z?
    Assert that PyPy is being used (regardless of 2 or 3)
    __pypy__)r/   builtin_module_namesr
   r
   r
   r   is_pypy|   r8   r<   c                 C   s2   t  s| S td| j ddlm} |dd| S )z
    A decorator that conditionally enables a lru_cache of size 512 if
    the version of Python can support it (>3.2) and otherwise returns
    the original function
    z"Enabling LRU cache for function %sr   )	lru_cachei   )maxsize)r7   logdebugr   	functoolsr=   )funcr=   r
   r
   r   conditional_lru_cache   s
   rC   )r   )+__doc__loggingr/   	getLoggerr?   r0   builtinscollectionsr   r#   ior   urllib.parser   objectr   url_libr   r   mapr"   input	get_inputstrtextr   r!   __builtin__	cStringIO	itertoolsurllib2	raw_inputunicodeinspectr&   r,   Handlerr3   r5   r7   r9   r<   rC   r
   r
   r
   r   <module>   sT   
	



