Viewing File: /usr/lib/python3.6/site-packages/pip/_vendor/distlib/__pycache__/util.cpython-36.pyc

3

aj@s>ddlZddlmZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZyddlZWnek
rdZYnXddlZddlZddlZddlZddlZyddlZWnek
rddlZYnXddlZddlmZddlmZmZmZmZm 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/e
j0e1Z2dZ3e
j4e3Z5dZ6d	e6d
Z7e6dZ8dZ9d
e9de8de3d
e9de8dZ:dZ;de:de;de:dZ<e7d
e3e7dZ=de=dZ>de6de>de<dZ?e
j4e?Z@de9de8d
ZAe
j4eAZBdd ZCd!d"ZDd#d$ZEd%d&ZFdd'd(ZGd)d*ZHd+d,ZId-d.ZJejKd/d0ZLejKd1d2ZMejKdd4d5ZNGd6d7d7eOZPd8d9ZQGd:d;d;eOZRd<d=ZSGd>d?d?eOZTe
j4d@e
jUZVdAdBZWddCdDZXdEdFZYdGdHZZdIdJZ[dKdLZ\dMdNZ]e
j4dOe
j^Z_e
j4dPZ`ddQdRZae
j4dSZbdTdUZcdVdWZddXdYZedZZfd[d\Zgd]d^ZhGd_d`d`eOZiGdadbdbeOZjGdcddddeOZkdZlddmdnZmdodpZndZoGdwdxdxeOZpe
j4dyZqe
j4dzZre
j4d{Zsd|d}Zd~dZter\ddlmuZvmwZwmxZxGddde$jyZyGdddevZuGdddeue'Zzej{ddZ|e|dkrGddde$j}Z}erGddde$j~Z~Gddde%jZerGddde%jZGddde%jZddZGdddeOZGdddeZGdddeZGddde(ZGdddeOZddZdS)N)deque)iglob)DistlibException)string_types	text_typeshutil	raw_inputStringIOcache_from_sourceurlopenurljoinhttplib	xmlrpclib	splittypeHTTPHandlerBaseConfiguratorvalid_ident	ContainerconfigparserURLErrorZipFilefsdecodeunquotez\s*,\s*z
(\w|[.-])+z(\*|:(\*|\w+):|)z\*?z([<>=!~]=)|[<>](z)?\s*(z)(z)\s*(z))*z(from\s+(?P<diref>.*))z\(\s*(?P<c1>|z)\s*\)|(?P<c2>z\s*)z)*z\[\s*(?P<ex>z)?\s*\]z(?P<dn>z	\s*)?(\s*z)?$z(?P<op>z)\s*(?P<vn>csddd}tj|}|r|j}|d}|dp8|d}|dsHd}nd}|dj}|snd}d}|d}nL|dd	krd
|}tj|}	fdd|	D}d
|djdd|Df}|dsd}
ntj|d}
t	|||
|||d}|S)NcSs|j}|d|dfS)NopZvn)	groupdict)mdr!/usr/lib/python3.6/util.pyget_constraintYsz)parse_requirement.<locals>.get_constraintZdnZc1Zc2Zdirefrz<>!=z~=csg|]}|qSr!r!).0r)r#r!r"
<listcomp>qsz%parse_requirement.<locals>.<listcomp>z%s (%s)z, cSsg|]}d|qS)z%s %sr!)r%Zconr!r!r"r&rsZex)nameZconstraintsextrasZrequirementsourceurl)
REQUIREMENT_REmatchrstripRELOP_IDENT_REfinditerjoinCOMMA_REsplitr)sresultrr r'Zconsr*ZconstrZrsiteratorr(r!)r#r"parse_requirementWs4


r6cCsdd}i}x|D]\}}}tjj||}xt|D]t}tjj||}	x`t|	D]T}
|||
}|dkrt|j|dqP|||
}|jtjjdjd}
|
d|||<qPWq4WqW|S)z%Find destinations for resources filescSsD|jtjjd}|jtjjd}|j|s.t|t|djdS)N/)replaceospathsep
startswithAssertionErrorlenlstrip)baser:r!r!r"get_rel_pathsz)get_resources_dests.<locals>.get_rel_pathNr7)r9r:r0rpopr8r;rstrip)Zresources_rootZrulesrAZdestinationsr@suffixdestprefixZabs_baseZabs_globZabs_pathZ
resource_fileZrel_pathZrel_destr!r!r"get_resources_dests|s

