????

Your IP : 18.220.222.38


Current Path : /proc/self/root/lib/python3.6/site-packages/future/backports/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/future/backports/__pycache__/misc.cpython-36.pyc

3

�c'��@s�dZddlmZddlZddlmZddlmZ	m
ZddlZddl
ZddlmZddlmZmZmZddlmZmZmZmZdd	lmZmZm Z m!Z!m"Z"e r�dd
l#m$Z$m%Z%ndd
l&m$Z$m%Z%dd�Zdd
lm'Z'e!r�d4dd�Z(nddlm(Z(e"�r*yddl)m*Z*Wn"e+k
�r&ddl,m*Z*YnXn4yddl-m*Z*Wn"e+k
�r\ddl.m*Z*YnXd5dd�Z/Gdd�de0�Z1Gdd�de2�Z3yddlmZddl
m4Z4Wne+k
�r�YnXdd�Z5Gdd�de2�Z6d d!�Z7d6d"d�Z(Gd#d$�d$e%�Z8dd%lm9Z9e9dfd&d'�Z:d(d)�Z;e3Z<e6Z=e7Z>e(Z?eZ@e5ZAe/ZBe8ZCe:ZDe;ZEejFd7k�r�dd,l#m3Z3m6Z6ddlm(Z(dd-lGm;Z;ydd.lm7Z7Wne+k
�r�YnXdd/lm:Z:ejFd8k�r�ddlmZdd1l#m5Z5ejFd9k�r�dd2lHm/Z/dd3l#m8Z8dS):a�
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�MutableMappingcCstt|��S)zZ
    Return the ceiling of x as an int.
    This is the smallest integral value >= x.
    )�int�oldceil)�x�r�/usr/lib/python3.6/misc.pyr#sr)�islice�ccsx|V||7}qWdS)Nr)�start�steprrr�count3sr)r)�	get_ident�...cs�fdd�}|S)zGDecorator to make a repr function return fillvalue for a recursive callcsLt�����fdd�}t�d�|_t�d�|_t�d�|_t�di�|_|S)NcsBt|�t�f}|�kr�S�j|�z�|�}Wd�j|�X|S)N)�idr�add�discard)�self�key�result)�	fillvalue�repr_running�
user_functionrr�wrapperMs
z<recursive_repr.<locals>.decorating_function.<locals>.wrapper�
__module__�__doc__�__name__�__annotations__)�set�getattrr+r,r-r.)r)r*)r')r(r)r�decorating_functionJsz+recursive_repr.<locals>.decorating_functionr)r'r1r)r'r�recursive_reprGsr2c@seZdZdZdS)�_Link�prev�nextr%�__weakref__N)r4r5r%r6)r-r+�__qualname__�	__slots__rrrrr3jsr3c@s�eZdZdZdd�Zejeefdd�Zej	fdd�Z	dd	�Z
d
d�Zdd
�Zd$dd�Z
d%dd�Zdd�ZejZZejZejZejZejZe�Zefdd�Zd&dd�Ze�dd��Zdd�Zdd�Zed'd d!��Z d"d#�Z!dS)(�OrderedDictz)Dictionary that remembers insertion ordercOs�|std��|d}|dd�}t|�dkr<tdt|���y
|jWn>tk
r�t�|_t|j�|_}||_|_i|_	YnX|j
||�dS)z�Initialize 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 argumentrrNz$expected at most 1 arguments, got %d)�	TypeError�len�_OrderedDict__root�AttributeErrorr3�_OrderedDict__hardroot�_proxyr4r5�_OrderedDict__map�_OrderedDict__update)�args�kwdsr$�rootrrr�__init__|s
zOrderedDict.__init__c	CsZ||krJ|�|j|<}|j}|j}||||_|_|_||_||�|_||||�dS)z!od.__setitem__(i, y) <==> od[i]=yN)r@r<r4r5r%)	r$r%�valueZdict_setitemrZLink�linkrD�lastrrr�__setitem__�s
zOrderedDict.__setitem__cCs2|||�|jj|�}|j}|j}||_||_dS)z od.__delitem__(y) <==> del od[y]N)r@�popr4r5)r$r%Zdict_delitemrG�	link_prev�	link_nextrrr�__delitem__�s
zOrderedDict.__delitem__ccs,|j}|j}x||k	r&|jV|j}qWdS)zod.__iter__() <==> iter(od)N)r<r5r%)r$rD�currrrr�__iter__�s

