a  ze@sddlZddlmZddlZddlZddlmZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZz ddlZWneydZYn0ddlZddlZddlZddlZddlZz ddlZWneyddlZYn0ddlZddlmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0e 1e2Z3e 4dZ5e 4dZ6e 4d Z7e 4d Z8e 4d Z9e 4d Z:e 4d Z;e 4dZddZ?ddZ@ddZAdddZBddZCddZDdd ZEejFd!d"ZGejFd#d$ZHejFdd&d'ZIGd(d)d)eJZKd*d+ZLGd,d-d-eJZMd.d/ZNGd0d1d1eJZOe 4d2e jPZQd3d4ZRdd5d6ZSd7d8ZTd9d:ZUd;d<ZVd=d>ZWd?d@ZXe 4dAe jYZZe 4dBZ[ddCdDZ\e 4dEZ]dFdGZ^dHdIZ_dJdKZ`dLZadMdNZbdOdPZcGdQdRdReJZdGdSdTdTeJZeGdUdVdVeJZfdWZgddYdZZhd[d\Zid]ZjGd^d_d_eJZke 4d`Zle 4daZme 4dbZndcddZdedfZoerddglmpZqmrZrmsZsGdhdidie$jtZtGdjdkdkeqZpGdldmdmepe'ZuejvddnZwewdokrGdpdqdqe$jxZxerGdrdsdse$jyZyGdtdudue%jzZzer>Gdvdwdwe%j{Z{Gdxdydye%j|Z|dzd{Z}Gd|d}d}eJZ~Gd~dde~ZGddde~ZGddde(ZGdddeJZddZGdddeJZddZddZddZddddZddZdS)N)deque)iglob)DistlibException) string_types text_typeshutil raw_inputStringIOcache_from_sourceurlopenurljoinhttplib xmlrpclib splittype HTTPHandlerBaseConfigurator valid_ident Container configparserURLErrorZipFilefsdecodeunquoteurlparsez^([\w\.-]+)\s*z^([\w\.*+-]+)\s*z^(<=?|>=?|={2,3}|[~!]=)\s*z*^((<=?)|(>=?)|={2,3}|[~!]=|in|not\s+in)\s*z^or\b\s*z ^and\b\s*z(\S+)\s*z(([\s\w\.{}()*+#:;,/?!~`@$%^&=|<>\[\]-]+)cs6ddfddfddfdd|S) ae Parse a marker string and return a dictionary containing a marker expression. The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in the expression grammar, or strings. A string contained in quotes is to be interpreted as a literal string, and a string not contained in quotes is a variable (such as os_name). cSs.t|}|r,|d}||d}n|s:tdn|d}|dvrVtd|d|d}|dd}|g}|r|d|krqqt|d|kr|||dd}qtt|}|std|||d||d}qtd|}td|||d|}|dd }||fS) Nrzunexpected end of inputz'"zinvalid expression: %srzerror in string literal: %szunterminated string: %s) IDENTIFIERmatchgroupsend SyntaxErrorreplaceappend STRING_CHUNKjoinlstrip) remainingmresultqoqpartssr-Z/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_vendor/distlib/util.py marker_varAs:               z parse_marker..marker_varcs|rR|ddkrR|dd\}}|ddkr@td||dd}nZ|\}}|rt|}|srq|d}||d}|\}}|||d}q^|}||fS)Nr(r)unterminated parenthesis: %soplhsrhs)r%r MARKER_OPrrr)r&r(r5r'r4r6)markerr/r-r. marker_expres       z!parse_marker..marker_exprcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Nandr3)ANDrrr&r5r'r6)r9r-r. marker_andxs   z parse_marker..marker_andcsR|\}}|rJt|}|s qJ||d}|\}}d||d}q ||fS)Norr3)ORrrr<)r=r-r.r8s   zparse_marker..markerr-) marker_stringr-)r8r=r9r/r. parse_marker8s $ rAcCs0|}|r|drdSt|}|s4td||d}||d}d}}}}|r:|ddkr:|dd}|dkrtd||d|} ||dd}g}| r0t| }|std | | |d| |d} | sq0| dd krtd | | dd} q|s:d}|r|dd kr|dd}t |}|sztd ||d}t |} | j r| j std|||d}ndd} |ddkr| |\}}n|dd}|dkrtd||d|} ||dd}t| r@| | \}} nXt| }|s\td| |d} | |d} | rtd| d| fg}|r|ddkrtd||dd}t|\}}|r|ddkrtd||s|}nd|ddd|Df}t||||||dS)z Parse a requirement passed in as a string. Return a Container whose attributes contain the various parts of the requirement. #Nzname expected: %sr[]rzunterminated extra: %szmalformed extra: %s,zcomma expected in extras: %s@zinvalid URI: %szInvalid URL: %scSst|}d}|rg}|d}||d}t|}|sLtd||d}|||f||d}|r|ddkrq|dd}t|}|std|q|sd}||fS)z| Return a list of operator, version tuples if any are specified, else None. Nrzinvalid version: %srErinvalid constraint: %s) COMPARE_OPrrrVERSION_IDENTIFIERr r"r%) ver_remainingr'versionsr4vr-r-r. get_versionss*      z'parse_requirement..get_versionsr0r1r2rGz~=;zinvalid requirement: %szunexpected trailing data: %s%s %s, cSsg|] }d|qS)rOr-).0conr-r-r. z%parse_requirement..)nameextras constraintsr8url requirement)strip startswithrrr rrfindr%r" NON_SPACErschemenetlocrHrIrAr$r)reqr&r'distnamerV mark_exprrKuriir,trM_rLrsr-r-r.parse_requirements                          rhcCsdd}i}|D]\}}}tj||}t|D]p}tj||} t| D]T} ||| } |durn|| dqJ||| } |tjjdd} | d| || <qJq0q|S)z%Find destinations for resources filescSsD|tjjd}|tjjd}||s.J|t|ddSN/)r!ospathsepr[lenr%)rootrlr-r-r. get_rel_path sz)get_resources_dests..get_rel_pathNrj)rkrlr$rpopr!rmrstrip)resources_rootrulesrp destinationsbasesuffixdestprefixabs_baseabs_globabs_path resource_filerel_pathrel_destr-r-r.get_resources_dests s    rcCs(ttdrd}ntjttdtjk}|S)N real_prefixT base_prefix)hasattrsysrygetattrr(r-r-r.in_venv$s rcCstj}t|tst|}|SN)r executable isinstancerrrr-r-r.get_executable.s  rcCsN|}t|}|}|s|r|}|r|d}||vr6qJ|rd|||f}q|S)Nrz %c: %s %s)r lower)prompt allowed_chars error_promptdefaultpr,cr-r-r.proceed@s rcCs8t|tr|}i}|D]}||vr||||<q|Sr)rrsplit)dkeysr(keyr-r-r.extract_by_keyPs rcCsvtjddkrtd|}|}t|}zlt|}|ddd}|D]B\}}|D]0\}}d||f}t |} | dusJ| ||<q`qP|WSt y| ddYn0dd } t } z| | |Wn:t jy|t|}t|}| | |Yn0i}| D]R} i|| <}| | D]4\} }d| |f}t |} | dusbJ| || <q8q|S) Nrutf-8 extensionszpython.exportsexportsz%s = %scSs$t|dr||n ||dS)N read_file)rrreadfp)cpstreamr-r-r. read_streamms  z!read_exports..read_stream)r version_infocodecs getreaderreadr jsonloaditemsget_export_entry Exceptionseekr ConfigParserMissingSectionHeaderErrorclosetextwrapdedentsections)rdatajdatar(groupentrieskrLr,entryrrrrUvaluer-r-r. read_exportsYsD         rcCstjddkrtd|}t}|D]l\}}|||D]P}|j dur\|j }nd|j |j f}|j rd|d |j f}| ||j|qFq,||dS)Nrrrz%s:%sz%s [%s]rP)rrr getwriterrrr add_sectionvaluesrwryflagsr$setrUwrite)rrrrrLrr,r-r-r. write_exportss   rc cs.t}z|VWt|n t|0dSr)tempfilemkdtemprrmtree)tdr-r-r.tempdirsrc cs8t}zt|dVWt|n t|0dSr)rkgetcwdchdir)rcwdr-r-r.rs  rc cs8t}zt|dVWt|n t|0dSr)socketgetdefaulttimeoutsetdefaulttimeout)secondsctor-r-r.socket_timeouts  rc@seZdZddZdddZdS)cached_propertycCs ||_dSr)func)selfrr-r-r.__init__szcached_property.__init__NcCs,|dur |S||}t||jj||Sr)robject __setattr____name__)robjclsrr-r-r.__get__s  zcached_property.__get__)N)r __module__ __qualname__rrr-r-r-r.rsrcCs~tjdkr|S|s|S|ddkr.td||ddkrFtd||d}tj|vrh|tjqP|srtjStjj|S)aReturn 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. rjrzpath '%s' cannot be absolutezpath '%s' cannot end with '/')rkrm ValueErrorrcurdirremoverlr$)pathnamepathsr-r-r. convert_paths       rc@seZdZd$ddZddZddZdd Zd%d d Zd&ddZddZ ddZ ddZ ddZ ddZ d'ddZddZddZd d!Zd"d#Zd S)( FileOperatorFcCs||_t|_|dSr)dry_runrensured _init_record)rrr-r-r.rszFileOperator.__init__cCsd|_t|_t|_dSNF)recordr files_written dirs_createdrr-r-r.rszFileOperator._init_recordcCs|jr|j|dSr)rradd)rrlr-r-r.record_as_writtenszFileOperator.record_as_writtencCsHtj|s tdtj|tj|s0dSt|jt|jkS)aTell if the target is newer than the source. Returns true if 'source' exists and is more recently modified than 'target', or if 'source' exists and 'target' doesn't. Returns false if both exist and 'target' is the same age or younger than 'source'. Raise PackagingFileError if 'source' does not exist. Note that this test is not very accurate: files created in the same second will have the same "age". zfile '%r' does not existT)rkrlexistsrabspathstatst_mtime)rsourcetargetr-r-r.newers   zFileOperator.newerTcCs|tj|td|||jsd}|rdtj|rDd|}n tj|rdtj |sdd|}|rtt |dt ||| |dS)z8Copy a file respecting dry-run and force flags. zCopying %s to %sNz%s is a symlinkz%s is a non-regular filez which would be overwritten) ensure_dirrkrldirnameloggerinforislinkrisfilerrcopyfiler)rinfileoutfilecheckmsgr-r-r. copy_files    zFileOperator.copy_fileNcCstj|rJ|tj|td|||js~|durJt|d}nt j|d|d}zt ||W| n | 0| |dS)NzCopying stream %s to %swbwencoding)rkrlisdirrrrrropenrr copyfileobjrr)rinstreamrr outstreamr-r-r. copy_streams zFileOperator.copy_streamcCsp|tj||jsbtj|r.t|t|d}||Wdn1sX0Y| |dS)Nr) rrkrlrrrrrrr)rrlrfr-r-r.write_binary_file#s   (zFileOperator.write_binary_filecCs||||dSr)r encode)rrlrrr-r-r.write_text_file,szFileOperator.write_text_filecCsntjdkstjdkrjtjdkrj|D]F}|jr:td|q"t|j|B|@}td||t||q"dS)Nposixjavazchanging mode of %szchanging mode of %s to %o) rkrU_namerrrrst_modechmod)rbitsmaskfilesr moder-r-r.set_mode/szFileOperator.set_modecCs|dd|S)Nimi)r)r,r r-r-r.;rTzFileOperator.cCs|tj|}||jvrxtj|sx|j|tj|\}}||t d||j sft ||j rx|j |dS)Nz Creating %s)rkrlrrrrrrrrrmkdirrr)rrlrr r-r-r.r=s    zFileOperator.ensure_dirc Cst|| }td|||js|s0|||rX|s:d}n||sHJ|t|d}i}|rvttdrvtj j |d<tj |||dfi|| ||S)NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT) r rrrrr[rnr py_compiler CHECKED_HASHcompiler) rrloptimizeforceryhashed_invalidationdpathdiagpathcompile_kwargsr-r-r. byte_compileIs   zFileOperator.byte_compilecCstj|rtj|r^tj|s^td||js@t ||j r||j vr|j |nPtj|rpd}nd}td|||jst ||j r||j vr|j |dS)NzRemoving directory tree at %slinkfilezRemoving %s %s)rkrlrrrrdebugrrrrrrr)rrlr,r-r-r.ensure_removedZs"       zFileOperator.ensure_removedcCsDd}|s@tj|r$t|tj}q@tj|}||kr:q@|}q|Sr)rkrlraccessW_OKr)rrlr(parentr-r-r. is_writableos  zFileOperator.is_writablecCs"|js J|j|jf}||S)zV Commit recorded changes, turn off recording, return changes. )rrrr)rr(r-r-r.commit{s  zFileOperator.commitcCs|jst|jD]}tj|rt|qt|jdd}|D]F}t |}|rz|dgks^Jtj ||d}t |t |q>| dS)NT)reverse __pycache__r) rlistrrkrlrrsortedrlistdirr$rmdirr)rr dirsrflistsdr-r-r.rollbacks     zFileOperator.rollback)F)T)N)FFNF)rrrrrrrrr r rrset_executable_moderr&r*r.r/r9r-r-r-r.rs         rcCs^|tjvrtj|}nt|}|dur,|}n.|d}t||d}|D]}t||}qJ|S)N.r)rmodules __import__rrrq) module_name dotted_pathmodr(r+rr-r-r.resolves    rAc@s6eZdZddZeddZddZddZej Z d S) ExportEntrycCs||_||_||_||_dSrrUryrwr)rrUryrwrr-r-r.rszExportEntry.__init__cCst|j|jSr)rAryrwrr-r-r.rszExportEntry.valuecCsd|j|j|j|jfS)NzrCrr-r-r.__repr__s zExportEntry.__repr__cCsDt|tsd}n0|j|jko>|j|jko>|j|jko>|j|jk}|Sr)rrBrUryrwr)rotherr(r-r-r.__eq__s     zExportEntry.__eq__N) rrrrrrrDrFr__hash__r-r-r-r.rBs   rBz(?P(\w|[-.+])+) \s*=\s*(?P(\w+)([:\.]\w+)*) \s*(\[\s*(?P[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])? c Cst|}|s0d}d|vs"d|vrtd|n|}|d}|d}|d}|dkrf|d}}n"|dkrztd||d\}}|d } | durd|vsd|vrtd|g} nd d | d D} t|||| }|S) NrCrDzInvalid specification '%s'rUcallable:rrrcSsg|] }|qSr-rZ)rQr r-r-r.rSrTz$get_export_entry..rE)ENTRY_REsearchr groupdictcountrrB) specificationr'r(rrUrlcolonsryrwrr-r-r.rs8   rcCs|dur d}tjdkr.dtjvr.tjd}n tjd}tj|rft|tj}|st d|n:zt |d}Wn&t yt j d |dd d }Yn0|st }t d |tj||S) a Return the default base location for distlib caches. If the directory does not exist, it is created. Use the suffix provided for the base directory, and default to '.distlib' if it isn't provided. On Windows, if LOCALAPPDATA is defined in the environment, then it is assumed to be a directory, and will be the parent directory of the result. On POSIX, and on Windows if LOCALAPPDATA is not defined, the user's home directory - using os.expanduser('~') - will be the parent directory of the result. The result is just the directory '.distlib' in the parent directory as determined above, or with the name specified with ``suffix``. Nz.distlibnt LOCALAPPDATAz $localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)rkrUenvironrl expandvars expanduserrr+r,rwarningmakedirsOSErrorrrr$)rwr(usabler-r-r.get_cache_bases&      r\cCsBtjtj|\}}|r(|dd}|tjd}||dS)a Convert an absolute path to a directory name for use in a cache. The algorithm used is: #. On Windows, any ``':'`` in the drive is replaced with ``'---'``. #. Any occurrence of ``os.sep`` is replaced with ``'--'``. #. ``'.cache'`` is appended. rIz---z--z.cache)rkrl splitdriverr!rm)rlrrr-r-r.path_to_cache_dirs  r^cCs|ds|dS|Sri)endswith)r,r-r-r. ensure_slash s r`cCs`d}}d|vr>|dd\}}d|vr.|}n|dd\}}|rJt|}|rVt|}|||fS)NrFrrI)rsplitrr)r_usernamepasswordryr-r-r.parse_credentials&srdcCstd}t||S)N)rkumaskrr-r-r.get_process_umask5s  rgcCs<d}d}t|D]\}}t|tsd}q,q|dus8J|S)NTF) enumeraterr)seqr(rdr,r-r-r.is_string_sequence:s  rjz3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z -py(\d\.?\d?)cCsd}d}t|dd}t|}|r@|d}|d|}|rt|t|dkrtt |d|}|r| }|d|||dd|f}|durt |}|r|d|d|f}|S)zw Extract name, version, python version from a filename (no extension) Return name, version, pyver or None N -rz\br) rr!PYTHON_VERSIONrLrstartrnrerescaperPROJECT_NAME_AND_VERSION)filename project_namer(pyverr'nr-r-r.split_filenameIs"   rvz-(?P[\w .-]+)\s*\(\s*(?P[^\s)]+)\)$cCs:t|}|std||}|d|dfS)z A utility method used to get name and version from a string. From e.g. a Provides-Dist value. :param p: A value in a form 'foo (1.0)' :return: The name and version as a tuple. z$Ill-formed name/version string: '%s'rUver)NAME_VERSION_RErrrMrZr)rr'rr-r-r.parse_name_and_versiones  rycCst}t|pg}t|pg}d|vr8|d||O}|D]x}|dkrT||q<|dr|dd}||vrtd|||vr||q<||vrtd|||q<|S)N*rlrzundeclared extra: %s)rrrr[rrX) requested availabler(runwantedr-r-r. get_extrasts&        rc Csi}zNt|}|}|d}|ds8td|ntd|}t |}Wn2t y}zt d||WYd}~n d}~00|S)Nz Content-Typezapplication/jsonz(Unexpected response for JSON request: %srz&Failed to get external data for %s: %s) r rgetr[rr)rrrrr exception)rXr(respheadersctreaderer-r-r._get_external_datas  $rz'https://www.red-dove.com/pypi/projects/cCs*d|d|f}tt|}t|}|S)Nz%s/%s/project.jsonrupperr _external_data_base_urlr)rUrXr(r-r-r.get_project_datas rcCs(d|d||f}tt|}t|S)Nz%s/%s/package-%s.jsonrr)rUversionrXr-r-r.get_package_datas rc@s(eZdZdZddZddZddZdS) Cachez A class implementing a cache for resources that need to live in the file system e.g. shared libraries. This class was moved from resources to here because it could be used by other modules, e.g. the wheel module. cCsPtj|st|t|jd@dkr6td|tjtj ||_ dS)zu Initialise an instance. :param base: The base directory where the cache should be located. ?rzDirectory '%s' is not privateN) rkrlrrYrrrrXrnormpathrv)rrvr-r-r.rs    zCache.__init__cCst|S)zN Converts a resource prefix to a directory name in the cache. )r^)rryr-r-r. prefix_to_dirszCache.prefix_to_dirc Csg}t|jD]p}tj|j|}z>tj|s>tj|rJt|ntj|r`t |Wqt y~| |Yq0q|S)z" Clear the cache. ) rkr4rvrlr$rrrrrrrr")r not_removedfnr-r-r.clears   z Cache.clearN)rrr__doc__rrrr-r-r-r.rsrc@s:eZdZdZddZdddZddZd d Zd d Zd S) EventMixinz1 A very simple publish/subscribe system. cCs i|_dSr) _subscribersrr-r-r.rszEventMixin.__init__TcCsD|j}||vrt|g||<n"||}|r6||n ||dS)a` Add a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be added (and called when the event is published). :param append: Whether to append or prepend the subscriber to an existing subscriber list for the event. N)rrr" appendleft)revent subscriberr"subssqr-r-r.rs  zEventMixin.addcCs,|j}||vrtd||||dS)z Remove a subscriber for an event. :param event: The name of an event. :param subscriber: The subscriber to be removed. zNo subscribers: %rN)rrr)rrrrr-r-r.rs zEventMixin.removecCst|j|dS)z Return an iterator for the subscribers for an event. :param event: The event to return subscribers for. r-)iterrr)rrr-r-r.get_subscribersszEventMixin.get_subscribersc Ospg}||D]J}z||g|Ri|}Wn tyLtdd}Yn0||qtd|||||S)a^ Publish a event and return a list of values returned by its subscribers. :param event: The event to publish. :param args: The positional arguments to pass to the event's subscribers. :param kwargs: The keyword arguments to pass to the event's subscribers. z"Exception during event publicationNz/publish %s: args = %s, kwargs = %s, result = %s)rrrrr"r))rrargskwargsr(rrr-r-r.publish s     zEventMixin.publishN)T) rrrrrrrrrr-r-r-r.rs   rc@s^eZdZddZddZdddZdd Zd d Zd d ZddZ e ddZ e ddZ dS) SequencercCsi|_i|_t|_dSr)_preds_succsr_nodesrr-r-r.r$szSequencer.__init__cCs|j|dSr)rrrnoder-r-r.add_node)szSequencer.add_nodeFcCs||jvr|j||rt|j|dD]}|||q,t|j|dD]}|||qPt|jD]\}}|sp|j|=qpt|jD]\}}|s|j|=qdS)Nr-)rrrrrrr2r)rredgesrr,rrLr-r-r. remove_node,s   zSequencer.remove_nodecCs<||ks J|j|t||j|t|dSr)r setdefaultrrr)rpredsuccr-r-r.r<s z Sequencer.addcCs||ks Jz|j|}|j|}WntyBtd|Yn0z||||Wn"ty~td||fYn0dS)Nz%r not a successor of anythingz%r not a successor of %r)rrKeyErrorrr)rrrpredssuccsr-r-r.rAs     zSequencer.removecCs||jvp||jvp||jvSr)rrr)rstepr-r-r.is_stepNszSequencer.is_stepcCs||std|g}g}t}|||r|d}||vrb||kr||||q.|||||j|d}| |q.t |S)Nz Unknown: %rrr-) rrrr"rqrrrrextendreversed)rfinalr(todoseenrrr-r-r. get_stepsRs"         zSequencer.get_stepscsRdggiig|jfddD]}|vr8|q8S)Nrcsd|<d|<dd7<|z |}WntyTg}Yn0|D]J}|vr|t|||<qZ|vrZt|||<qZ||krg}}||||krqqt|}|dS)Nrr)r"rminrqtuple)r successors successorconnected_component componentgraphindex index_counterlowlinksr(stack strongconnectr-r.rvs*        z3Sequencer.strong_connections..strongconnect)rrr-rr.strong_connectionsks" zSequencer.strong_connectionscCsfdg}|jD]*}|j|}|D]}|d||fqq |jD]}|d|q>|dd|S)Nz digraph G {z %s -> %s;z %s;} )rr"rr$)rr(rrrrr-r-r.dots    z Sequencer.dotN)F) rrrrrrrrrrpropertyrrr-r-r-r.r#s   2r).tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc sZfdd}tjtd}|dur|dr>d}nH|drRd}d}n4|drfd }d }n |d rzd }d }n td|z|dkrt|d }|r|}|D] }||qn*t ||}|r| }|D] }||q|dkr*t j ddkr*| D]"} t| jts| jd| _q|W|rV|n|rT|0dS)NcsRt|ts|d}tjtj|}|rB|tjkrNt d|dS)Nrzpath outside destination: %r) rrdecoderkrlrr$r[rmr)rlrdest_dirplenr-r. check_paths   zunarchive..check_path)rrzip)rrtgzzr:gz)rrtbzzr:bz2rtarr}zUnknown format for %rrrr)rkrlrrnr_rrnamelisttarfilergetnamesrr getmembersrrUrr extractallr) archive_filenamerformatrrarchivernamesrUtarinfor-rr. unarchivesL             rc Cst}t|}t|dd}t|D]H\}}}|D]8}tj||}||d} tj| |} ||| q4q&Wdn1s0Y|S)z*zip a directory tree into a BytesIO objectrN) ioBytesIOrnrrkwalkrlr$r) directoryr(dlenzfror6rrUfullrelrxr-r-r.zip_dirs  .r)rKMGTPc@sreZdZdZdddZddZdd Zd d Zd d Ze ddZ e ddZ ddZ e ddZ e ddZdS)ProgressUNKNOWNrdcCs<|dus||ksJ||_|_||_d|_d|_d|_dS)NrF)rcurmaxstartedelapseddone)rminvalmaxvalr-r-r.rs  zProgress.__init__cCsV|j|ksJ|jdus&||jks&J||_t}|jdurF||_n ||j|_dSr)rrrtimerr)rcurvalnowr-r-r.updates zProgress.updatecCs |dks J||j|dSNr)rr)rincrr-r-r. increments zProgress.incrementcCs||j|Sr)rrrr-r-r.rns zProgress.startcCs |jdur||jd|_dS)NT)rrrrr-r-r.stops  z Progress.stopcCs|jdur|jS|jSr)runknownrr-r-r.maximumszProgress.maximumcCsD|jr d}n4|jdurd}n$d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr(rLr-r-r. percentage!s zProgress.percentagecCs:|dkr|jdus|j|jkr$d}ntdt|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rdurationr(r-r-r.format_duration,szProgress.format_durationcCs|jrd}|j}n^d}|jdur&d}nJ|jdks<|j|jkrBd}n.t|j|j}||j|j}|d|j}d|||fS)NDonezETA rrrz%s: %s)rrrrrfloatr )rryrer-r-r.ETA5s z Progress.ETAcCsL|jdkrd}n|j|j|j}tD]}|dkr6q@|d}q&d||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr(unitr-r-r.speedHs  zProgress.speedN)rr)rrrrrrrrnrrrrr rrr-r-r-r.rs      rz \{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCs<t|rd}t||t|r4d}t||t|S)zAExtended globbing function that supports ** and {opt1,opt2,opt3}.z7invalid glob %r: recursive glob "**" must be used alonez2invalid glob %r: mismatching set marker '{' or '}')_CHECK_RECURSIVE_GLOBrLr_CHECK_MISMATCH_SET_iglob) path_globrr-r-r.r]s    rc cst|d}t|dkrht|dks,J||\}}}|dD]$}td|||fD] }|VqXq@nd|vrt|D] }|Vqxn~|dd\}}|dkrd}|dkrd}n|d}|d }t|D]4\}}} tj |}ttj ||D] } | VqqdS) NrrrErz**r;rzrj\) RICH_GLOBrrnrr$ std_iglobr%rkrrlr) rrich_path_globryrrwitemrlradicaldirrrr-r-r.rhs*         r) HTTPSHandlermatch_hostnameCertificateErrorc@seZdZdZdZddZdS)HTTPSConnectionNTcCs^t|j|jf|j}t|ddr0||_|tt dsp|j rHt j }nt j }t j ||j|j|t j|j d|_nt t j}tt dr|jt jO_|jr||j|ji}|j rt j |_|j|j dtt ddr|j|d<|j |fi||_|j rZ|jrZz$t|j|jtd |jWn.tyX|jtj|jYn0dS) N _tunnel_hostF SSLContext) cert_reqs ssl_versionca_certs OP_NO_SSLv2)cafileHAS_SNIserver_hostnamezHost verified: %s) rcreate_connectionhostporttimeoutrsock_tunnelrsslr& CERT_REQUIRED CERT_NONE wrap_socketkey_file cert_filePROTOCOL_SSLv23r#optionsr'load_cert_chain verify_modeload_verify_locations check_domainr getpeercertrr)r shutdown SHUT_RDWRr)rr/r$contextrr-r-r.connectsB        zHTTPSConnection.connect)rrrr&r<rAr-r-r-r.r!sr!c@s&eZdZd ddZddZddZdS) rTcCst|||_||_dSr)BaseHTTPSHandlerrr&r<)rr&r<r-r-r.rs zHTTPSHandler.__init__cOs(t|i|}|jr$|j|_|j|_|S)a This is called to create a connection instance. Normally you'd pass a connection class to do_open, but it doesn't actually check for a class, and just expects a callable. As long as we behave just as a constructor would have, we should be OK. If it ever changes so that we *must* pass a class, we'll create an UnsafeHTTPSConnection class which just sets check_domain to False in the class definition, and choose which one to pass to do_open. )r!r&r<)rrrr(r-r-r. _conn_makers zHTTPSHandler._conn_makerc CsZz||j|WStyT}z,dt|jvr>td|jnWYd}~n d}~00dS)Nzcertificate verify failedz*Unable to verify server certificate for %s)do_openrCrstrreasonr r,)rr`rr-r-r. https_openszHTTPSHandler.https_openN)T)rrrrrCrGr-r-r-r.rs rc@seZdZddZdS)HTTPSOnlyHandlercCstd|dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rr`r-r-r. http_openszHTTPSOnlyHandler.http_openN)rrrrIr-r-r-r.rHsrHrJc@seZdZdddZdS)HTTPrNcKs*|dkr d}||j||fi|dSr_setupZ_connection_classrr,r-rr-r-r.rsz HTTP.__init__)rNrrrrr-r-r-r.rMsrMc@seZdZdddZdS)HTTPSrNcKs*|dkr d}||j||fi|dSrrNrPr-r-r.rszHTTPS.__init__)rNrQr-r-r-r.rRsrRc@seZdZdddZddZdS) TransportrcCs||_tj||dSr)r.rrSrrr. use_datetimer-r-r.rszTransport.__init__cCs`||\}}}tdkr(t||jd}n4|jr<||jdkrR||_|t|f|_|jd}|S)NrK)r.rr) get_host_info _ver_inforMr. _connection_extra_headersrHTTPConnection)rr,hehx509r(r-r-r.make_connections zTransport.make_connectionN)rrrrrr^r-r-r-r.rSs rSc@seZdZdddZddZdS) SafeTransportrcCs||_tj||dSr)r.rr`rrTr-r-r.r szSafeTransport.__init__cCs||\}}}|si}|j|d<tdkr>t|dfi|}n>|jrR||jdkrr||_|tj|dfi|f|_|jd}|S)Nr.rKrr)rVr.rWrRrXrYrr!)rr,r[r\rr(r-r-r.r^s   zSafeTransport.make_connectionN)rr_r-r-r-r.r` s r`c@seZdZddZdS) ServerProxycKsx|dd|_}|dur^t|d}|dd}|dkr@t}nt}|||d|d<}||_tjj ||fi|dS)Nr.rrUhttps)rU transport) rqr.rrr`rSrcrrar)rrcrr.r^rUtclsrer-r-r.r"s  zServerProxy.__init__NrQr-r-r-r.ra!sracKs:tjddkr|d7}nd|d<d|d<t||fi|S)Nrrbrnewlinerr)rrr)rrrr-r-r. _csv_open7s  rgc@s4eZdZedededdZddZddZd S) CSVBaserE"r) delimiter quotecharlineterminatorcCs|Srr-rr-r-r. __enter__IszCSVBase.__enter__cGs|jdSr)rr)rrTr-r-r.__exit__LszCSVBase.__exit__N)rrrrEdefaultsrmrnr-r-r-r.rhBs rhc@s(eZdZddZddZddZeZdS) CSVReadercKs`d|vr4|d}tjddkr,td|}||_nt|dd|_tj|jfi|j|_dS)Nrrrrrlr}) rrrrrrgcsvrro)rrrr-r-r.rQszCSVReader.__init__cCs|Srr-rr-r-r.__iter__\szCSVReader.__iter__cCsFt|j}tjddkrBt|D] \}}t|ts |d||<q |SNrrr)nextrrrrhrrr)rr(rdrr-r-r.rt_s   zCSVReader.nextN)rrrrrrrt__next__r-r-r-r.rpPs rpc@seZdZddZddZdS) CSVWritercKs(t|d|_tj|jfi|j|_dS)Nr)rgrrqwriterro)rrrr-r-r.rjs zCSVWriter.__init__cCsNtjddkr>g}|D]"}t|tr.|d}||q|}|j|dSrs)rrrrr r"rwwriterow)rrowr}rr-r-r.rxns   zCSVWriter.writerowN)rrrrrxr-r-r-r.rvisrvcsHeZdZeejZded<d fdd ZddZdd Zd d Z Z S) Configurator inc_convertincNcs"tt|||pt|_dSr)superrzrrkrrv)rconfigrv __class__r-r.rszConfigurator.__init__c sfddd}t|s*|}dd}dd}|r\tfdd|D}fd dD}t|}||i|}|r|D]\}} t||| q|S) Ncsvt|ttfr*t|fdd|D}nHt|trhd|vrH|}qri}|D]}||||<qPn |}|S)Ncsg|] }|qSr-r-)rQrdconvertr-r.rSrTzBConfigurator.configure_custom..convert..())rr2rtypedictconfigure_customr)or(r)rrr-r.rs   z.Configurator.configure_custom..convertrr;z[]r-csg|] }|qSr-r-)rQrrr-r.rSrTz1Configurator.configure_custom..cs$g|]}t|r||fqSr-)r)rQr)r~rr-r.rSrT)rqrHrArrrsetattr) rr~rpropsrrrr(rurLr-)r~rrr.rs    zConfigurator.configure_customcCs4|j|}t|tr0d|vr0|||j|<}|S)Nr)r~rrr)rrr(r-r-r. __getitem__s zConfigurator.__getitem__cCsZtj|stj|j|}tj|ddd}t|}Wdn1sL0Y|S)z*Default converter for the inc:// protocol.r}rrN) rkrlisabsr$rvrrrr)rrr r(r-r-r.r{s  (zConfigurator.inc_convert)N) rrrrrvalue_convertersrrrr{ __classcell__r-r-rr.rz|s  rzc@s*eZdZdZd ddZddZdd ZdS) SubprocessMixinzC Mixin for running subprocesses and capturing their output FNcCs||_||_dSr)verboseprogress)rrrr-r-r.rszSubprocessMixin.__init__cCsj|j}|j}|}|sq^|dur.|||q |s@tjdntj|dtjq |dS)z Read lines from a subprocess' output stream and either pass to a progress callable (if specified) or write progress information to sys.stderr. Nr;r) rrreadlinerstderrrrflushr)rrr@rrr,r-r-r.rs  zSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|tj|j|jdfd}|| | | |j dur| ddn|j rt jd|S)N)stdoutrr)rrrzdone.mainzdone. ) subprocessPopenPIPE threadingThreadrrrnrwaitr$rrrr)rcmdrrt1t2r-r-r. run_commands"   zSubprocessMixin.run_command)FN)rrrrrrrr-r-r-r.rs rcCstdd|S)z,Normalize a python package name a la PEP 503z[-_.]+rl)rosubr)rUr-r-r.normalize_namesrc@s.eZdZdZdZd ddZddZdd ZdS) PyPIRCFilezhttps://upload.pypi.org/legacy/pypiNcCs.|durtjtjdd}||_||_dS)NrSz.pypirc)rkrlr$rWrrrX)rrrXr-r-r.rszPyPIRCFile.__init__c Csi}tj|jr||jp|j}t}||j| }d|vr*| dd}dd| dD}|gkr~d|vr|dg}n|D]}d|i}| |d|d<d |jfd |j fd fD].\}} | ||r| ||||<q| ||<q|dkr ||jdfvr |j|d <q|d|kr|d |kri}qnRd |vr|d }| |d rT| |d }n|j}| |d| |d |||j d}|S)N distutilsz index-serverscSs g|]}|dkr|qS)rrJ)rQserverr-r-r.rSs z#PyPIRCFile.read..rrrrb repositoryrealm)rcNz server-loginrc)rbrcrrr)rkrlrrrrXDEFAULT_REPOSITORYrRawConfigParserrrrr DEFAULT_REALM has_option) rr(rr~r index_servers_serversrrrr-r-r.rsX               zPyPIRCFile.readcCst}|j}|||ds,|d|dd||dd|t|d}||Wdn1sr0YdS)Nrrbrcr) rrrrr has_sectionrrrr)rrbrcr~rr r-r-r.r5s    zPyPIRCFile.update)NN)rrrrrrrrr-r-r-r.rs  :rcCst|jdS)zG Read the PyPI access configuration as supported by distutils. )rX)rrXrrr-r-r. _load_pypircAsrcCst|j|jdSr)rrrbrcrr-r-r. _store_pypircGsrc CstjdkrFdtjvrdSdtjvr.dSdtjvr@dStjSdtjvrZtjdStjd ksnttd sttjSt\}}}}}| d d }| d d d d}|dddkrd||fS|dddkr(|ddkrd}dt |dd|ddf}ddd}|d|tj 7}n|dddkrLdd l m }|S|dd!d"krd"}td#tj}||}|r|}n>|dd!d$krddl} ddl} | | j|||\}}}d%|||fS)&aReturn a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. on Linux, the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. rQamd64 win-amd64z(arm) win-arm32z(arm64)z win-arm64_PYTHON_HOST_PLATFORMrunamerjrrkrfrlNlinuxz%s-%ssunosr5solarisz%d.%srrJ32bit64bit)ilz.%saix) aix_platformrLcygwinz[\d.]+darwinz%s-%s-%s)rkrUrrrplatformrUrrr!intmaxsize _aix_supportrrorASCIIrr _osx_supportdistutils.sysconfigget_platform_osx sysconfigget_config_vars) osnamer,releasermachinebitnessrrel_rer'rrr-r-r.get_host_platformOsN          rwin32rr)x86x64armcCs2tjdkrtStjd}|tvr*tSt|S)NrQVSCMD_ARG_TGT_ARCH)rkrUrrUr_TARGET_TO_PLAT)cross_compilation_targetr-r-r. get_platforms   r)NN)r)N)N)NT)r collectionsr contextlibrqglobrrrrloggingrkrrorr1 ImportErrorrrrrrrZdummy_threadingrrrcompatrrrr r r r r rrrrrrrrrrrrr getLoggerrrrrrIrHr7r?r;r]r#rArhrrrrrrrcontextmanagerrrrrrrrrArBVERBOSErKrr\r^r`rdrgrjIrqrmrvrxryrrrrrrrrARCHIVE_EXTENSIONSrrrrrrrrrrBrr r!rHrrWrMrRrSr`rargrhrprvrzrrrrrrrrr-r-r-r.s        \         Yy   /   8 )    ,H  6]    +)   7.QR