rGcCs(ttdrd}ntjttdtjk}|S)NZreal_prefixTbase_prefix)hasattrsysrFgetattr)r4r!r!r"in_venvs
rLcCs$tjjtj}t|ts t|}|S)N)r9r:normcaserJ
executable
isinstancerr)r4r!r!r"get_executables

rPcCsT|}xJt|}|}|r |r |}|r|dj}||kr:P|rd|||f}qW|S)Nrz	%c: %s
%s)r	lower)promptZ
allowed_charsZerror_promptdefaultpr3cr!r!r"proceeds
rVcCs<t|tr|j}i}x |D]}||kr||||<qW|S)N)rOrr2)r keysr4keyr!r!r"extract_by_keys

rYcCstjddkrtjd|}|j}t|}yrtj|}|ddd}xR|jD]F\}}x<|jD]0\}}d||f}t	|}	|	dk	st
|	||<qdWqRW|Stk
r|jddYnXdd	}
t
j}y|
||Wn<t
jk
r|jtj|}t|}|
||YnXi}xb|jD]V}i||<}xB|j|D]4\}
}d|
|f}t	|}	|	dk	spt
|	||
<qFWq*W|S)
Nrzutf-8
extensionszpython.exportsexportsz%s = %scSs$t|dr|j|n
|j|dS)N	read_file)rIr]Zreadfp)cpstreamr!r!r"read_streams
z!read_exports.<locals>.read_stream)rJversion_infocodecs	getreaderreadr
jsonloaditemsget_export_entryr=	ExceptionseekrConfigParserZMissingSectionHeaderErrorclosetextwrapdedentZsections)r_dataZjdatar4groupZentrieskvr3entryr`r^rXr'valuer!r!r"read_exportssD

rucCstjddkrtjd|}tj}x||jD]p\}}|j|x\|jD]P}|j	dkr`|j
}nd|j
|j	f}|jrd|dj|jf}|j
||j|qJWq.W|j|dS)NrrZzutf-8z%s:%sz%s [%s]z, )rJrarb	getwriterrrkrgZadd_sectionvaluesrDrFflagsr0setr'write)r\r_r^rqrrrsr3r!r!r"
write_exportss

r{ccs$tj}z
|VWdtj|XdS)N)tempfilemkdtemprrmtree)Ztdr!r!r"tempdirs
rccs.tj}ztj|dVWdtj|XdS)N)r9getcwdchdir)r cwdr!r!r"rs


rccs.tj}ztj|dVWdtj|XdS)N)socketZgetdefaulttimeoutZsetdefaulttimeout)ZsecondsZctor!r!r"socket_timeouts


rc@seZdZddZdddZdS)cached_propertycCs
||_dS)N)func)selfrr!r!r"__init__)szcached_property.__init__NcCs,|dkr|S|j|}tj||jj||S)N)robject__setattr____name__)robjclsrtr!r!r"__get__.s

zcached_property.__get__)N)r
__module____qualname__rrr!r!r!r"r(srcCstjdkr|S|s|S|ddkr.td||ddkrFtd||jd}xtj|krj|jtjqRW|svtjStjj|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.
    r7rzpath '%s' cannot be absoluterzpath '%s' cannot end with '/')r9r;
ValueErrorr2curdirremover:r0)pathnamepathsr!r!r"convert_path6s