zOrderedDict.__iter__ccs,|j}|j}x||k	r&|jV|j}qWdS)z#od.__reversed__() <==> reversed(od)N)r<r4r%)r$rDrNrrr�__reversed__�s

zOrderedDict.__reversed__cCs*|j}||_|_|jj�tj|�dS)z.od.clear() -> None.  Remove all items from od.N)r<r4r5r@�clear�dict)r$rDrrrrQ�s
zOrderedDict.clearTcCsj|std��|j}|r0|j}|j}||_||_n|j}|j}||_||_|j}|j|=tj||�}||fS)z�od.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.

        zdictionary is empty)�KeyErrorr<r4r5r%r@rRrJ)r$rHrDrGrKrLr%rFrrr�popitem�s zOrderedDict.popitemcCsn|j|}|j}|j}||_||_|j}|rL|j}||_||_||_|_n|j}||_||_||_|_dS)z�Move 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)r@r4r5r<)r$r%rHrGrKrLrD�firstrrr�move_to_end�s
zOrderedDict.move_to_endcCsVtj}t|�d}||j�}|||j�d7}|||j�|7}|||j�|7}|S)Nr�)�sys�	getsizeofr;�__dict__r@r>r<)r$Zsizeof�n�sizerrr�
__sizeof__�s
zOrderedDict.__sizeof__cCs0||kr||}||=|S||jkr,t|��|S)z�od.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__markerrS)r$r%�defaultr&rrrrJs
zOrderedDict.popNcCs||kr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr)r$r%r_rrr�
setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|j��fS)zod.__repr__() <==> repr(od)z%s()z%s(%r))�	__class__r-�list�items)r$rrr�__repr__szOrderedDict.__repr__cCsHt|�j�}xtt��D]}|j|d�qW|jf|p8ddt|j��fS)z%Return state information for picklingN)�vars�copyr9rJra�iterrc)r$Z	inst_dict�krrr�
__reduce__ szOrderedDict.__reduce__cCs
|j|�S)z!od.copy() -> a shallow copy of od)ra)r$rrrrf'szOrderedDict.copycCs |�}x|D]}|||<qW|S)zOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
        If not specified, the value defaults to None.

        r)�cls�iterablerFr$r%rrr�fromkeys+s
zOrderedDict.fromkeyscCs2t|t�r&tj||�o$ttt||��Stj||�S)z�od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
        while comparison to a regular mapping is order-insensitive.

        )�
isinstancer9rR�__eq__�all�map�_eq)r$�otherrrrrn6s
zOrderedDict.__eq__)T)T)N)N)"r-r+r7r,rErRrIr?r3rMrOrPrQrTrVr]r�updaterA�keys�valuesrc�__ne__�objectr^rJr`r2rdrirf�classmethodrlrnrrrrr9ms0
		

	


