o
    Kg'                     @   s  d Z ddlmZ ddlZddlmZ ddlmZ	m
Z ddlZddlZddlmZ ddlmZmZmZ ddlmZmZmZmZ dd	lmZmZm Z m!Z!m"Z" e rWdd
l#m$Z$m%Z% ndd
l&m$Z$m%Z% dd Zddlm'Z' e!rqd4ddZ(nddlm(Z( e"rzddl)m*Z* W n' e+y   ddl,m*Z* Y nw zddl-m*Z* W n e+y   ddl.m*Z* Y nw d5ddZ/G dd de0Z1G dd de2Z3zddlmZ ddlm4Z4 W n	 e+y   Y nw dd Z5G dd de2Z6d d! Z7d4d"dZ(G d#d$ d$e%Z8dd%lm9Z9 e9dfd&d'Z:d(d) Z;e3Z<e6Z=e7Z>e(Z?eZ@e5ZAe/ZBe8ZCe:ZDe;ZEejFd*krKdd+l#m3Z3m6Z6 ddlm(Z( dd,lGm;Z; zdd-lm7Z7 W n
 e+yD   Y nw dd.lm:Z: ejFd/kr]ddlmZ dd0l#m5Z5 ejFd1krqdd2lHm/Z/ dd3l#m8Z8 dS dS )6a  
Miscellaneous function (re)definitions from the Py3.4+ standard library
for Python 2.6/2.7.

- math.ceil                (for Python 2.7)
- collections.OrderedDict  (for Python 2.6)
- collections.Counter      (for Python 2.6)
- collections.ChainMap     (for all versions prior to Python 3.3)
- itertools.count          (for Python 2.6, with step parameter)
- subprocess.check_output  (for Python 2.6)
- reprlib.recursive_repr   (for Python 2.6+)
- functools.cmp_to_key     (for Python 2.6)
    )absolute_importN)ceil)
itemgettereq)proxy)repeatchainstarmap)getaddrinfoSOCK_STREAMerrorsocket)	iteritems
itervaluesPY2PY26PY3)MappingMutableMappingc                 C   s   t t| S )zZ
    Return the ceiling of x as an int.
    This is the smallest integral value >= x.
    )intoldceil)x r   Z/var/www/html/status_management/venv/lib/python3.10/site-packages/future/backports/misc.pyr   #   s   r   )islice   c                 c       	 | V  | |7 } qNr   startstepr   r   r   count3   s
   r!   )r!   )	get_ident...c                    s    fdd}|S )zGDecorator to make a repr function return fillvalue for a recursive callc                    sL   t    fdd}td|_td|_td|_tdi |_|S )Nc              	      sJ   t | t f}|v r S | z| }W | |S | w r   )idr"   adddiscard)selfkeyresult)	fillvaluerepr_runninguser_functionr   r   wrapperM   s   


z<recursive_repr.<locals>.decorating_function.<locals>.wrapper
__module____doc____name____annotations__)setgetattrr.   r/   r0   r1   )r,   r-   r*   )r+   r,   r   decorating_functionJ   s   z+recursive_repr.<locals>.decorating_functionr   )r*   r5   r   r4   r   recursive_reprG   s   r6   c                   @   s   e Zd ZdZdS )_Link)prevnextr(   __weakref__N)r0   r.   __qualname__	__slots__r   r   r   r   r7   j   s    r7   c                   @   s   e Zd ZdZdd ZejeefddZej	fddZ	dd	 Z
d
d Zdd Zd$ddZd$ddZdd Zej ZZejZejZejZejZe ZefddZd%ddZe dd Zdd Zdd Zed%d d!Z d"d# Z!dS )&OrderedDictz)Dictionary that remembers insertion orderc                  O   s   | st d| d }| dd } t| dkrt dt|  z|j W n tyA   t |_t|j |_}| |_|_i |_	Y nw |j
| i | dS )zInitialize an ordered dictionary.  The signature is the same as
        regular dictionaries, but keyword arguments are not recommended because
        their insertion order is arbitrary.

        z?descriptor '__init__' of 'OrderedDict' object needs an argumentr   r   N$expected at most 1 arguments, got %d)	TypeErrorlen_OrderedDict__rootAttributeErrorr7   _OrderedDict__hardroot_proxyr8   r9   _OrderedDict__map_OrderedDict__update)argskwdsr'   rootr   r   r   __init__|   s   