rc@seZdZd$ddZddZddZdd	Zd%ddZd&ddZddZ	ddZ
ddZddZddZ
d'ddZddZddZd d!Zd"d#Zd
S)(FileOperatorFcCs||_t|_|jdS)N)dry_runryensured_init_record)rrr!r!r"rRszFileOperator.__init__cCsd|_t|_t|_dS)NF)recordry
files_writtendirs_created)rr!r!r"rWszFileOperator._init_recordcCs|jr|jj|dS)N)rradd)rr:r!r!r"record_as_written\szFileOperator.record_as_writtencCsHtjj|s tdtjj|tjj|s0dStj|jtj|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)r9r:existsrabspathstatst_mtime)rr)targetr!r!r"newer`szFileOperator.newerTcCs|jtjj|tjd|||jsd}|rftjj|rDd|}n"tjj|rftjj	|rfd|}|rvt
|dtj|||j
|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_dirr9r:dirnameloggerinforislinkrisfilerrZcopyfiler)rZinfileoutfilecheckmsgr!r!r"	copy_filets
zFileOperator.copy_fileNc
Cstjj|st|jtjj|tjd|||jsx|dkrLt	|d}nt
j	|d|d}ztj||Wd|j
X|j|dS)NzCopying stream %s to %swbw)encoding)r9r:isdirr=rrrrropenrbrZcopyfileobjrlr)rZinstreamrrZ	outstreamr!r!r"copy_streams
zFileOperator.copy_streamc	CsF|jtjj||js8t|d}|j|WdQRX|j|dS)Nr)rr9r:rrrrzr)rr:rofr!r!r"write_binary_files
zFileOperator.write_binary_filec
CsL|jtjj||js>t|d}|j|j|WdQRX|j|dS)Nr)	rr9r:rrrrzencoder)rr:rorrr!r!r"write_text_files
zFileOperator.write_text_filecCsrtjdkstjdkrntjdkrnxN|D]F}|jr<tjd|q$tj|j|B|@}tjd||tj||q$WdS)Nposixjavazchanging mode of %szchanging mode of %s to %o)	r9r'_namerrrrst_modechmod)rbitsmaskfilesrmoder!r!r"set_modes
zFileOperator.set_modecCs|jdd|S)Nimi)r)r3rr!r!r"<lambda>szFileOperator.<lambda>cCs~tjj|}||jkrztjj|rz|jj|tjj|\}}|j|tj	d||j
shtj||jrz|j
j|dS)NzCreating %s)r9r:rrrrr2rrrrmkdirrr)rr:r rr!r!r"rs

zFileOperator.ensure_dircCsvt||}tjd|||jsh|s0|j||rX|s:d}n|j|sHt|t|d}tj	|||d|j
||S)NzByte-compiling %s to %sT)rrrrrr<r=r>
py_compilecompiler)rr:optimizeforcerFZdpathZdiagpathr!r!r"byte_compiles
zFileOperator.byte_compilecCstjj|rtjj|r`tjj|r`tjd||jsBtj	||j
r||jkr|jj|nPtjj|rrd}nd}tjd|||jstj||j
r||j
kr|j
j|dS)NzRemoving directory tree at %slinkfilezRemoving %s %s)r9r:rrrrdebugrrr~rrrr)rr:r3r!r!r"ensure_removeds"



zFileOperator.ensure_removedcCsHd}x>|sBtjj|r&tj|tj}Ptjj|}||kr<P|}qW|S)NF)r9r:raccessW_OKr)rr:r4parentr!r!r"is_writableszFileOperator.is_writablecCs"|js
t|j|jf}|j|S)zV
        Commit recorded changes, turn off recording, return
        changes.
        )rr=rrr)rr4r!r!r"commits
zFileOperator.commitcCs|jsx(t|jD]}tjj|rtj|qWt|jdd}xN|D]F}tj	|}|r|dgksdt
tjj||d}tj|tj|qDW|j
dS)NT)reverse__pycache__r)rlistrr9r:rrsortedrlistdirr=r0rmdirr)rrdirsr flistZsdr!r!r"rollbacks


zFileOperator.rollback)F)T)N)FFN)rrrrrrrrrrrrZset_executable_moderrrrrrr!r!r!r"rQs 




rcCsb|tjkrtj|}nt|}|dkr,|}n2|jd}t||jd}x|D]}t||}qLW|S)N.r)rJmodules
__import__r2rKrB)Zmodule_nameZdotted_pathmodr4partsrTr!r!r"resolves


rc@s6eZdZddZeddZddZddZej	Z	d	S)
ExportEntrycCs||_||_||_||_dS)N)r'rFrDrx)rr'rFrDrxr!r!r"rszExportEntry.__init__cCst|j|jS)N)rrFrD)rr!r!r"rtszExportEntry.valuecCsd|j|j|j|jfS)Nz<ExportEntry %s = %s:%s %s>)r'rFrDrx)rr!r!r"__repr__!s
zExportEntry.__repr__cCsDt|tsd}n0|j|jko>|j|jko>|j|jko>|j|jk}|S)NF)rOrr'rFrDrx)rotherr4r!r!r"__eq__%s
zExportEntry.__eq__N)
rrrrrrtrrr__hash__r!r!r!r"rs