r9)r)�nlargestcCs*|j}x|D]}||d�d||<qWdS)z!Tally elements from the iterable.rrN)�get)�mappingrkZmapping_get�elemrrr�_count_elementsLs
r}cs�eZdZdZ�fdd�Zdd�Zd/dd�Zd	d
�Zed0dd��Z	�fd
d�Z
dd�Zdd�Zdd�Z
�fdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Z�ZS)1�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)]

    csZ|std��|d}|dd�}t|�dkr<tdt|���tt|�j�|j||�dS)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 argumentrrNz$expected at most 1 arguments, got %d)r:r;�superr~rErs)rBrCr$)rarrrE�szCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.rr)r$r%rrr�__missing__�szCounter.__missing__NcCs6|dkrt|j�td�dd�Stj||j�td�d�S)z�List 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)]

        NrT)r%�reverse)r%)�sortedrc�_itemgetter�_heapqry)r$r[rrr�most_common�s	zCounter.most_commoncCstjtt|j���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�_repeatrc)r$rrr�elements�szCounter.elementscCstd��dS)Nz@Counter.fromkeys() is undefined.  Use Counter(iterable) instead.)�NotImplementedError)rjrk�vrrrrl�szCounter.fromkeyscs�|std��|d}|dd�}t|�dkr<tdt|���|rH|dnd}|dk	r�t|t�r�|r�|j}x8|j�D]\}}|||d�||<qrWq�tt|�j|�n
t	||�|r�|j|�dS)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 argumentrrNz$expected at most 1 arguments, got %d)
r:r;rmrrzrcrr~rsr})rBrCr$rk�self_getr|r)rarrrs�s"

zCounter.updatecOs�|std��|d}|dd�}t|�dkr<tdt|���|rH|dnd}|dk	r�|j}t|t�r�xH|j�D]\}}||d�|||<qnWn x|D]}||d�d||<q�W|r�|j|�dS)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 argumentrrNz$expected at most 1 arguments, got %d)r:r;rzrmrrc�subtract)rBrCr$rkr�r|rrrrr��s 