zOrderedDict.__init__c           	      C   sZ   || vr%|  | j |< }| j}|j}||||_|_|_||_|||_|| || dS )z!od.__setitem__(i, y) <==> od[i]=yN)rE   rA   r8   r9   r(   )	r'   r(   valuedict_setitemr   LinklinkrI   lastr   r   r   __setitem__   s   
zOrderedDict.__setitem__c                 C   s2   || | | j |}|j}|j}||_||_dS )z od.__delitem__(y) <==> del od[y]N)rE   popr8   r9   )r'   r(   dict_delitemrN   	link_prev	link_nextr   r   r   __delitem__   s   

zOrderedDict.__delitem__c                 c   4    | j }|j}||ur|jV  |j}||usdS dS )zod.__iter__() <==> iter(od)N)rA   r9   r(   r'   rI   currr   r   r   __iter__      zOrderedDict.__iter__c                 c   rV   )z#od.__reversed__() <==> reversed(od)N)rA   r8   r(   rW   r   r   r   __reversed__   rZ   zOrderedDict.__reversed__c                 C   s*   | j }| |_|_| j  t|  dS )z.od.clear() -> None.  Remove all items from od.N)rA   r8   r9   rE   cleardict)r'   rI   r   r   r   r\      s   
zOrderedDict.clearTc                 C   sj   | st d| j}|r|j}|j}||_||_n|j}|j}||_||_|j}| j|= t| |}||fS )zod.popitem() -> (k, v), return and remove a (key, value) pair.
        Pairs are returned in LIFO order if last is true or FIFO order if false.

        zdictionary is empty)KeyErrorrA   r8   r9   r(   rE   r]   rQ   )r'   rO   rI   rN   rS   rT   r(   rK   r   r   r   popitem   s    zOrderedDict.popitemc                 C   sp   | j | }|j}|j}||_||_| j}|r'|j}||_||_| |_|_dS |j}||_||_| |_|_dS )zMove an existing element to the end (or beginning if last==False).

        Raises KeyError if the element does not exist.
        When last=True, acts like a fast version of self[key]=self.pop(key).

        N)rE   r8   r9   rA   )r'   r(   rO   rN   rS   rT   rI   firstr   r   r   move_to_end   s   
zOrderedDict.move_to_endc                 C   sV   t j}t| d }|| j}||| jd 7 }||| j| 7 }||| j| 7 }|S )Nr      )sys	getsizeofr@   __dict__rE   rC   rA   )r'   sizeofnsizer   r   r   
__sizeof__   s   
zOrderedDict.__sizeof__c                 C   s0   || v r| | }| |= |S || j u rt||S )zod.pop(k[,d]) -> v, remove specified key and return the corresponding
        value.  If key is not found, d is returned if given, otherwise KeyError
        is raised.

        )_OrderedDict__markerr^   )r'   r(   defaultr)   r   r   r   rQ     s   
zOrderedDict.popNc                 C   s   || v r| | S || |< |S )zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr   r'   r(   rk   r   r   r   
setdefault  s   zOrderedDict.setdefaultc                 C   s*   | s	d| j jf S d| j jt|  f S )zod.__repr__() <==> repr(od)%s()z%s(%r))	__class__r0   listitemsr'   r   r   r   __repr__  s   zOrderedDict.__repr__c                 C   sD   t |  }t t D ]}||d q| jd|pddt|  fS )z%Return state information for picklingNr   )varscopyr=   rQ   ro   iterrq   )r'   	inst_dictkr   r   r   
__reduce__   s   zOrderedDict.__reduce__c                 C   
   |  | S )z!od.copy() -> a shallow copy of odro   rr   r   r   r   ru   '     