rz(?P<name>(\w|[-.+])+)
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>\w+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c
Cstj|}|s0d}d|ks"d|krtd|n|j}|d}|d}|jd}|dkrf|d}}n"|dkrztd||jd\}}|d	}	|	dkrd|ksd|krtd|g}	nd
d|	jdD}	t||||	}|S)
N[]zInvalid specification '%s'r'callable:rrrxcSsg|]}|jqSr!)r-)r%rr!r!r"r&Qsz$get_export_entry.<locals>.<listcomp>,)ENTRY_REsearchrrcountr2r)
Z
specificationrr4r r'r:ZcolonsrFrDrxr!r!r"rh7s2


rhcCs|dkrd}tjdkr.dtjkr.tjjd}ntjjd}tjj|rftj|tj}|st	j
d|n<ytj|d}Wn(tk
rt	j
d	|dd
d}YnX|st
j}t	j
d|tjj||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.distlibntZLOCALAPPDATAz
$localappdata~z(Directory exists but is not writable: %sTzUnable to create %s)exc_infoFz#Default location unusable, using %s)r9r'environr:
expandvars
expanduserrrrrwarningmakedirsOSErrorr|r}r0)rDr4Zusabler!r!r"get_cache_baseVs&

rcCsBtjjtjj|\}}|r(|jdd}|jtjd}||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.
    rz---z--z.cache)r9r:
splitdriverr8r;)r:r rTr!r!r"path_to_cache_dirs

rcCs|jds|dS|S)Nr7)endswith)r3r!r!r"ensure_slashs
rcCsHd}}d|kr>|jdd\}}d|kr.|}n|jdd\}}|||fS)N@rr)r2)ZnetlocZusernameZpasswordrFr!r!r"parse_credentialssrcCstjd}tj||S)N)r9umask)r4r!r!r"get_process_umasks

rcCs>d}d}x$t|D]\}}t|tsd}PqW|dk	s:t|S)NTF)	enumeraterOrr=)seqr4ir3r!r!r"is_string_sequences
rz3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z
-py(\d\.?\d?)cCsd}d}t|jdd}tj|}|r@|jd}|d|j}|rt|t|dkrtjtj	|d|}|r|j
}|d|||dd|f}|dkrtj|}|r|jd|jd|f}|S)zw
    Extract name, version, python version from a filename (no extension)

    Return name, version, pyver or None
    N -rz\brZ)rr8PYTHON_VERSIONrrpstartr>rer,escapeendPROJECT_NAME_AND_VERSION)filenameZproject_namer4Zpyverrnr!r!r"split_filenames"


rz-(?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$cCs:tj|}|std||j}|djj|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'r'Zver)NAME_VERSION_REr,rrr-rQ)rTrr r!r!r"parse_name_and_versions
	
rcCst}t|pg}t|pg}d|kr8|jd||O}x|D]x}|dkrV|j|q>|jdr|dd}||krtjd|||kr|j|q>||krtjd||j|q>W|S)N*r
rzundeclared extra: %s)ryrrr<rr)Z	requestedZ	availabler4rZunwantedr!r!r"
get_extrass&


rcCsi}yNt|}|j}|jd}|jds8tjd|ntjd|}tj	|}Wn0t
k
r}ztjd||WYdd}~XnX|S)NzContent-Typezapplication/jsonz(Unexpected response for JSON request: %szutf-8z&Failed to get external data for %s: %s)rrgetr<rrrbrcrerfri	exception)r*r4ZrespZheadersZctreaderer!r!r"_get_external_datas

 rz'https://www.red-dove.com/pypi/projects/cCs*d|dj|f}tt|}t|}|S)Nz%s/%s/project.jsonr)upperr
_external_data_base_urlr)r'r*r4r!r!r"get_project_datas
r cCs(d|dj||f}tt|}t|S)Nz%s/%s/package-%s.jsonr)rr
rr)r'versionr*r!r!r"get_package_datas
r"c@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.
    cCsPtjj|stj|tj|jd@dkr6tjd|tjjtjj	||_
dS)zu
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        ?rzDirectory '%s' is not privateN)r9r:rrrrrrrnormpathr@)rr@r!r!r"r"s

zCache.__init__cCst|S)zN
        Converts a resource prefix to a directory name in the cache.
        )r)rrFr!r!r"
prefix_to_dir0szCache.prefix_to_dircCsg}xtj|jD]r}tjj|j|}y>tjj|s@tjj|rLtj|ntjj|rbt	j
|Wqtk
r|j|YqXqW|S)z"
        Clear the cache.
        )