zCounter.subtractcCs
|j|�S)zReturn a shallow copy.)ra)r$rrrrfszCounter.copycCs|jt|�ffS)N)rarR)r$rrrriszCounter.__reduce__cs||krtt|�j|�dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rr~rM)r$r|)rarrrMszCounter.__delitem__cCs`|sd|jjSy&djtdj|j���}d|jj|fStk
rZdj|jjt|��SXdS)Nz%s()z, z%r: %rz%s({%s})z
{0}({1!r}))	rar-�joinrp�__mod__r�r:�formatrR)r$rcrrrrd#szCounter.__repr__cCsxt|t�stSt�}x0|j�D]$\}}|||}|dkr|||<qWx,|j�D] \}}||krP|dkrP|||<qPW|S)zAdd counts from two counters.

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

        r)rmr~�NotImplementedrc)r$rrr&r|r�newcountrrr�__add__6s
zCounter.__add__cCs|t|t�stSt�}x0|j�D]$\}}|||}|dkr|||<qWx0|j�D]$\}}||krP|dkrPd|||<qPW|S)z� Subtract count, but keep only results with positive counts.

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

        r)rmr~r�rc)r$rrr&r|rr�rrr�__sub__Is
zCounter.__sub__cCs�t|t�stSt�}x<|j�D]0\}}||}||kr:|n|}|dkr|||<qWx,|j�D] \}}||kr\|dkr\|||<q\W|S)z�Union is the maximum of value in either of the input counters.

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

        r)rmr~r�rc)r$rrr&r|r�other_countr�rrr�__or__\s
zCounter.__or__cCsVt|t�stSt�}x<|j�D]0\}}||}||kr:|n|}|dkr|||<qW|S)z� Intersection is the minimum of corresponding counts.

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

        r)rmr~r�rc)r$rrr&r|rr�r�rrr�__and__ps
zCounter.__and__cCs
|t�S)zEAdds an empty counter, effectively stripping negative and zero counts)r~)r$rrr�__pos__�szCounter.__pos__cCs
t�|S)z{Subtracts from an empty counter.  Strips positive and zero counts,
        and flips the sign on negative counts.

        )r~)r$rrr�__neg__�szCounter.__neg__cCs*dd�|j�D�}x|D]
}||=qW|S)z?Internal method to strip elements with a negative or zero countcSsg|]\}}|dks|�qS)rr)�.0r|rrrr�
<listcomp>�sz*Counter._keep_positive.<locals>.<listcomp>)rc)r$�nonpositiver|rrr�_keep_positive�s

zCounter._keep_positivecCs.x$|j�D]\}}|||7<q
W|j�S)z�Inplace add from another counter, keeping only positive counts.

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

        )rcr�)r$rrr|rrrr�__iadd__�s	zCounter.__iadd__cCs.x$|j�D]\}}|||8<q
W|j�S)z�Inplace subtract counter, but keep only results with positive counts.

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

        )rcr�)r$rrr|rrrr�__isub__�s	zCounter.__isub__cCs6x,|j�D] \}}||}||kr
|||<q
W|j�S)z�Inplace union is the maximum of value from either counter.

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

        )rcr�)r$rrr|r�rrrr�__ior__�s
	zCounter.__ior__cCs6x,|j�D] \}}||}||kr
|||<q
W|j�S)z�Inplace intersection is the minimum of corresponding counts.

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

        )rcr�)r$rrr|rr�rrr�__iand__�s
	zCounter.__iand__)N)N)r-r+r7r,rEr�r�r�rxrlrsr�rfrirMrdr�r�r�r�r�r�r�r�r�r�r��
__classcell__rr)rarr~Rs0+

)#

r~cOshd|krtd��tj|dtji|��}|j�\}}|j�}|rd|jd�}|dkrX|d}tj||��|S)z[
    For Python 2.6 compatibility: see
    http://stackoverflow.com/questions/4814970/
    �stdoutz3stdout argument not allowed, it will be overridden.rBNr)�
ValueError�
subprocess�Popen�PIPEZcommunicateZpollrzZCalledProcessError)Z	popenargs�kwargsZprocess�outputZ
unused_errZretcode�cmdrrr�check_output�s
r�ccsx|V||7}qWdS)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+.
    Nr)rrrrrr�sc@s�eZdZdZdd�Zdd�Zdd�Zd'd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZeZe
�dd��Zedd��Zdd�ZeZd(dd�Zedd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS))�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.

    cGst|�pig|_dS)z�Initialize a ChainMap by setting *maps* to the given mappings.
        If no mappings are provided, a single empty dictionary is used.

        N)rb�maps)r$r�rrrrE�szChainMap.__init__cCst|��dS)N)rS)r$r%rrrr�szChainMap.__missing__cCs8x,|jD]"}y||Stk
r(YqXqW|j|�S)N)r�rSr�)r$r%r{rrr�__getitem__s
zChainMap.__getitem__NcCs||kr||S|S)Nr)r$r%r_rrrrzszChainMap.getcCstt�j|j��S)N)r;r/�unionr�)r$rrr�__len__szChainMap.__len__cCstt�j|j��S)N)rgr/r�r�)r$rrrrOszChainMap.__iter__cst�fdd�|jD��S)Nc3s|]}�|kVqdS)Nr)r��m)r%rr�	<genexpr>sz(ChainMap.__contains__.<locals>.<genexpr>)�anyr�)r$r%r)r%r�__contains__szChainMap.__contains__cCs
t|j�S)N)r�r�)r$rrr�__bool__szChainMap.__bool__cCsdj|djtt|j���S)Nz{0.__class__.__name__}({1})z, )r�r�rp�reprr�)r$rrrrd!szChainMap.__repr__cGs|tj|f|���S)z?Create a ChainMap with a single dict created from the iterable.)rRrl)rjrkrBrrrrl&szChainMap.fromkeyscCs$|j|jdj�f|jdd���S)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]rrN)rar�rf)r$rrrrf+sz
ChainMap.copycCs|dkri}|j|f|j��S)z�
        New ChainMap with a new map followed by all previous maps. If no
        map is provided, an empty dict is used.
        N)rar�)r$r�rrr�	new_child1szChainMap.new_childcCs|j|jdd��S)zNew ChainMap from maps[1:].rN)rar�)r$rrr�parents:szChainMap.parentscCs||jd|<dS)Nr)r�)r$r%rFrrrrI?szChainMap.__setitem__cCs8y|jd|=Wn"tk
r2tdj|���YnXdS)Nrz)Key not found in the first mapping: {0!r})r�rSr�)r$r%rrrrMBszChainMap.__delitem__cCs0y|jdj�Stk
r*td��YnXdS)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.rz#No keys found in the first mapping.N)r�rTrS)r$rrrrTHszChainMap.popitemcGs>y|jdj|f|��Stk
r8tdj|���YnXdS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].rz)Key not found in the first mapping: {0!r}N)r�rJrSr�)r$r%rBrrrrJOszChainMap.popcCs|jdj�dS)z'Clear maps[0], leaving maps[1:] intact.rN)r�rQ)r$rrrrQVszChainMap.clear)N)N)r-r+r7r,rEr�r�rzr�rOr�r�Z__nonzero__r2rdrxrlrf�__copy__r��propertyr�rIrMrTrJrQrrrrr��s*

	r�)�_GLOBAL_DEFAULT_TIMEOUTcCs�|\}}d}x�t||dt�D]�}|\}}}	}
}d}y:t|||	�}|tk	rR|j|�|r`|j|�|j|�|Stk
r�}
z|
}|dk	r�|j�WYdd}
~
XqXqW|dk	r�|�ntd��dS)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.
    Nrz!getaddrinfo returns an empty list)	r