zOrderedDict.copyc                 C   s   |  }|D ]}|||< q|S )zOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
        If not specified, the value defaults to None.

        r   )clsiterablerK   r'   r(   r   r   r   fromkeys+  s   
zOrderedDict.fromkeysc                 C   s2   t |trt| |ottt| |S t| |S )zod.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
        while comparison to a regular mapping is order-insensitive.

        )
isinstancer=   r]   __eq__allmap_eqr'   otherr   r   r   r   6  s   
zOrderedDict.__eq__)Tr   )"r0   r.   r;   r/   rJ   r]   rP   rD   r7   rU   rY   r[   r\   r_   ra   ri   r   updaterF   keysvaluesrq   __ne__objectrj   rQ   rm   r6   rs   ry   ru   classmethodr   r   r   r   r   r   r=   m   s6    
		


	


r=   )r   )nlargestc                 C   s&   | j }|D ]}||dd | |< qdS )z!Tally elements from the iterable.r   r   N)get)mappingr~   mapping_getelemr   r   r   _count_elementsL  s   r   c                       s   e Zd ZdZ fddZdd Zd/ddZd	d
 Zed/ddZ	 fddZ
dd Zdd Zdd Z fddZdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Z  ZS )0Countera  Dict subclass for counting hashable items.  Sometimes called a bag
    or multiset.  Elements are stored as dictionary keys and their counts
    are stored as dictionary values.

    >>> c = Counter('abcdeabcdabcaba')  # count elements from a string

    >>> c.most_common(3)                # three most common elements
    [('a', 5), ('b', 4), ('c', 3)]
    >>> sorted(c)                       # list all unique elements
    ['a', 'b', 'c', 'd', 'e']
    >>> ''.join(sorted(c.elements()))   # list elements with repetitions
    'aaaaabbbbcccdde'
    >>> sum(c.values())                 # total of all counts
    15

    >>> c['a']                          # count of letter 'a'
    5
    >>> for elem in 'shazam':           # update counts from an iterable
    ...     c[elem] += 1                # by adding 1 to each element's count
    >>> c['a']                          # now there are seven 'a'
    7
    >>> del c['b']                      # remove all 'b'
    >>> c['b']                          # now there are zero 'b'
    0

    >>> d = Counter('simsalabim')       # make another counter
    >>> c.update(d)                     # add in the second counter
    >>> c['a']                          # now there are nine 'a'
    9

    >>> c.clear()                       # empty the counter
    >>> c
    Counter()

    Note:  If a count is set to zero or reduced to zero, it will remain
    in the counter until the entry is deleted or the counter is cleared:

    >>> c = Counter('aaabbc')
    >>> c['b'] -= 2                     # reduce the count of 'b' by two
    >>> c.most_common()                 # 'b' is still in, but its count is zero
    [('a', 3), ('c', 1), ('b', 0)]

    c                     s^   | st d| d }| dd } t| dkrt dt|  tt|  |j| i | dS )a	  Create a new, empty Counter object.  And if given, count elements
        from an input iterable.  Or, initialize the count from another mapping
        of elements to their counts.

        >>> c = Counter()                           # a new, empty counter
        >>> c = Counter('gallahad')                 # a new counter from an iterable
        >>> c = Counter({'a': 4, 'b': 2})           # a new counter from a mapping
        >>> c = Counter(a=4, b=2)                   # a new counter from keyword args

        z;descriptor '__init__' of 'Counter' object needs an argumentr   r   Nr>   )r?   r@   superr   rJ   r   )rG   rH   r'   r{   r   r   rJ     s   zCounter.__init__c                 C   s   dS )z1The count of elements not in the Counter is zero.r   r   r'   r(   r   r   r   __missing__  s   zCounter.__missing__Nc                 C   s6   |du rt |  tdddS tj||  tddS )zList the n most common elements and their counts from the most
        common to the least.  If n is None, then list all element counts.

        >>> Counter('abcdeabcdabcaba').most_common(3)
        [('a', 5), ('b', 4), ('c', 3)]

        Nr   T)r(   reverser(   )sortedrq   _itemgetter_heapqr   )r'   rg   r   r   r   most_common  s   	zCounter.most_commonc                 C   s   t tt|  S )a  Iterator over elements repeating each as many times as its count.

        >>> c = Counter('ABCABC')
        >>> sorted(c.elements())
        ['A', 'A', 'B', 'B', 'C', 'C']

        # Knuth's example for prime factors of 1836:  2**2 * 3**3 * 17**1
        >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
        >>> product = 1
        >>> for factor in prime_factors.elements():     # loop over factors
        ...     product *= factor                       # and multiply them
        >>> product
        1836

        Note, if an element's count has been set to zero or is a negative
        number, elements() will ignore it.

        )_chainfrom_iterable_starmap_repeatrq   rr   r   r   r   elements  s   zCounter.elementsc                 C      t d)Nz@Counter.fromkeys() is undefined.  Use Counter(iterable) instead.)NotImplementedError)r}   r~   vr   r   r   r     s   zCounter.fromkeysc                     s   | st d| d }| dd } t| dkrt dt|  | r$| d nd}|durUt|trP|rG|j}| D ]\}}|||d ||< q8ntt|| nt	|| |r^|| dS dS )a  Like dict.update() but add counts instead of replacing them.

        Source can be an iterable, a dictionary, or another Counter instance.

        >>> c = Counter('which')
        >>> c.update('witch')           # add elements from another iterable
        >>> d = Counter('watch')
        >>> c.update(d)                 # add elements from another counter
        >>> c['h']                      # four 'h' in which, witch, and watch
        4

        z9descriptor 'update' of 'Counter' object needs an argumentr   r   Nr>   )