r9rr@r:r0rrrrrr~riappend)rZnot_removedfnr!r!r"clear6szCache.clearN)rrr__doc__rr&r)r!r!r!r"r#sr#c@s:eZdZdZddZdddZddZd	d
ZddZd
S)
EventMixinz1
    A very simple publish/subscribe system.
    cCs
i|_dS)N)_subscribers)rr!r!r"rKszEventMixin.__init__TcCsD|j}||krt|g||<n"||}|r6|j|n
|j|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)r,rr'
appendleft)revent
subscriberr'subsZsqr!r!r"rNs
zEventMixin.addcCs,|j}||krtd|||j|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)r,rr)rr.r/r0r!r!r"rbszEventMixin.removecCst|jj|fS)z
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        )iterr,r)rr.r!r!r"get_subscribersnszEventMixin.get_subscriberscOspg}xT|j|D]F}y||f||}Wn"tk
rJtjdd}YnX|j|qWtjd|||||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)r2rirrr'r)rr.argskwargsr4r/rtr!r!r"publishus

zEventMixin.publishN)T)	rrrr*rrrr2r5r!r!r!r"r+Gs
r+c@s^eZdZddZddZdddZdd	Zd
dZdd
ZddZ	e
ddZe
ddZdS)	SequencercCsi|_i|_t|_dS)N)_preds_succsry_nodes)rr!r!r"rszSequencer.__init__cCs|jj|dS)N)r9r)rnoder!r!r"add_nodeszSequencer.add_nodeFcCs||jkr|jj||rx&t|jj|fD]}|j||q.Wx&t|jj|fD]}|j||qVWx&t|jjD]\}}|sz|j|=qzWx&t|jjD]\}}|s|j|=qWdS)N)r9rryr7rr8rrg)rr:ZedgesrTr3rqrrr!r!r"remove_nodes
zSequencer.remove_nodecCs<||kst|jj|tj||jj|tj|dS)N)r=r7
setdefaultryrr8)rpredsuccr!r!r"rsz
Sequencer.addcCs||ksty|j|}|j|}Wn tk
rDtd|YnXy|j||j|Wn$tk
rtd||fYnXdS)Nz%r not a successor of anythingz%r not a successor of %r)r=r7r8KeyErrorrr)rr>r?predsZsuccsr!r!r"rs

zSequencer.removecCs||jkp||jkp||jkS)N)r7r8r9)rstepr!r!r"is_stepszSequencer.is_stepcCs|j|std|g}g}t}|j|xd|r|jd}||krd||kr|j||j|q0|j||j||jj|f}|j	|q0Wt
|S)NzUnknown: %rr)rCrryr'rBrrr7rextendreversed)rfinalr4ZtodoseenrBrAr!r!r"	get_stepss"





zSequencer.get_stepscsVdggiig|jfddxD]}|kr:|q:WS)Nrc
sd|<d|<dd7<j|y|}Wntk
rVg}YnXxR|D]J}|kr|t|||<q^|kr^t|||<q^W||krg}x j}|j|||krPqWt|}j|dS)Nrr)r'riminrBtuple)r:Z
successorsZ	successorZconnected_componentZ	component)graphindex
index_counterlowlinksr4stack
strongconnectr!r"rPs.



z3Sequencer.strong_connections.<locals>.strongconnect)r8)rr:r!)rKrLrMrNr4rOrPr"strong_connectionss"
zSequencer.strong_connectionscCsrdg}x8|jD].}|j|}x|D]}|jd||fq"WqWx|jD]}|jd|qHW|jddj|S)Nzdigraph G {z  %s -> %s;z  %s;}
)r7r'r9r0)rr4r?rAr>r:r!r!r"dot
s


z
Sequencer.dotN)F)
rrrrr;r<rrrCrHpropertyrQrTr!r!r!r"r6s

3r6.tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc

sXfdd}tjjtd}|dkr|jdr>d}nH|jdrRd}d	}n4|jdrfd}d
}n |jdrzd}d}ntd|z|dkrt|d}|r|j}xD|D]}||qWn.tj	||}|r|j
}x|D]}||qW|dkr6tjddkr6x.|j
D]"}	t|	jts|	jjd|	_qW|jWd|rR|jXdS)NcsTt|ts|jd}tjjtjj|}|jsD|tjkrPt	d|dS)Nzutf-8zpath outside destination: %r)
rOrdecoder9r:rr0r<r;r)r:rT)dest_dirplenr!r"
check_paths


