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dadaeQZYnXdS)c)absolute_importN)StringIO)FileType)shutil)urlparse urlunparseurljoinurlsplit urlunsplit) urlretrievequoteunquote url2pathname pathname2urlContentTooShortError splittypecCs+t|tr!|jd}nt|S)Nzutf-8) isinstanceunicodeencode_quote)sr5/tmp/pip-ztkk0jow-build/pip/_vendor/distlib/compat.pyrsr) RequesturlopenURLError HTTPErrorHTTPBasicAuthHandlerHTTPPasswordMgr HTTPSHandler HTTPHandlerHTTPRedirectHandler build_opener) HTMLParser)ifilter) ifilterfalsecCsYtdkr*ddl}|jdantj|}|rO|jddSd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.Nrz ^(.*)@(.*)$r) _userprogrecompilematchgroup)hostr*r,rrr splituser-s  r/) TextIOWrapper) rr r r/rrr r r) rr rrrrr r!r"r#r$)rrr) filterfalse)match_hostnameCertificateErrorc@seZdZdS)r3N)__name__ __module__ __qualname__rrrrr3Us r3cCsg}x[|jdD]J}|dkr8|jdqtj|}|j|jddqWtjddj|dtjS) N.*z[^.]+z\*z[^.]*z\Az\.z\Z)splitappendr*escapereplacer+join IGNORECASE)dnpatsfragrrr_dnsname_to_patYs rBcCsg|stdng}|jdf}xI|D]A\}}|dkr4t|j|redS|j|q4q4W|sxi|jdfD]R}xI|D]A\}}|dkrt|j|rdS|j|qqWqWnt|dkr(td|d jtt |fn;t|dkrWtd ||d fn td dS) a7Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules are mostly followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing. zempty or no certificatesubjectAltNameDNSNsubject commonNamerz&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found) ValueErrorgetrBr,r:lenr3r=maprepr)certhostnamednsnamessankeyvaluesubrrrr2gs.  %r2)SimpleNamespacec@s"eZdZdZddZdS) ContainerzR A generic container for when multiple values need to be returned cKs|jj|dS)N)__dict__update)selfkwargsrrr__init__szContainer.__init__N)r4r5r6__doc__rYrrrrrTs rT)whichc sdd}tjjr5||r1SdS|dkr\tjjdtj}n|sfdS|jtj}tj dkrtj |kr|j dtj ntjjddjtj}t fd d |Drg}qfd d |D}n g}t }xu|D]m}tjj|}||kr-|j|x9|D].} tjj|| } || |re| SqeWq-q-WdS) aKGiven a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. cSs5tjj|o4tj||o4tjj| S)N)ospathexistsaccessisdir)fnmoderrr _access_checks$zwhich.._access_checkNPATHwin32rPATHEXTc3s*|] }jj|jVqdS)N)lowerendswith).0ext)cmdrr szwhich..csg|]}|qSrr)rjrk)rlrr s zwhich..)r\r]dirnameenvironrHdefpathr9pathsepsysplatformcurdirinsertanysetnormcaseaddr=) rlrbr]rcpathextfilesseendirnormdirthefilenamer)rlrr[s8  !       r[)ZipFile __enter__) ZipExtFilec@s4eZdZddZddZddZdS)rcCs|jj|jdS)N)rUrV)rWbaserrrrYszZipExtFile.__init__cCs|S)Nr)rWrrrrszZipExtFile.__enter__cGs|jdS)N)close)rWexc_inforrr__exit__szZipExtFile.__exit__N)r4r5r6rYrrrrrrrs   rc@s4eZdZddZddZddZdS)rcCs|S)Nr)rWrrrrszZipFile.__enter__cGs|jdS)N)r)rWrrrrrszZipFile.__exit__cOstj|||}t|S)N) BaseZipFileopenr)rWargsrXrrrrrsz ZipFile.openN)r4r5r6rrrrrrrrs   r)python_implementationcCs@dtjkrdStjdkr&dStjjdr<dSdS)z6Return a string identifying the Python implementation.PyPyjavaJython IronPythonCPython)rsversionr\r startswithrrrrrsr) sysconfig)CallablecCs t|tS)N)rr)objrrrcallablesrmbcsstrictsurrogateescapecCsOt|tr|St|tr2|jttStdt|jdS)Nzexpect bytes or str, not %s) rbytes text_typer _fsencoding _fserrors TypeErrortyper4)filenamerrrfsencode#s rcCsOt|tr|St|tr2|jttStdt|jdS)Nzexpect bytes or str, not %s) rrrdecoderrrrr4)rrrrfsdecode,s r)detect_encoding)BOM_UTF8lookupzcoding[:=]\s*([-\w.]+)cCsd|ddjjdd}|dks=|jdrAdS|d ks\|jdr`dS|S)z(Imitates get_normal_name in tokenizer.c.N _-zutf-8zutf-8-latin-1 iso-8859-1 iso-latin-1latin-1- iso-8859-1- iso-latin-1-)rrr)rrr)rhr<r)orig_encencrrr_get_normal_name=s" rc syjjWntk r*dYnXdd}d}fdd}fdd}|}|jtrd|d d}d }n|s|gfS||}|r||gfS|}|s||gfS||}|r|||gfS|||gfS) a> The detect_encoding() function is used to detect the encoding that should be used to decode a Python source file. It requires one argment, readline, in the same way as the tokenize() generator. It will call readline a maximum of twice, and return the encoding used (as a string) and a list of any lines (left as bytes) it has read in. It detects the encoding from the presence of a utf-8 bom or an encoding cookie as specified in pep-0263. If both a bom and a cookie are present, but disagree, a SyntaxError will be raised. If the encoding cookie is an invalid charset, raise a SyntaxError. Note that if a utf-8 bom is found, 'utf-8-sig' is returned. If no encoding is specified, then the default of 'utf-8' will be returned. NFzutf-8c s(y SWntk r#dSYnXdS)N) StopIterationr)readlinerr read_or_stop`s  z%detect_encoding..read_or_stopcs9y|jd}WnEtk rZd}dk rJdj|}nt|YnXtj|}|stdSt|d}yt|}WnItk rdkrd|}ndj|}t|YnXr5|j dkr(dkr d}ndj}t|n|d 7}n|S) Nzutf-8z'invalid or missing encoding declarationz {} for {!r}rzunknown encoding: zunknown encoding for {!r}: {}zencoding problem: utf-8z encoding problem for {!r}: utf-8z-sig) rUnicodeDecodeErrorformat SyntaxError cookie_refindallrr LookupErrorr)line line_stringmsgmatchesencodingcodec) bom_foundrrr find_cookiefs6          z$detect_encoding..find_cookieTrz utf-8-sig)__self__rAttributeErrorrr)rrdefaultrrfirstsecondr)rrrrrHs4  &        r)r;r()unescape)ChainMap)MutableMapping)recursive_reprz...csfdd}|S)zm Decorator to make a repr function return fillvalue for a recursive call csptfdd}td|_td|_td|_tdi|_|S)Nc sWt|tf}|kr%Sj|z|}Wdj|X|S)N)id get_identrzdiscard)rWrPresult) fillvalue repr_running user_functionrrwrappers  z=_recursive_repr..decorating_function..wrapperr5rZr4__annotations__)rxgetattrr5rZr4r)rr)r)rrrdecorating_functions  z,_recursive_repr..decorating_functionr)rrr)rr_recursive_reprsrc@s eZdZdZddZddZddZdd d Zd d Zd dZ ddZ ddZ e ddZ eddZddZeZddZeddZddZdd Zd!d"Zd#d$Zd%d&ZdS)'ra 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|pig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)listmaps)rWrrrrrYszChainMap.__init__cCst|dS)N)KeyError)rWrPrrr __missing__szChainMap.__missing__c CsBx2|jD]'}y ||SWq tk r0Yq Xq W|j|S)N)rrr)rWrPmappingrrr __getitem__s    zChainMap.__getitem__NcCs||kr||S|S)Nr)rWrPrrrrrHsz ChainMap.getcCsttj|jS)N)rIrxunionr)rWrrr__len__szChainMap.__len__cCsttj|jS)N)iterrxrr)rWrrr__iter__szChainMap.__iter__cs tfdd|jDS)Nc3s|]}|kVqdS)Nr)rjm)rPrrrmsz(ChainMap.__contains__..)rwr)rWrPr)rPr __contains__szChainMap.__contains__cCs t|jS)N)rwr)rWrrr__bool__szChainMap.__bool__cCs%dj|djtt|jS)Nz{0.__class__.__name__}({1})z, )rr=rJrKr)rWrrr__repr__szChainMap.__repr__cGs|tj||S)z?Create a ChainMap with a single dict created from the iterable.)dictfromkeys)clsiterablerrrrrszChainMap.fromkeyscCs*|j|jdj|jddS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]rrN) __class__rcopy)rWrrrr sz ChainMap.copycCs|ji|jS)z;New ChainMap with a new dict followed by all previous maps.)rr)rWrrr new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rN)rr)rWrrrparentsszChainMap.parentscCs||jd| od[i]=yrrN)rr)rWrPrQ dict_setitemr lastrrrrms    )zOrderedDict.__setitem__cCs@||||jj|\}}}||d<||d del od[y]rrN)rr)rWrP dict_delitem link_prev link_nextrrrrws  zOrderedDict.__delitem__ccs=|j}|d}x#||k r8|dV|d}qWdS)zod.__iter__() <==> iter(od)rr(N)r)rWr currrrrrs    zOrderedDict.__iter__ccs=|j}|d}x#||k r8|dV|d}qWdS)z#od.__reversed__() <==> reversed(od)rr(N)r)rWr rrrr __reversed__s    zOrderedDict.__reversed__c CsyZx$|jjD]}|dd=qW|j}||dg|dd<|jjWntk rnYnXtj|dS)z.od.clear() -> None. Remove all items from od.N)r itervaluesrrrr)rWnoder rrrrs  zOrderedDict.clearTcCs|stdn|j}|rO|d}|d}||d<||d (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 emptyrrr()rrrrr)rWr r linkr rrPrQrrrrs            zOrderedDict.popitemcCs t|S)zod.keys() -> list of keys in od)r)rWrrrkeysszOrderedDict.keyscsfddDS)z#od.values() -> list of values in odcsg|]}|qSrr)rjrP)rWrrrns z&OrderedDict.values..r)rWr)rWrvaluesszOrderedDict.valuescsfddDS)z.od.items() -> list of (key, value) pairs in odcs g|]}||fqSrr)rjrP)rWrrrns z%OrderedDict.items..r)rWr)rWritemsszOrderedDict.itemscCs t|S)z0od.iterkeys() -> an iterator over the keys in od)r)rWrrriterkeysszOrderedDict.iterkeysccsx|D]}||VqWdS)z2od.itervalues -> an iterator over the values in odNr)rWkrrrrs zOrderedDict.itervaluesccs$x|D]}|||fVqWdS)z=od.iteritems -> an iterator over the (key, value) items in odNr)rWrrrr iteritemss zOrderedDict.iteritemscOs&t|dkr.tdt|fn|sCtdn|d}f}t|dkrr|d}nt|trxw|D]}|||| None. Update od from dict/iterable E and F. If E is a dict instance, does: for k in E: od[k] = E[k] If E has a .keys() method, does: for k in E.keys(): od[k] = E[k] Or if E is an iterable of items, does: for k, v in E: od[k] = v In either case, this is followed by: for k, v in F.items(): od[k] = v r(z8update() takes at most 2 positional arguments (%d given)z,update() takes at least 1 argument (0 given)rrrN)rIrrrhasattrrr)rrrWotherrPrQrrrrVs&    zOrderedDict.updatecCsC||kr!||}||=|S||jkr?t|n|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)rWrPrrrrrrs  zOrderedDict.popNcCs"||kr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odr)rWrPrrrr setdefaults  zOrderedDict.setdefaultc Cs|si}nt|tf}||kr4dSd|| repr(od)z...rz%s()z%s(%r)N)r _get_identrr4r)rWZ _repr_runningZcall_keyrrrrs   zOrderedDict.__repr__cs~fddD}tj}x'ttD]}|j|dq;W|rnj|f|fSj|ffS)z%Return state information for picklingcs g|]}||gqSrr)rjr)rWrrrns z*OrderedDict.__reduce__..N)varsrrrr)rWr inst_dictrr)rWr __reduce__szOrderedDict.__reduce__cCs |j|S)z!od.copy() -> a shallow copy of od)r)rWrrrrszOrderedDict.copycCs(|}x|D]}||| New ordered dictionary with keys from S and values equal to v (which defaults to None). r)rrrQdrPrrrr"s  zOrderedDict.fromkeyscCsMt|tr=t|t|ko<|j|jkStj||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. )rrrIrr__eq__)rWrrrrr#-s.zOrderedDict.__eq__cCs ||k S)Nr)rWrrrr__ne__6szOrderedDict.__ne__cCs t|S)z@od.viewkeys() -> a set-like object providing a view on od's keys)r)rWrrrviewkeys;szOrderedDict.viewkeyscCs t|S)z an object providing a view on od's values)r)rWrrr viewvalues?szOrderedDict.viewvaluescCs t|S)zBod.viewitems() -> a set-like object providing a view on od's items)r)rWrrr viewitemsCszOrderedDict.viewitems)"r4r5r6rZrYrrrrrrrrrrrrrrVrobjectrrrrr!rrrr#r$r%r&r'rrrrrQs:                   r)BaseConfigurator valid_identz^[a-z_][a-z0-9_]*$cCs,tj|}|s(td|ndS)Nz!Not a valid Python identifier: %rT) IDENTIFIERr,rG)rrrrrr*Msr*c@s1eZdZdZddZdddZdS)ConvertingDictz A converting dictionary wrapper.cCsqtj||}|jj|}||k rm|||[a-z]+)://(?P.*)$z ^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$ ext_convertrk cfg_convertcfgcCst||_||j_dS)N)r,configr-)rWr8rrrrYszBaseConfigurator.__init__c Cs|jd}|jd}yz|j|}x`|D]X}|d|7}yt||}Wq7tk r|j|t||}Yq7Xq7W|SWn]tk rtjdd\}}td||f}|||_ |_ |YnXdS)zl Resolve strings to objects using standard import and attribute syntax. r7rrNzCannot resolve %r: %s) r9rimporterrr ImportErrorrsrrG __cause__ __traceback__) rWrrusedfoundrAetbvrrrresolves"    zBaseConfigurator.resolvecCs |j|S)z*Default converter for the ext:// protocol.)rB)rWrQrrrr5szBaseConfigurator.ext_convertc Cs\|}|jj|}|dkr7td|n!||jd}|j|jd}x|rW|jj|}|r||jd}n|jj|}|r|jd}|jj|s||}qyt |}||}Wqt k r||}YqXn|r>||jd}qgtd||fqgW|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r) WORD_PATTERNr,rGendr8groups DOT_PATTERN INDEX_PATTERN DIGIT_PATTERNintr)rWrQrestrr"r2nrrrr6s2     zBaseConfigurator.cfg_convertcCs/t|t r7t|tr7t|}||_nt|t rnt|trnt|}||_nt|t rt|trt|}||_nt|tr+|j j |}|r+|j }|d}|j j |d}|r(|d}t||}||}q(q+n|S)z Convert values to an appropriate type. dicts, lists and tuples are replaced by their converting alternatives. Strings are checked to see if they have a conversion format and are converted if they do. prefixNr)rr,rr-r/rr0r4 string_typesCONVERT_PATTERNr, groupdictvalue_convertersrHr)rWrQrr"rL converterrrrrr.s*         zBaseConfigurator.convertcsjd}t|s-|j|}njdd}tfddD}||}|rx-|jD]\}}t|||q}Wn|S)z1Configure an object with a user-supplied factory.z()r7Ncs,g|]"}t|r||fqSr)r*)rjr)r8rrrns z5BaseConfigurator.configure_custom..)rrrBrrsetattr)rWr8rpropsrXrrrQr)r8rconfigure_customs  z!BaseConfigurator.configure_customcCs"t|trt|}n|S)z0Utility function which converts lists to tuples.)rrr4)rWrQrrras_tuple$szBaseConfigurator.as_tupleN)r4r5r6rZr*r+rNrCrFrGrHrP staticmethod __import__r9rYrBr5r6r.rTrUrrrrr)s"       "  r))rr) __future__rr\r*rs version_infor basestringrMrrtypesr file_type __builtin__builtins ConfigParser configparserZ _backportrrr r r r urllibr rrrrrrrurllib2rrrrrr r!r"r#r$httplib xmlrpclibQueuequeuer%htmlentitydefs raw_input itertoolsr&filterr'r1r)r/iostrr0 urllib.parseurllib.request urllib.error http.clientclientrequest xmlrpc.client html.parser html.entitiesentitiesinputsslr2r3r:rGrBrSrTr(r[F_OKX_OKzipfilerrrrZBaseZipExtFilertrrr NameError collectionsrrrrgetfilesystemencodingrrtokenizercodecsrrr+rrhtmlr;cgirrrreprlibrrimprrthreadrr dummy_thread_abcollrrrrlogging.configr)r*Ir+r,rrr/r4r0rrrrs      (4  F         @L   )  !A                   [   b