r?   r@   r   r   r   rq   r   r   r   r   rG   rH   r'   r~   self_getr   r!   r{   r   r   r     s&   

zCounter.updatec                  O   s   | st d| d }| dd } t| dkrt dt|  | r$| d nd}|durS|j}t|trE| D ]\}}||d| ||< q6n|D ]}||dd ||< qG|r\|| dS dS )a  Like dict.update() but subtracts counts instead of replacing them.
        Counts can be reduced below zero.  Both the inputs and outputs are
        allowed to contain zero and negative counts.

        Source can be an iterable, a dictionary, or another Counter instance.

        >>> c = Counter('which')
        >>> c.subtract('witch')             # subtract elements from another iterable
        >>> c.subtract(Counter('watch'))    # subtract elements from another counter
        >>> c['h']                          # 2 in which, minus 1 in witch, minus 1 in watch
        0
        >>> c['w']                          # 1 in which, minus 1 in witch, minus 1 in watch
        -1

        z;descriptor 'subtract' of 'Counter' object needs an argumentr   r   Nr>   )r?   r@   r   r   r   rq   subtractr   r   r   r   r     s$   
zCounter.subtractc                 C   rz   )zReturn a shallow copy.r{   rr   r   r   r   ru     r|   zCounter.copyc                 C   s   | j t| ffS r   )ro   r]   rr   r   r   r   ry     s   zCounter.__reduce__c                    s    || v rt t| | dS dS )zGLike dict.__delitem__() but does not raise KeyError for missing values.N)r   r   rU   )r'   r   r{   r   r   rU     s   zCounter.__delitem__c                 C   s`   | sd| j j S zdtdj|  }d| j j|f W S  ty/   d| j jt|  Y S w )Nrn   , z%r: %rz%s({%s})z
{0}({1!r}))	ro   r0   joinr   __mod__r   r?   formatr]   )r'   rq   r   r   r   rs   #  s   zCounter.__repr__c                 C   sp   t |tstS t }|  D ]\}}|||  }|dkr |||< q| D ]\}}|| vr5|dkr5|||< q%|S )zAdd counts from two counters.

        >>> Counter('abbb') + Counter('bcc')
        Counter({'b': 4, 'c': 2, 'a': 1})

        r   r   r   NotImplementedrq   r'   r   r)   r   r!   newcountr   r   r   __add__6  s   