rr
r�Z
settimeoutZbindZconnectr�close)ZaddressZtimeoutZsource_address�hostZport�err�resZafZsocktype�protoZ	canonnameZsaZsock�_rrr�create_connection`s(


r�csG�fdd�dt�}|S)z,Convert a cmp= function into a key= functioncsjeZdZdgZdd�Z�fdd�Z�fdd�Z�fdd	�Z�fd
d�Z�fdd
�Z	�fdd�Z
dd�ZdS)zcmp_to_key.<locals>.K�objcWs
||_dS)N)r�)r$r�rBrrrrE�szcmp_to_key.<locals>.K.__init__cs�|j|j�dkS)Nr)r�)r$rr)�mycmprr�__lt__�szcmp_to_key.<locals>.K.__lt__cs�|j|j�dkS)Nr)r�)r$rr)r�rr�__gt__�szcmp_to_key.<locals>.K.__gt__cs�|j|j�dkS)Nr)r�)r$rr)r�rrrn�szcmp_to_key.<locals>.K.__eq__cs�|j|j�dkS)Nr)r�)r$rr)r�rr�__le__�szcmp_to_key.<locals>.K.__le__cs�|j|j�dkS)Nr)r�)r$rr)r�rr�__ge__�szcmp_to_key.<locals>.K.__ge__cs�|j|j�dkS)Nr)r�)r$rr)r�rrrv�szcmp_to_key.<locals>.K.__ne__cSstd��dS)Nzhash not implemented)r:)r$rrr�__hash__�szcmp_to_key.<locals>.K.__hash__N)r-r+r7r8rEr�r�rnr�r�rvr�r)r�rr�K�sr�)rw)r�r�r)r�r�
cmp_to_key�sr�rW�)r9r~)r�)r�)r��)r})r2)r�)rr)r )rr)rWr�)r�r)r�r�)Ir,Z
__future__rr�Zmathrr�operatorrr�rrqrX�heapqr��_weakrefrr?�	itertoolsrr�rr�r	r�r
r
rrZfuture.utilsrrrrr�collectionsrr�collections.abcrr�_threadr�ImportErrorZ
_dummy_threadZthreadZdummy_threadr2rwr3rRr9ryr}r~r�r�r�r�r�Z_OrderedDictZ_CounterZ
_check_output�_countZ_ceilZ__count_elements�_recursive_reprZ	_ChainMapZ_create_connectionZ_cmp_to_key�version_info�	functools�reprlibrrrr�<module>
s�
#V|
l(