zunarchive.<locals>.check_path.zip.whlzip.tar.gz.tgzZtgzzr:gz.tar.bz2.tbzZtbzzr:bz2z.tarZtarrzUnknown format for %rrrZzutf-8)rarb)rdre)rfrg)r9r:rr>rrrZnamelisttarfilerZgetnamesrJraZ
getmembersrOr'rr]Z
extractallrl)
Zarchive_filenamer^formatrr`archivernamesr'Ztarinfor!)r^r_r"	unarchivesH






rlcCstj}t|}t|db}xZtj|D]L\}}}x@|D]8}tjj||}||d}	tjj|	|}
|j||
q8Wq(WWdQRX|S)z*zip a directory tree into a BytesIO objectrN)	ioBytesIOr>rr9walkr:r0rz)Z	directoryr4ZdlenZzfrootrrr'ZfullZrelrEr!r!r"zip_dirSs
rqr$KMGTPc@sreZdZdZdddZddZdd	Zd
dZdd
Ze	ddZ
e	ddZddZe	ddZ
e	ddZdS)ProgressZUNKNOWNrdcCs<|dks||kst||_|_||_d|_d|_d|_dS)NrF)r=rIcurmaxstartedelapseddone)rZminvalZmaxvalr!r!r"rjszProgress.__init__cCsV|j|kst|jdks&||jks&t||_tj}|jdkrF||_n||j|_dS)N)rIr=rzrytimer{r|)rZcurvalZnowr!r!r"updaters
zProgress.updatecCs |dkst|j|j|dS)Nr)r=rry)rZincrr!r!r"	increment|szProgress.incrementcCs|j|j|S)N)rrI)rr!r!r"rszProgress.startcCs |jdk	r|j|jd|_dS)NT)rzrr})rr!r!r"stops
z
Progress.stopcCs|jdkr|jS|jS)N)rzunknown)rr!r!r"maximumszProgress.maximumcCsD|jrd}n4|jdkrd}n$d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)r}rzryrI)rr4rrr!r!r"
percentages
zProgress.percentagecCs:|dkr|jdks|j|jkr$d}ntjdtj|}|S)Nrz??:??:??z%H:%M:%S)rzryrIr~ZstrftimeZgmtime)rZdurationr4r!r!r"format_durationszProgress.format_durationcCs|jrd}|j}n^d}|jdkr&d}nJ|jdks<|j|jkrBd}n.t|j|j}||j|j}|d|j}d||j|fS)NZDonezETA rrz%s: %sr)r}r|rzryrIfloatr)rrFtr!r!r"ETAs
zProgress.ETAcCsN|jdkrd}n|j|j|j}xtD]}|dkr6P|d}q(Wd||fS)Nrgig@@z%d %sB/s)r|ryrIUNITS)rr4Zunitr!r!r"speeds

zProgress.speedN)rrx)rrrrrrrrrrUrrrrrr!r!r!r"rwgs

	rwz\{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCs<tj|rd}t||tj|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_GLOBrr_CHECK_MISMATCH_SET_iglob)	path_globrr!r!r"rs

rccstj|d}t|dkrpt|dks,t||\}}}x|jdD](}x"tdj|||fD]
}|Vq\WqBWnd|krxt|D]
}|VqWn|jdd\}}|dkrd}|dkrd}n|jd}|jd	}xHtj	|D]:\}}}	tj
j|}x"ttj
j||D]}
|
VqWqWdS)
NrrZrr$z**rrr7\)	RICH_GLOBr2r>r=rr0	std_iglobr?r9ror:r%)rZrich_path_globrFryrDitemr:Zradicaldirrr(r!r!r"rs*


r)HTTPSHandlermatch_hostnameCertificateErrorc@seZdZdZdZddZdS)HTTPSConnectionNTcCsPtj|j|jf|j}t|ddr0||_|jtt	dsp|j
rHt	j}nt	j}t	j
||j|j|t	j|j
d|_nxt	jt	j}|jt	jO_|jr|j|j|ji}|j
rt	j|_|j|j
dtt	ddr|j|d<|j
|f||_|j
o|jrLy$t|jj|jtjd|jWn0tk
rJ|jjtj|jjYnXdS)	NZ_tunnel_hostF
SSLContext)	cert_reqsZssl_versionca_certs)ZcafileZHAS_SNIZserver_hostnamezHost verified: %s) rZcreate_connectionhostporttimeoutrKsockZ_tunnelrIsslrZ
CERT_REQUIREDZ	CERT_NONEZwrap_socketZkey_fileZ	cert_fileZPROTOCOL_SSLv23rZoptionsZOP_NO_SSLv2Zload_cert_chainZverify_modeZload_verify_locationscheck_domainrZgetpeercertrrrZshutdownZ	SHUT_RDWRrl)rrrcontextr4r!r!r"connects>


zHTTPSConnection.connect)rrrrrrr!r!r!r"rsrc@s&eZdZd	ddZddZddZdS)
rTcCstj|||_||_dS)N)BaseHTTPSHandlerrrr)rrrr!r!r"r#s
zHTTPSHandler.__init__cOs$t||}|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.
            )rrr)rr3r4r4r!r!r"_conn_maker(s


zHTTPSHandler._conn_makercCsVy|j|j|Stk
rP}z&dt|jkr>td|jnWYdd}~XnXdS)Nzcertificate verify failedz*Unable to verify server certificate for %s)Zdo_openrrstrreasonrr)rreqrr!r!r"
https_open8szHTTPSHandler.https_openN)T)rrrrrrr!r!r!r"r"s
rc@seZdZddZdS)HTTPSOnlyHandlercCstd|dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rrr!r!r"	http_openLszHTTPSOnlyHandler.http_openN)rrrrr!r!r!r"rKsrc@seZdZdddZdS)HTTPr$NcKs&|dkrd}|j|j||f|dS)Nr)_setup_connection_class)rrrr4r!r!r"rXsz
HTTP.__init__)r$N)rrrrr!r!r!r"rWsrc@seZdZdddZdS)HTTPSr$NcKs&|dkrd}|j|j||f|dS)Nr)rr)rrrr4r!r!r"r`szHTTPS.__init__)r$N)rrrrr!r!r!r"r_src@seZdZdddZddZdS)	TransportrcCs||_tjj||dS)N)rrrr)rruse_datetimer!r!r"rgszTransport.__init__cCsb|j|\}}}tdkr(t||jd}n6|js>||jdkrT||_|tj|f|_|jd}|S)Nrr)rrr)rr)
get_host_info	_ver_inforr_connection_extra_headersrZHTTPConnection)rrhehZx509r4r!r!r"make_connectionks
zTransport.make_connectionN)r)rrrrrr!r!r!r"rfs
rc@seZdZdddZddZdS)
SafeTransportrcCs||_tjj||dS)N)rrrr)rrrr!r!r"rxszSafeTransport.__init__cCsz|j|\}}}|si}|j|d<tdkr:t|df|}n<|jsP||jdkrl||_|tj|df|f|_|jd}|S)Nrrrrr)rr)rrrrrrrr)rrrrr4r4r!r!r"r|s