zCounter.__add__c                 C   st   t |tstS t }|  D ]\}}|||  }|dkr |||< q| D ]\}}|| vr7|dk r7d| ||< q%|S )z Subtract count, but keep only results with positive counts.

        >>> Counter('abbbc') - Counter('bccd')
        Counter({'b': 2, 'a': 1})

        r   r   r   r   r   r   __sub__I  s   
zCounter.__sub__c                 C   s|   t |tstS t }|  D ]\}}|| }||k r|n|}|dkr&|||< q| D ]\}}|| vr;|dkr;|||< q+|S )zUnion is the maximum of value in either of the input counters.

        >>> Counter('abbb') | Counter('bcc')
        Counter({'b': 3, 'c': 2, 'a': 1})

        r   r   r'   r   r)   r   r!   other_countr   r   r   r   __or__\  s   
zCounter.__or__c                 C   sR   t |tstS t }|  D ]\}}|| }||k r|n|}|dkr&|||< q|S )z Intersection is the minimum of corresponding counts.

        >>> Counter('abbb') & Counter('bcc')
        Counter({'b': 1})

        r   r   r   r   r   r   __and__p  s   
zCounter.__and__c                 C   s
   | t   S )zEAdds an empty counter, effectively stripping negative and zero countsr   rr   r   r   r   __pos__  r|   zCounter.__pos__c                 C   s
   t  |  S )z{Subtracts from an empty counter.  Strips positive and zero counts,
        and flips the sign on negative counts.

        r   rr   r   r   r   __neg__  s   
zCounter.__neg__c                 C   s&   dd |   D }|D ]}| |= q| S )z?Internal method to strip elements with a negative or zero countc                 S   s   g | ]
\}}|d ks|qS )r   r   ).0r   r!   r   r   r   
<listcomp>  s    z*Counter._keep_positive.<locals>.<listcomp>)rq   )r'   nonpositiver   r   r   r   _keep_positive  s   zCounter._keep_positivec                 C   s*   |  D ]\}}| |  |7  < q|  S )zInplace add from another counter, keeping only positive counts.

        >>> c = Counter('abbb')
        >>> c += Counter('bcc')
        >>> c
        Counter({'b': 4, 'c': 2, 'a': 1})

        rq   r   r'   r   r   r!   r   r   r   __iadd__     	zCounter.__iadd__c                 C   s*   |  D ]\}}| |  |8  < q|  S )zInplace subtract counter, but keep only results with positive counts.

        >>> c = Counter('abbbc')
        >>> c -= Counter('bccd')
        >>> c
        Counter({'b': 2, 'a': 1})

        r   r   r   r   r   __isub__  r   zCounter.__isub__c                 C   s2   |  D ]\}}| | }||kr|| |< q|  S )zInplace union is the maximum of value from either counter.

        >>> c = Counter('abbb')
        >>> c |= Counter('bcc')
        >>> c
        Counter({'b': 3, 'c': 2, 'a': 1})

        r   )r'   r   r   r   r!   r   r   r   __ior__     	zCounter.__ior__c                 C   s2   |   D ]\}}|| }||k r|| |< q|  S )zInplace intersection is the minimum of corresponding counts.

        >>> c = Counter('abbb')
        >>> c &= Counter('bcc')
        >>> c
        Counter({'b': 1})

        r   )r'   r   r   r!   r   r   r   r   __iand__  r   zCounter.__iand__r   )r0   r.   r;   r/   rJ   r   r   r   r   r   r   r   ru   ry   rU   rs   r   r   r   r   r   r   r   r   r   r   r   __classcell__r   r   r{   r   r   R  s2    2
)#r   c                  O   sh   d|v rt dtj| dtji|}| \}}| }|r2|d}|du r,| d }t|||S )z[
    For Python 2.6 compatibility: see
    http://stackoverflow.com/questions/4814970/
    stdoutz3stdout argument not allowed, it will be overridden.rG   Nr   )
