U .e @sBddlmZddlZddlZddlZz ddlZWnek rHdZYnXejddkr~ddlmZe fZ e Z ddl mZddlZddlZddlmZddlmZmZmZmZmZdd lmZmZmZm Z m!Z!m"Z"m#Z#d d Zddl$Z$dd l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-er&dd l$m.Z.ddl/Z/ddl0Z0ddl1Z2ddl3m3Z3ddl4Z4e5Z5ddl6m7Z8ddl6m9Z:da;ddZ<nddl=mZe>fZ e>Z ddl=m?ZddlZddlZddlZddl@mZmZmZmd?Zod@dAZiYnXzddBlpmqZqWn"ek rddBlrmqZqYnXejddCdDkr:e3jsZsn ddElpmsZszddFl`mtZtWndek rddGl`muZuzddHlvmwZxWn ek rdedJdKZxYnXGdLdMdMeuZtYnXzddNlymzZzWnHek rzddNl{mzZzWn ek rdfdOdPZzYnXYnXzddQl`m|Z|Wnek rzddRl}m~ZWn"ek rjddRlm~ZYnXzddSlmZmZmZWnek rYnXGdTdUdUeZ|YnXzddVlmZmZWnvek r<emdWejZdXdYZGdZd[d[eZdgd\d]ZGd^d_d_eZGd`dadaeZGdbdcdceQZYnXdS)h)absolute_importN)StringIO)FileType)shutil)urlparse urlunparseurljoinurlsplit urlunsplit) urlretrievequoteunquote url2pathname pathname2urlContentTooShortError splittypecCst|tr|d}t|S)Nutf-8) isinstanceunicodeencode_quote)sr>/usr/lib/python3.8/site-packages/pip/_vendor/distlib/compat.pyrs  r) RequesturlopenURLError HTTPErrorHTTPBasicAuthHandlerHTTPPasswordMgr HTTPHandlerHTTPRedirectHandler build_opener) HTTPSHandler) HTMLParser)ifilter) ifilterfalsecCs<tdkrddl}|dat|}|r4|ddSd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.Nrz ^(.*)@(.*)$r) _userprogrecompilematchgroup)Zhostr+r-rrr splituser4s   r/) TextIOWrapper) rr r r/rrr r r) rr rrrr r!r"r#r$)rrr) filterfalse)match_hostnameCertificateErrorc@s eZdZdS)r3N)__name__ __module__ __qualname__rrrrr3^sr3c Csg}|s dS|d}|d|dd}}|d}||krNtdt||sb||kS|dkrv|dn>|d s|d r|t|n|t| d d |D]}|t|qt d d |dtj } | |S)zpMatching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 F.rrN*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)splitcountr3reprlowerappend startswithr+escapereplacer,join IGNORECASEr-) ZdnhostnameZ max_wildcardsZpatspartsZleftmostZ remainderZ wildcardsfragZpatrrr_dnsname_matchbs*    rFcCs|s tdg}|dd}|D]*\}}|dkr t||r@dS||q |s|ddD]6}|D],\}}|dkrdt||rdS||qdq\t|dkrtd |d tt|fn*t|dkrtd ||d fntd dS)a=Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing. ztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDZsubjectAltNamerZDNSNZsubjectZ commonNamerz&hostname %r doesn't match either of %s, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found) ValueErrorgetrFr=lenr3rAmapr;)ZcertrCZdnsnamesZsankeyvaluesubrrrr2s2         r2)SimpleNamespacec@seZdZdZddZdS) ContainerzR A generic container for when multiple values need to be returned cKs|j|dSN__dict__update)selfkwargsrrr__init__szContainer.__init__N)r4r5r6__doc__rWrrrrrPsrP)whichc s"dd}tjr&||r"SdS|dkr>tjdtj}|sFdS|tj}tj dkrtj |krt| dtj tjddtj}t fd d |Drg}q‡fd d |D}ng}t }|D]P}tj|}||kr|||D](} tj|| } || |r| SqqdS) 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. cSs&tj|o$t||o$tj| SrQ)ospathexistsaccessisdir)fnmoderrr _access_checks zwhich.._access_checkNPATHZwin32rZPATHEXTc3s |]}|VqdSrQ)r<endswith.0extcmdrr szwhich..csg|] }|qSrrrerhrr szwhich..)rZr[dirnameenvironrIdefpathr9pathsepsysplatformcurdirinsertanysetnormcaseaddrA) rir`r[raZpathextfilesseendirZnormdirZthefilenamerrhrrYs8         rY)ZipFile __enter__) ZipExtFilec@s$eZdZddZddZddZdS)r~cCs|j|jdSrQrR)rUbaserrrrWszZipExtFile.__init__cCs|SrQrrUrrrr}szZipExtFile.__enter__cGs |dSrQcloserUexc_inforrr__exit__szZipExtFile.__exit__N)r4r5r6rWr}rrrrrr~sr~c@s$eZdZddZddZddZdS)r|cCs|SrQrrrrrr}"szZipFile.__enter__cGs |dSrQrrrrrr%szZipFile.__exit__cOstj|f||}t|SrQ) BaseZipFileopenr~)rUargsrVrrrrr)sz ZipFile.openN)r4r5r6r}rrrrrrr|!sr|)python_implementationcCs0dtjkrdStjdkrdStjdr,dSdS)z6Return a string identifying the Python implementation.ZPyPyjavaZJythonZ IronPythonZCPython)rpversionrZr{r>rrrrr0s   r) sysconfig)CallablecCs t|tSrQ)rr)objrrrcallableDsrrmbcsstrictsurrogateescapecCs:t|tr|St|tr$|ttStdt|jdSNzexpect bytes or str, not %s) rbytes text_typer _fsencoding _fserrors TypeErrortyper4filenamerrrfsencodeXs   rcCs:t|tr|St|tr$|ttStdt|jdSr) rrrdecoderrrrr4rrrrfsdecodeas   r)detect_encoding)BOM_UTF8lookupzcoding[:=]\s*([-\w.]+)cCsH|dddd}|dks*|dr.dS|dks@|drDd S|S) z(Imitates get_normal_name in tokenizer.c.N _-rzutf-8-)zlatin-1 iso-8859-1z iso-latin-1)zlatin-1-z iso-8859-1-z iso-latin-1-r)r<r@r>)orig_encencrrr_get_normal_namersrcsz jjWntk r$dYnXdd}d}fdd}fdd}|}|trpd|d d}d }|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 argument, 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. NFrcs$zWStk rYdSXdS)N) StopIterationr)readlinerr read_or_stopsz%detect_encoding..read_or_stopcsz|d}Wn4tk rBd}dk r6d|}t|YnXt|}|sVdSt|d}z t|}Wn:tk rdkrd|}n d|}t|YnXr|j dkr؈dkrd}n d}t||d 7}|S) Nrz'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_stringmsgZmatchesencodingcodec) bom_foundrrr find_cookies8       z$detect_encoding..find_cookieTrz utf-8-sig)__self__r{AttributeErrorr>r)rrdefaultrrfirstsecondr)rrrrr}s4   &     r)r?r))r)unescape)ChainMap)MutableMapping)recursive_repr...csfdd}|S)zm Decorator to make a repr function return fillvalue for a recursive call csLtfdd}td|_td|_td|_tdi|_|S)Nc sBt|tf}|krS|z |}W5|X|SrQ)id get_identrwdiscard)rUrLresult) fillvalue repr_running user_functionrrwrappers   z=_recursive_repr..decorating_function..wrapperr5rXr4__annotations__)rugetattrr5rXr4r)rrr)rrrdecorating_functions   z,_recursive_repr..decorating_functionr)rrrrr_recursive_reprs rc@seZdZdZddZddZddZd'd 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|p ig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)listmaps)rUrrrrrWszChainMap.__init__cCs t|dSrQ)KeyErrorrUrLrrr __missing__szChainMap.__missing__c Cs:|jD](}z||WStk r,YqXq||SrQ)rrr)rUrLmappingrrr __getitem__s  zChainMap.__getitem__NcCs||kr||S|SrQrrUrLrrrrrI%sz ChainMap.getcCsttj|jSrQ)rJruunionrrrrr__len__(szChainMap.__len__cCsttj|jSrQ)iterrurrrrrr__iter__+szChainMap.__iter__cstfdd|jDS)Nc3s|]}|kVqdSrQr)rfmrLrrrj/sz(ChainMap.__contains__..rtrrrrr __contains__.szChainMap.__contains__cCs t|jSrQrrrrr__bool__1szChainMap.__bool__cCsd|dtt|jS)Nz{0.__class__.__name__}({1})rG)rrArKr;rrrrr__repr__4szChainMap.__repr__cGs|tj|f|S)z?Create a ChainMap with a single dict created from the iterable.)dictfromkeys)clsiterablerrrrr9szChainMap.fromkeyscCs$|j|jdf|jddS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]rrN) __class__rcopyrrrrr>sz ChainMap.copycCs|jif|jS)z;New ChainMap with a new dict followed by all previous maps.rrrrrr new_childDszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rNrrrrrparentsHszChainMap.parentscCs||jd|<dS)Nr)r)rUrLrMrrr __setitem__MszChainMap.__setitem__cCs8z|jd|=Wn"tk r2td|YnXdS)Nr(Key not found in the first mapping: {!r})rrrrrrr __delitem__PszChainMap.__delitem__cCs2z|jdWStk r,tdYnXdS)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)rpopitemrrrrrrVszChainMap.popitemcGs@z|jdj|f|WStk r:td|YnXdS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].rrN)rpoprr)rUrLrrrrr]sz ChainMap.popcCs|jddS)z'Clear maps[0], leaving maps[1:] intact.rN)rclearrrrrrdszChainMap.clear)N)r4r5r6rXrWrrrIrrrrrr classmethodrr__copy__rpropertyrrrrrrrrrrrs.     r)cache_from_sourcecCs"|dkr d}|rd}nd}||S)NFcor)r[debug_overridesuffixrrrrns r) OrderedDict)r)KeysView ValuesView ItemsViewc@seZdZdZddZejfddZejfddZdd Zd d Z d d Z d6ddZ ddZ ddZ ddZddZddZddZddZeZeZefdd Zd7d"d#Zd8d$d%Zd&d'Zd(d)Zed9d*d+Zd,d-Zd.d/Zd0d1Zd2d3Z d4d5Z!d!S):rz)Dictionary that remembers insertion ordercOsnt|dkrtdt|z |jWn6tk r\g|_}||dg|dd<i|_YnX|j||dS)zInitialize an ordered dictionary. Signature is the same as for regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. rz$expected at most 1 arguments, got %dN)rJr_OrderedDict__rootr_OrderedDict__map_OrderedDict__update)rUrkwdsrootrrrrWs    zOrderedDict.__init__cCsF||kr6|j}|d}|||g|d<|d<|j|<||||dS)z!od.__setitem__(i, y) <==> od[i]=yrrN)rr)rUrLrMZ dict_setitemrlastrrrrs  zOrderedDict.__setitem__cCs0||||j|\}}}||d<||d<dS)z od.__delitem__(y) <==> del od[y]rrN)rr)rUrLZ dict_delitem link_prev link_nextrrrrs zOrderedDict.__delitem__ccs.|j}|d}||k r*|dV|d}qdS)zod.__iter__() <==> iter(od)rr)NrrUrZcurrrrrrs  zOrderedDict.__iter__ccs.|j}|d}||k r*|dV|d}qdS)z#od.__reversed__() <==> reversed(od)rr)Nrrrrr __reversed__s  zOrderedDict.__reversed__cCsdz@|jD]}|dd=q |j}||dg|dd<|jWntk rTYnXt|dS)z.od.clear() -> None. Remove all items from od.N)r itervaluesrrrr)rUZnoderrrrrs zOrderedDict.clearTcCs||s td|j}|r8|d}|d}||d<||d<n |d}|d}||d<||d<|d}|j|=t||}||fS)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. zdictionary is emptyrrr))rrrrr)rUrrlinkrrrLrMrrrrs   zOrderedDict.popitemcCst|S)zod.keys() -> list of keys in od)rrrrrkeysszOrderedDict.keyscsfddDS)z#od.values() -> list of values in odcsg|] }|qSrrrfrLrrrrksz&OrderedDict.values..rrrrrvaluesszOrderedDict.valuescsfddDS)z.od.items() -> list of (key, value) pairs in odcsg|]}||fqSrrr rrrrksz%OrderedDict.items..rrrrritemsszOrderedDict.itemscCst|S)z0od.iterkeys() -> an iterator over the keys in od)rrrrriterkeysszOrderedDict.iterkeysccs|D]}||VqdS)z2od.itervalues -> an iterator over the values in odNrrUkrrrr szOrderedDict.itervaluesccs|D]}|||fVqdS)z=od.iteritems -> an iterator over the (key, value) items in odNrrrrr iteritemsszOrderedDict.iteritemscOst|dkr tdt|fn |s,td|d}d}t|dkrL|d}t|trn|D]}||||<qZn 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)rrrr N)rJrrrhasattrr r)rrrUotherrLrMrrrrTs(       zOrderedDict.updatecCs0||kr||}||=|S||jkr,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)rUrLrrrrrr*s zOrderedDict.popNcCs||kr||S|||<|S)zDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in odrrrrr setdefault7szOrderedDict.setdefaultcCsf|si}t|tf}||kr"dSd||<z.|sBd|jjfWSd|jj|fWS||=XdS)zod.__repr__() <==> repr(od)rrz%s()z%s(%r)N)r _get_identrr4r)rUZ _repr_runningZcall_keyrrrr>szOrderedDict.__repr__csXfddD}t}ttD]}||dq(|rLj|f|fSj|ffS)z%Return state information for picklingcsg|]}||gqSrrrfrrrrrkNsz*OrderedDict.__reduce__..N)varsrrrr)rUrZ inst_dictrrrr __reduce__Ls zOrderedDict.__reduce__cCs ||S)z!od.copy() -> a shallow copy of od)rrrrrrVszOrderedDict.copycCs|}|D] }|||<q |S)zOD.fromkeys(S[, v]) -> New ordered dictionary with keys from S and values equal to v (which defaults to None). r)rrrMdrLrrrrZs zOrderedDict.fromkeyscCs6t|tr*t|t|ko(||kSt||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. )rrrJrr__eq__rUrrrrres  zOrderedDict.__eq__cCs ||k SrQrrrrr__ne__nszOrderedDict.__ne__cCst|S)z@od.viewkeys() -> a set-like object providing a view on od's keys)rrrrrviewkeyssszOrderedDict.viewkeyscCst|S)z an object providing a view on od's values)rrrrr viewvalueswszOrderedDict.viewvaluescCst|S)zBod.viewitems() -> a set-like object providing a view on od's items)rrrrr viewitems{szOrderedDict.viewitems)T)N)N)N)"r4r5r6rXrWrrrrr rrr rrrr rrTrobjectrrrrrrrrrrr r!r"rrrrrs:         r)BaseConfigurator valid_identz^[a-z_][a-z0-9_]*$cCst|}|std|dS)Nz!Not a valid Python identifier: %rT) IDENTIFIERr-rH)rrrrrr%s  r%c@s"eZdZdZddZdddZdS)ConvertingDictz A converting dictionary wrapper.cCsJt||}|j|}||k rF|||<t|tttfkrF||_||_ |SrQ) rr configuratorconvertrr'ConvertingListConvertingTupleparentrLrUrLrMrrrrrs   zConvertingDict.__getitem__NcCsLt|||}|j|}||k rH|||<t|tttfkrH||_||_ |SrQ) rrIr(r)rr'r*r+r,rLrUrLrrMrrrrrIs  zConvertingDict.get)N)r4r5r6rXrrIrrrrr's r'cCsDt|||}|j|}||k r@t|tttfkr@||_||_ |SrQ) rrr(r)rr'r*r+r,rLr.rrrrs  rc@s"eZdZdZddZdddZdS) r*zA converting list wrapper.cCsJt||}|j|}||k rF|||<t|tttfkrF||_||_ |SrQ) rrr(r)rr'r*r+r,rLr-rrrrs   zConvertingList.__getitem__cCs<t||}|j|}||k r8t|tttfkr8||_|SrQ) rrr(r)rr'r*r+r,)rUidxrMrrrrrs   zConvertingList.popN)r/)r4r5r6rXrrrrrrr*s r*c@seZdZdZddZdS)r+zA converting tuple wrapper.cCsBt||}|j|}||k r>t|tttfkr>||_||_ |SrQ) tuplerr(r)rr'r*r+r,rLr-rrrrs   zConvertingTuple.__getitem__N)r4r5r6rXrrrrrr+sr+c@seZdZdZedZedZedZedZ edZ ddd Z e e Zd d Zd d ZddZddZddZddZddZdS)r$zQ The configurator base class which defines some useful defaults. z%^(?P[a-z]+)://(?P.*)$z ^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$ ext_convert cfg_convert)rgZcfgcCst||_||j_dSrQ)r'configr()rUr4rrrrWs zBaseConfigurator.__init__c Cs|d}|d}z^||}|D]H}|d|7}zt||}Wq$tk rj||t||}Yq$Xq$|WStk rtdd\}}td||f}|||_ |_ |YnXdS)zl Resolve strings to objects using standard import and attribute syntax. r7rrNzCannot resolve %r: %s) r9rimporterrr ImportErrorrprrH __cause__ __traceback__) rUrr{ZusedfoundrEetbvrrrresolves"     zBaseConfigurator.resolvecCs ||S)z*Default converter for the ext:// protocol.)r=rUrMrrrr2 szBaseConfigurator.ext_convertcCs|}|j|}|dkr&td|n||d}|j|d}|r|j|}|rn||d}nd|j|}|r|d}|j|s||}n2zt |}||}Wnt k r||}YnX|r||d}qHtd||fqH|S)z*Default converter for the cfg:// protocol.NzUnable to convert %rrzUnable to convert %r at %r) WORD_PATTERNr-rHendr4groups DOT_PATTERN INDEX_PATTERN DIGIT_PATTERNintr)rUrMrestrrr0nrrrr3s4       zBaseConfigurator.cfg_convertcCst|ts$t|tr$t|}||_nt|tsHt|trHt|}||_nzt|tslt|trlt|}||_nVt|tr|j |}|r| }|d}|j |d}|r|d}t||}||}|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*rr+r1 string_typesCONVERT_PATTERNr- groupdictvalue_convertersrIr)rUrMrrrHZ converterrrrrr)2s,    zBaseConfigurator.convertcsnd}t|s||}dd}tfddD}|f|}|rj|D]\}}t|||qT|S)z1Configure an object with a user-supplied factory.z()r7Ncs g|]}t|r||fqSr)r%rr4rrrkUsz5BaseConfigurator.configure_custom..)rrr=rrsetattr)rUr4rZpropsrVrr{rMrrMrconfigure_customNs    z!BaseConfigurator.configure_customcCst|trt|}|S)z0Utility function which converts lists to tuples.)rrr1r>rrras_tuple\s zBaseConfigurator.as_tupleN)r4r5r6rXr+r,rJr?rBrCrDrL staticmethod __import__r5rWr=r2r3r)rOrPrrrrr$s"     "r$)r)r)N)N)Z __future__rrZr+rpZsslr6 version_inforZ basestringrIrrtypesrZ file_typeZ __builtin__builtinsZ ConfigParserZ configparserZ _backportrrr r r r Zurllibr rrrrrrrZurllib2rrrrr r!r"r#r$r%ZhttplibZ xmlrpclibZQueueZqueuer&ZhtmlentitydefsZ raw_input itertoolsr'filterr(r1r*r/iostrr0Z urllib.parseZurllib.requestZ urllib.errorZ http.clientZclientZrequestZ xmlrpc.clientZ html.parserZ html.entitiesZentitiesinputr2r3rHrFrOrPr#rYF_OKX_OKZzipfiler|rrr~ZBaseZipExtFilerqrrr NameError collectionsrrrrgetfilesystemencodingrrtokenizercodecsrrr,rrZhtmlr?Zcgirrrreprlibrrimportlib.utilrZimprthreadrrZ dummy_threadZ_abcollrrrrZlogging.configr$r%Ir&r'rrr*r1r+rrrrs,      $,      ,0        2+A              [   b w