zSafeTransport.make_connectionN)r)rrrrrr!r!r!r"rws
rc@seZdZddZdS)ServerProxyc	Kst|jdd|_}|dk	r^t|\}}|jdd}|dkr@t}nt}|||d|d<}||_tjj	||f|dS)NrrrZhttps)r	transport)
rBrrrrrrrrr)	rZurir4rscheme_rZtclsrr!r!r"rszServerProxy.__init__N)rrrrr!r!r!r"rsrcKs.tjddkr|d7}nd|d<t||f|S)NrrZbr$newline)rJrar)r(rr4r!r!r"	_csv_opens
rc@s4eZdZedededdZddZddZd	S)
CSVBaser"rS)Z	delimiterZ	quotecharZlineterminatorcCs|S)Nr!)rr!r!r"	__enter__szCSVBase.__enter__cGs|jjdS)N)r_rl)rrr!r!r"__exit__szCSVBase.__exit__N)rrrrdefaultsrrr!r!r!r"rs
rc@s(eZdZddZddZddZeZdS)	CSVReadercKs\d|kr4|d}tjddkr,tjd|}||_nt|dd|_tj|jf|j|_dS)Nr_rrZzutf-8r:r)	rJrarbrcr_rcsvrr)rr4r_r!r!r"rszCSVReader.__init__cCs|S)Nr!)rr!r!r"__iter__szCSVReader.__iter__cCsJt|j}tjddkrFx,t|D] \}}t|ts"|jd||<q"W|S)NrrZzutf-8)nextrrJrarrOrr])rr4rrr!r!r"rs