ValueError
subprocessPopenPIPEcommunicatepollr   CalledProcessError)	popenargskwargsprocessoutput
unused_errretcodecmdr   r   r   check_output  s   
r   c                 c   r   )z
    ``itertools.count`` in Py 2.6 doesn't accept a step
    parameter. This is an enhanced version of ``itertools.count``
    for Py2.6 equivalent to ``itertools.count`` in Python 2.7+.
    r   r   r   r   r   r!     s
   c                   @   s   e Zd ZdZdd Zdd Zdd Zd'd	d
Zdd Zdd Z	dd Z
dd ZeZe dd Zedd Zdd ZeZd'ddZedd Zdd Zdd  Zd!d" Zd#d$ Zd%d& ZdS )(ChainMapa   A ChainMap groups multiple dicts (or other mappings) together
    to create a single, updateable view.

    The underlying mappings are stored in a list.  That list is public and can
    accessed or updated using the *maps* attribute.  There is no other state.

    Lookups search the underlying mappings successively until a key is found.
    In contrast, writes, updates, and deletions only operate on the first
    mapping.

    c                 G   s   t |pi g| _dS )zInitialize a ChainMap by setting *maps* to the given mappings.
        If no mappings are provided, a single empty dictionary is used.

        N)rp   maps)r'   r   r   r   r   rJ     s   zChainMap.__init__c                 C   s   t |r   )r^   r   r   r   r   r        zChainMap.__missing__c              	   C   s6   | j D ]}z|| W   S  ty   Y qw | |S r   )r   r^   r   )r'   r(   r   r   r   r   __getitem__  s   

zChainMap.__getitem__Nc                 C   s   || v r| | S |S r   r   rl   r   r   r   r     s   zChainMap.getc                 C      t t j| j S r   )r@   r2   unionr   rr   r   r   r   __len__     zChainMap.__len__c                 C   r   r   )rv   r2   r   r   rr   r   r   r   rY     r   zChainMap.__iter__c                    s   t  fdd| jD S )Nc                 3   s    | ]} |v V  qd S r   r   )r   mr   r   r   	<genexpr>  s    z(ChainMap.__contains__.<locals>.<genexpr>anyr   r   r   r   r   __contains__  s   zChainMap.__contains__c                 C   s
   t | jS r   r   rr   r   r   r   __bool__     
zChainMap.__bool__c                 C   s   d | dtt| jS )Nz{0.__class__.__name__}({1})r   )r   r   r   reprr   rr   r   r   r   rs   !  s   zChainMap.__repr__c                 G   s   | t j|g|R  S )z?Create a ChainMap with a single dict created from the iterable.)r]   r   )r}   r~   rG   r   r   r   r   &  s   zChainMap.fromkeysc                 C   s&   | j | jd  g| jdd R  S )zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r   r   N)ro   r   ru   rr   r   r   r   ru   +  s   &zChainMap.copyc                 C   s    |du ri }| j |g| jR  S )z
        New ChainMap with a new map followed by all previous maps. If no
        map is provided, an empty dict is used.
        Nro   r   )r'   r   r   r   r   	new_child1  s   zChainMap.new_childc                 C   s   | j | jdd  S )zNew ChainMap from maps[1:].r   Nr   rr   r   r   r   parents:  s   zChainMap.parentsc                 C   s   || j d |< d S Nr   )r   )r'   r(   rK   r   r   r   rP   ?  r   zChainMap.__setitem__c                 C   s0   z	| j d |= W d S  ty   td|w )Nr   )Key not found in the first mapping: {0!r})r   r^   r   r   r   r   r   rU   B  s
   zChainMap.__delitem__c                 C   s(   z| j d  W S  ty   tdw )zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r   z#No keys found in the first mapping.)r   r_   r^   rr   r   r   r   r_   H  s
   zChainMap.popitemc                 G   s8   z| j d j|g|R  W S  ty   td|w )zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r   r   )r   rQ   r^   r   )r'   r(   rG   r   r   r   rQ   O  s
   zChainMap.popc                 C   s   | j d   dS )z'Clear maps[0], leaving maps[1:] intact.r   N)r   r\   rr   r   r   r   r\   V  s   zChainMap.clearr   )r0   r.   r;   r/   rJ   r   r   r   r   rY   r   r   __nonzero__r6   rs   r   r   ru   __copy__r   propertyr   rP   rU   r_   rQ   r\   r   r   r   r   r     s2    



	
r   )_GLOBAL_DEFAULT_TIMEOUTc                 C   s   | \}}d}t ||dtD ]G}|\}}}	}
}d}z t|||	}|tur(|| |r/|| || |W   S  tyT } z|}|durJ|  W Y d}~qd}~ww |dur[|td)a  Backport of 3-argument create_connection() for Py2.6.

    Connect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    Nr   z!getaddrinfo returns an empty list)	r
   r   r   r   
settimeoutbindconnectr   close)addresstimeoutsource_addresshostporterrresafsocktypeproto	canonnamesasock_r   r   r   create_connection`  s,   



r  c                    s   G  fdddt }|S )z,Convert a cmp= function into a key= functionc                       sj   e Zd ZdgZdd Z fddZ fddZ fdd	Z fd
dZ fddZ	 fddZ
dd ZdS )zcmp_to_key.<locals>.Kobjc                 W   s
   || _ d S r   r  )r'   r  rG   r   r   r   rJ     r   zcmp_to_key.<locals>.K.__init__c                    s    | j |j dk S r   r  r   mycmpr   r   __lt__  r   zcmp_to_key.<locals>.K.__lt__c                    s    | j |j dkS r   r  r   r  r   r   __gt__  r   zcmp_to_key.<locals>.K.__gt__c                    s    | j |j dkS r   r  r   r  r   r   r     r   zcmp_to_key.<locals>.K.__eq__c                    s    | j |j dkS r   r  r   r  r   r   __le__  r   zcmp_to_key.<locals>.K.__le__c                    s    | j |j dkS r   r  r   r  r   r   __ge__  r   zcmp_to_key.<locals>.K.__ge__c                    s    | j |j dkS r   r  r   r  r   r   r     r   zcmp_to_key.<locals>.K.__ne__c                 S   r   )Nzhash not implemented)r?   rr   r   r   r   __hash__  r   zcmp_to_key.<locals>.K.__hash__N)r0   r.   r;   r<   rJ   r  r  r   r  r	  r   r
  r   r  r   r   K  s    r  )r   )r  r  r   r  r   
cmp_to_key  s   r  )rb      )r=   r   )r  )r   )r  )   r   )r   )r  r  )r6   )r   )r   r   )r#   )Ir/   
__future__r   r   mathr   r   operatorr   r   r   r   rc   heapqr   _weakrefr   rD   	itertoolsr   r   r   r   r	   r   r   r
   r   r   future.utilsr   r   r   r   r   collectionsr   r   collections.abcr   r!   _threadr"   ImportError_dummy_threadthreaddummy_threadr6   r   r7   r]   r=   r   r   r   r   r   r   r  r  _OrderedDict_Counter_check_output_count_ceil__count_elements_recursive_repr	_ChainMap_create_connection_cmp_to_keyversion_info	functoolsreprlibr   r   r   r   <module>   s    
# V  |
l
)