zCSVReader.nextN)rrrrrr__next__r!r!r!r"rsrc@seZdZddZddZdS)	CSVWritercKs$t|d|_tj|jf|j|_dS)Nr)rr_rwriterr)rr(r4r!r!r"rszCSVWriter.__init__cCsRtjddkrBg}x*|D]"}t|tr0|jd}|j|qW|}|jj|dS)NrrZzutf-8)rJrarOrrr'rwriterow)rrowrrr!r!r"rs


zCSVWriter.writerowN)rrrrrr!r!r!r"rsrcsHeZdZeejZded<dfdd	ZddZdd	Zd
dZ	Z
S)
Configuratorinc_convertZincNcs"tt|j||ptj|_dS)N)superrrr9rr@)rconfigr@)	__class__r!r"rszConfigurator.__init__c
sfddjd}t|s*j|}jdd}jdf}|r\tfdd|D}fddD}t|}|||}|rx$|jD]\}}	t|||	qW|S)	Ncszt|ttfr*t|fdd|D}nLt|trld|krHj|}qvi}x(|D]}||||<qRWn
j|}|S)Ncsg|]}|qSr!r!)r%r)convertr!r"r&szBConfigurator.configure_custom.<locals>.convert.<locals>.<listcomp>z())rOrrJtypedictconfigure_customr)or4rq)rrr!r"rs


z.Configurator.configure_custom.<locals>.convertz()rz[]csg|]}|qSr!r!)r%r)rr!r"r&sz1Configurator.configure_custom.<locals>.<listcomp>cs$g|]}t|r||fqSr!)r)r%rq)rrr!r"r&s)rBrrrJrrgsetattr)
rrrUZpropsr3rgr4r4rrrr!)rrrr"rs


zConfigurator.configure_customcCs4|j|}t|tr0d|kr0|j||j|<}|S)Nz())rrOrr)rrXr4r!r!r"__getitem__s
zConfigurator.__getitem__c	CsFtjj|stjj|j|}tj|ddd}tj|}WdQRX|S)z*Default converter for the inc:// protocol.rzutf-8)rN)	r9r:isabsr0r@rbrrerf)rrtrr4r!r!r"rs
zConfigurator.inc_convert)N)rrrrrZvalue_convertersrrrr
__classcell__r!r!)rr"rs
rc@s&eZdZd	ddZddZddZdS)
SubprocessMixinFNcCs||_||_dS)N)verboseprogress)rrrr!r!r"rszSubprocessMixin.__init__cCsn|j}|j}xT|j}|sP|dk	r0|||q|sBtjjdntjj|jdtjjqW|jdS)z
        Read lines from a subprocess' output stream and either pass to a progress
        callable (if specified) or write progress information to sys.stderr.
        Nrzutf-8)	rrreadlinerJstderrrzr]flushrl)rr_rrrr3r!r!r"r"szSubprocessMixin.readercKstj|ftjtjd|}tj|j|jdfd}|jtj|j|jdfd}|j|j	|j
|j
|jdk	r|jddn|jrt
jjd|S)N)stdoutrr)rr3rzdone.mainzdone.
)
subprocessPopenPIPE	threadingZThreadrrrrwaitr0rrrJrz)rcmdr4rTZt1Zt2r!r!r"run_command7s
zSubprocessMixin.run_command)FN)rrrrrrr!r!r!r"rs
rcCstjdd|jS)z,Normalize a python package name a la PEP 503z[-_.]+r
)r
subrQ)r'r!r!r"normalize_nameHsr)NN)r)N)N)rVrWrXrYrZr[r\)NT)r$rrrsrtrurv)rr)rbcollectionsr
contextlibrZglobrrrmreZloggingr9rr
rrrImportErrorrrJrhr|rmrZdummy_threadingr~r$rcompatrrr	r
rrr
rrrrrrrrrrrrZ	getLoggerrrCOMMArr1ZIDENTZEXTRA_IDENTZVERSPECZRELOPZBARE_CONSTRAINTSZ
DIRECT_REFZCONSTRAINTSZ
EXTRA_LISTZEXTRASZREQUIREMENTr+ZRELOP_IDENTr.r6rGrLrPrVrYrur{contextmanagerrrrrrrrrrVERBOSErrhrrrrrrIrrrrrrrrr r"r#r+r6ZARCHIVE_EXTENSIONSrlrqrrwrrrrrrrrrrrarrrrrrrrrrrrrr!r!r!r"<module>s
X

,

%

	/
	7

)



,H
6]


*)	
:+
Back to Directory File Manager