Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/distlib/__pycache__/util.cpython-35.pyc



t_@sddlZddlmZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZyddlZWnek
rdZYnXddlZddlZddlZddlZddlZyddlZWnek
r/ddlZYnXddlZddlmZddlmZmZmZmZm 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
j1e2Z3e
j4dZ5e
j4dZ6e
j4d	Z7e
j4d
Z8e
j4dZ9e
j4dZ:e
j4d
Z;e
j4dZ<ddZ=ddZ>ddZ?ddZ@ddZAddddZBddZCddZDdd ZEejFd!d"ZGejFd#d$ZHejFd%d&d'ZIGd(d)d)eJZKd*d+ZLGd,d-d-eJZMd.d/ZNGd0d1d1eJZOe
j4d2e
jPZQd3d4ZRdd5d6ZSd7d8ZTd9d:ZUd;d<ZVd=d>ZWd?d@ZXe
j4dAe
jYZZe
j4dBZ[ddCdDZ\e
j4dEZ]dFdGZ^dHdIZ_dJdKZ`dLZadMdNZbdOdPZcGdQdRdReJZdGdSdTdTeJZeGdUdVdVeJZfdZgdd^d_d`ZhdadbZidZjGdidjdjeJZke
j4dkZle
j4dlZme
j4dmZndndoZdpdqZoerddrlmpZqmrZrmsZsGdsdtdte$jtZtGdudvdveqZpGdwdxdxepe'ZuejvddyZwewdkrGd{d|d|e$jxZxerGd}d~d~e$jyZyGddde%jzZzerGddde%j{Z{Gddde%j|Z|ddZ}GdddeJZ~Gddde~ZGddde~ZGddde(ZGdddeJZddZdS)N)deque)iglob)DistlibException)string_types	text_typeshutil	raw_inputStringIOcache_from_sourceurlopenurljoinhttplib	xmlrpclib	splittypeHTTPHandlerBaseConfiguratorvalid_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\.{}()*+#:;,/?!~`@$%^&=|<>\[\]-]+)csOddfddfddfdd|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).
    cSstj|}|r>|jd}||jd}nZ|sStdnE|d}|dkrytd|dj|d}|dd}|g}x|rF|d|krPq|d|kr|j||dd}qtj|}|std||j|jd||jd}qWdj|}td||j|dj|}|ddj	}||fS)	Nrzunexpected end of inputz'"zinvalid expression: %srzerror in string literal: %szunterminated string: %s)

IDENTIFIERmatchgroupsendSyntaxErrorreplaceappendSTRING_CHUNKjoinlstrip)	remainingmresultqoqpartssr-/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/distlib/util.py
marker_varAs:
		

z parse_marker.<locals>.marker_varcs|rq|ddkrq|ddj\}}|ddkrXtd||ddj}n|\}}xp|rtj|}|sP|jd}||jd}|\}}d|d|d|i}qW|}||fS)	Nr(r)zunterminated parenthesis: %soplhsrhs)r%r 	MARKER_OPrrr)r&r(r3r'r2r4)markerr/r-r.marker_expres "	z!parse_marker.<locals>.marker_exprcs|\}}x`|rttj|}|s1P||jd}|\}}ddd|d|i}qW||fS)Nr2andr3r4)ANDrr)r&r3r'r4)r7r-r.
marker_andxs	z parse_marker.<locals>.marker_andcs|\}}x`|rttj|}|s1P||jd}|\}}ddd|d|i}qW||fS)Nr2orr3r4)ORrr)r&r3r'r4)r:r-r.r6s	zparse_marker.<locals>.markerr-)
marker_stringr-)r6r:r7r/r.parse_marker8s
	$r>c
CsD|j}|s"|jdr&dStj|}|sKtd||jd}||jd}d}}}}|r|ddkr|jdd}|dkrtd||d|}	||ddj}g}x|	rtj|	}|s%td	|	|j	|jd|	|jd}	|	sYP|	dd
krytd|	|	ddj}	qW|sd}|rp|ddkrM|ddj}t
j|}|std
||jd}t|}
|
jo|
j
s.td|||jdj}n#dd}|ddkr~||\}}n|jdd}|dkrtd||d|}	||ddj}tj|	r||	\}}nvtj|	}|std|	|jd}
|	|jdj}	|	ratd|	d|
fg}|r|ddkrtd||ddj}t|\}}|r|ddkrtd||s|}n&d|djdd|Df}td|d|d|d |d!|d"|S)#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: %scSstj|}d}|rg}x|jd}||jd}tj|}|sotd||jd}|j||f||jd}|s|ddkrP|ddj}tj|}|s$td|q$W|sd}||fS)z|
                Return a list of operator, version tuples if any are
                specified, else None.
                Nrzinvalid version: %srBrzinvalid constraint: %s)
COMPARE_OPrrrVERSION_IDENTIFIERr r"r%)
ver_remainingr'versionsr2vr-r-r.get_versionss,z'parse_requirement.<locals>.get_versionsr0r1zunterminated parenthesis: %szinvalid constraint: %sz~=;zinvalid requirement: %szunexpected trailing data: %sz%s %sz, cSsg|]}d|qS)z%s %sr-).0conr-r-r.
<listcomp>s	z%parse_requirement.<locals>.<listcomp>nameextrasconstraintsr6urlrequirement)strip
startswithrrr rrfindr%r"	NON_SPACErschemenetlocrDrEr>r$r)reqr&r'distnamerO	mark_exprrGuriir,trI_rHrsr-r-r.parse_requirements		&racCsdd}i}x|D]\}}}tjj||}xt|D]}tjj||}	xt|	D]v}
|||
}|dkr|j|dqr|||
}|jtjjdjd}
|
d|||<qrWqJWqW|S)z%Find destinations for resources filescSsb|jtjjd}|jtjjd}|j|sEt|t|djdS)N/)r!ospathseprTAssertionErrorlenr%)rootrdr-r-r.get_rel_path
sz)get_resources_dests.<locals>.get_rel_pathNrb)rcrdr$rpopr!rerstrip)resources_rootrulesridestinationsbasesuffixdestprefixabs_baseabs_globabs_path
resource_filerel_pathrel_destr-r-r.get_resources_dests
s!rycCs:ttdrd}ntjttdtjk}|S)Nreal_prefixTbase_prefix)hasattrsysrrgetattr)r(r-r-r.in_venv$s	rcCs4tjjtj}t|ts0t|}|S)N)rcrdnormcaser}
executable
isinstancerr)r(r-r-r.get_executable.s
rcCsr|}xet|}|}|r.|r.|}|r	|dj}||krQP|r	d|||f}q	W|S)Nrz	%c: %s
%s)r	lower)prompt
allowed_charserror_promptdefaultpr,cr-r-r.proceed>s
rcCsPt|tr|j}i}x(|D] }||kr(||||<q(W|S)N)rrsplit)dkeysr(keyr-r-r.extract_by_keyNs
rcCstjddkr(tjd|}|j}t|}ytj|}|ddd}xo|jD]a\}}xR|jD]D\}}d||f}t	|}	|	dk	st
|	||<qWqqW|SWn"tk
r|jddYnXdd	}
t
j}y|
||WnGt
jk
rr|jtj|}t|}|
||YnXi}xz|jD]l}i||<}xU|j|D]D\}
}d|
|f}t	|}	|	dk	st
|	||
<qWqW|S)
Nrzutf-8
extensionszpython.exportsexportsz%s = %scSs0t|dr|j|n
|j|dS)N	read_file)r|rreadfp)cpstreamr-r-r.read_streamksz!read_exports.<locals>.read_stream)r}version_infocodecs	getreaderreadr
jsonloaditemsget_export_entryrf	ExceptionseekrConfigParserMissingSectionHeaderErrorclosetextwrapdedentsections)rdatajdatar(groupentrieskrHr,entryrrrrNvaluer-r-r.read_exportsWsD

rcCstjddkr(tjd|}tj}x|jD]\}}|j|x|jD]r}|j	dkr|j
}nd|j
|j	f}|jrd|dj|jf}|j
||j|qgWqAW|j|dS)Nrrzutf-8z%s:%sz%s [%s]z, )r}rr	getwriterrrradd_sectionvaluesrprrflagsr$setrNwrite)rrrrrHrr,r-r-r.
write_exportss
	rccs*tj}z	|VWdtj|XdS)N)tempfilemkdtemprrmtree)tdr-r-r.tempdirs	rccs7tj}ztj|dVWdtj|XdS)N)rcgetcwdchdir)rcwdr-r-r.rs

	rccs7tj}ztj|dVWdtj|XdS)N)socketgetdefaulttimeoutsetdefaulttimeout)secondsctor-r-r.socket_timeouts

	rc@s+eZdZddZdddZdS)cached_propertycCs
||_dS)N)func)selfrr-r-r.__init__szcached_property.__init__NcCs<|dkr|S|j|}tj||jj||S)N)robject__setattr____name__)robjclsrr-r-r.__get__s
zcached_property.__get__)r
__module____qualname__rrr-r-r-r.rsrcCstjdkr|S|s|S|ddkr=td||ddkr]td||jd}x#tj|kr|jtjqoW|stjStjj|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.
    rbrzpath '%s' cannot be absoluterzpath '%s' cannot end with '/')rcre
ValueErrorrcurdirremoverdr$)pathnamepathsr-r-r.convert_paths
rc@seZdZdddZddZddZdd	Zd
ddZd
ddZddZ	ddZ
ddZddZddZ
ddd
dddZddZddZd d!Zd"d#Zd
S)$FileOperatorFcCs#||_t|_|jdS)N)dry_runrensured_init_record)rrr-r-r.rs	zFileOperator.__init__cCs%d|_t|_t|_dS)NF)recordr
files_writtendirs_created)rr-r-r.rs	zFileOperator._init_recordcCs|jr|jj|dS)N)rradd)rrdr-r-r.record_as_writtens	zFileOperator.record_as_writtencCsftjj|s.tdtjj|tjj|sDdStj|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)rcrdexistsrabspathstatst_mtime)rsourcetargetr-r-r.newerszFileOperator.newerTcCs|jtjj|tjd|||jsd}|rtjj|r`d|}n/tjj|rtjj	|rd|}|rt
|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_dirrcrddirnameloggerinforislinkrisfilerrcopyfiler)rinfileoutfilecheckmsgr-r-r.	copy_files	
%
zFileOperator.copy_fileNc
Cstjj|st|jtjj|tjd|||js|dkrlt	|d}nt
j	|dd|}ztj||Wd|j
X|j|dS)NzCopying stream %s to %swbwencoding)rcrdisdirrfrrrrropenrrcopyfileobjrr)rinstreamrr	outstreamr-r-r.copy_streams	zFileOperator.copy_streamc	Csx|jtjj||jsgtjj|rAtj|t|d}|j|WdQRX|j	|dS)Nr)
rrcrdrrrrrrr)rrdrfr-r-r.write_binary_file!s	
zFileOperator.write_binary_filecCs|j||j|dS)N)rencode)rrdrrr-r-r.write_text_file*szFileOperator.write_text_filecCstjdks-tjdkrtjdkrxg|D]_}|jrVtjd|q4tj|j|B|@}tjd||tj||q4WdS)Nposixjavazchanging mode of %szchanging mode of %s to %o)	rcrN_namerrrrst_modechmod)rbitsmaskfilesrmoder-r-r.set_mode-s-
	zFileOperator.set_modecCs|jdd|S)Nimi)r)r,rr-r-r.<lambda>9szFileOperator.<lambda>cCstjj|}||jkrtjj|r|jj|tjj|\}}|j|tj	d||j
stj||jr|j
j|dS)NzCreating %s)rcrdrrrrrrrrrmkdirrr)rrdrrr-r-r.r;s"
	
	zFileOperator.ensure_dirc	Cst||}tjd|||js|sD|j||r~|sSd}n+|j|sht|t|d}i}|rtt	drt	j
j|d<t	j|||d||j
||S)NzByte-compiling %s to %sPycInvalidationModeinvalidation_modeT)rrrrrrTrfrgr|
py_compilerCHECKED_HASHcompiler)	rrdoptimizeforcerrhashed_invalidationdpathdiagpathcompile_kwargsr-r-r.byte_compileGs		
zFileOperator.byte_compilecCstjj|rtjj|rtjj|rtjd||js]tj	||j
r||jkr|jj|nrtjj|rd}nd}tjd|||jstj||j
r||j
kr|j
j|dS)NzRemoving directory tree at %slinkfilezRemoving %s %s)rcrdrrrrdebugrrrrrrr)rrdr,r-r-r.ensure_removedXs"%	
			
	zFileOperator.ensure_removedcCsdd}xW|s_tjj|r7tj|tj}Ptjj|}||krVP|}q	W|S)NF)rcrdraccessW_OKr)rrdr(parentr-r-r.is_writablems	
zFileOperator.is_writablecCs/|jst|j|jf}|j|S)zV
        Commit recorded changes, turn off recording, return
        changes.
        )rrfrrr)rr(r-r-r.commitys
zFileOperator.commitcCs|jsx6t|jD]%}tjj|rtj|qWt|jdd}xk|D]c}tj	|}|r|dgkst
tjj||d}tj|tj|q^W|j
dS)NreverseT__pycache__r)rlistrrcrdrrsortedrlistdirrfr$rmdirr)rrdirsrflistsdr-r-r.rollbacks	

zFileOperator.rollback)rrrrrrrrrrrrset_executable_moderrrr"r#r-r-r-r-r.rs 	
rcCs|tjkrtj|}nt|}|dkr@|}nG|jd}t||jd}x|D]}t||}qnW|S)N.r)r}modules
__import__rr~rj)module_namedotted_pathmodr(r+rr-r-r.resolves	
r5c@sOeZdZddZeddZddZddZej	Z	d	S)
ExportEntrycCs(||_||_||_||_dS)N)rNrrrpr)rrNrrrprr-r-r.rs			zExportEntry.__init__cCst|j|jS)N)r5rrrp)rr-r-r.rszExportEntry.valuecCs d|j|j|j|jfS)Nz<ExportEntry %s = %s:%s %s>)rNrrrpr)rr-r-r.__repr__szExportEntry.__repr__cCsdt|tsd}nH|j|jko]|j|jko]|j|jko]|j|jk}|S)NF)rr6rNrrrpr)rotherr(r-r-r.__eq__s	zExportEntry.__eq__N)
rrrrrrr7r9r__hash__r-r-r-r.r6s

r6z(?P<name>(\w|[-.+])+)
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>[\w-]+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c
Cs>tj|}|sFd}d|ks3d|kr:td|n|j}|d}|d}|jd}|dkr|d}}n1|dkrtd||jd\}}|d	}	|	dkr	d|ksd|krtd|g}	nd
d|	jdD}	t||||	}|S)
Nr@rAzInvalid specification '%s'rNcallable:rrrcSsg|]}|jqSr-)rS)rKrr-r-r.rMs	z$get_export_entry.<locals>.<listcomp>rB)ENTRY_REsearchr	groupdictcountrr6)

specificationr'r(rrNrdcolonsrrrprr-r-r.rs2





	rcCs|dkrd}tjdkrEdtjkrEtjjd}ntjjd}tjj|rtj|tj}|st	j
d|nHytj|d}Wn.tk
rt	j
d	|d
dd}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.distlibntLOCALAPPDATAz
$localappdata~z(Directory exists but is not writable: %sTzUnable to create %sexc_infoFz#Default location unusable, using %s)rcrNenvironrd
expandvars
expanduserrrr rwarningmakedirsOSErrorrrr$)rpr(usabler-r-r.get_cache_bases&


rNcCs]tjjtjj|\}}|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.
    r<z---z--z.cache)rcrd
splitdriverr!re)rdrrr-r-r.path_to_cache_dir
s

$rPcCs|jds|dS|S)Nrb)endswith)r,r-r-r.ensure_slashsrRcCsd}}d|kr[|jdd\}}d|krC|}n|jdd\}}|rmt|}|rt|}|||fS)NrCrr<)rsplitrr)rXusernamepasswordrrr-r-r.parse_credentials$s
	rVcCs tjd}tj||S)N)rcumask)r(r-r-r.get_process_umask3s
rYcCsUd}d}x0t|D]"\}}t|tsd}PqW|dk	sQt|S)NTF)	enumeraterrrf)seqr(r]r,r-r-r.is_string_sequence8sr\z3([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\br)rr!PYTHON_VERSIONr>rstartrgrerescaperPROJECT_NAME_AND_VERSION)filenameproject_namer(pyverr'nr-r-r.split_filenameGs""'!rhz-(?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$cCsOtj|}|s%td||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'rNver)NAME_VERSION_RErrr?rSr)rr'rr-r-r.parse_name_and_versioncs
	rkcCst}t|pg}t|p'g}d|krP|jd||O}x|D]}|dkry|j|qW|jdr|dd}||krtjd|||kr|j|qW||krtjd||j|qWW|S)N*r^rzundeclared extra: %s)rrrrTrrJ)	requested	availabler(runwantedr-r-r.
get_extrasrs&	


rqcCsi}yqt|}|j}|jd}|jdsRtjd|n$tjd|}tj	|}Wn8t
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rgetrTrrrrrrr	exception)rQr(respheadersctreaderer-r-r._get_external_datas&ryz'https://www.red-dove.com/pypi/projects/cCs9d|dj|f}tt|}t|}|S)Nz%s/%s/project.jsonr)upperr
_external_data_base_urlry)rNrQr(r-r-r.get_project_datasr|cCs6d|dj||f}tt|}t|S)Nz%s/%s/package-%s.jsonr)rzr
r{ry)rNversionrQr-r-r.get_package_datasr~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@dkrKtjd|tjjtjj	||_
dS)zu
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        ?rzDirectory '%s' is not privateN)rcrdrrKrrrrJrnormpathro)rror-r-r.rs

zCache.__init__cCs
t|S)zN
        Converts a resource prefix to a directory name in the cache.
        )rP)rrrr-r-r.
prefix_to_dirszCache.prefix_to_dircCsg}xtj|jD]}tjj|j|}yWtjj|s^tjj|rntj|ntjj|rt	j
|Wqtk
r|j|YqXqW|S)z"
        Clear the cache.
        )
rcr(rordr$rrrrrrrr")rnot_removedfnr-r-r.clears$
zCache.clearN)rrr__doc__rrrr-r-r-r.rsrc@sUeZdZdZddZdddZddZd	d
ZddZd
S)
EventMixinz1
    A very simple publish/subscribe system.
    cCs
i|_dS)N)_subscribers)rr-r-r.rszEventMixin.__init__TcCs\|j}||kr+t|g||<n-||}|rK|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)rrr"
appendleft)revent
subscriberr"subssqr-r-r.rs
	
zEventMixin.addcCs:|j}||kr%td|||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)rrr)rrrrr-r-r.rs	zEventMixin.removecCst|jj|fS)z
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        )iterrrr)rrr-r-r.get_subscribersszEventMixin.get_subscriberscOsg}xb|j|D]Q}y||||}Wn%tk
rYtjdd}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)rrrrsr"r)rrargskwargsr(rrr-r-r.publishs

	zEventMixin.publishN)	rrrrrrrrrr-r-r-r.rsrc@seZdZddZddZdddZdd	Zd
dZdd
ZddZ	e
ddZe
ddZdS)	SequencercCs"i|_i|_t|_dS)N)_preds_succsr_nodes)rr-r-r.r"s		zSequencer.__init__cCs|jj|dS)N)rr)rnoder-r-r.add_node'szSequencer.add_nodeFcCs||jkr|jj||rx3t|jj|fD]}|j||qAWx3t|jj|fD]}|j||qwWx3t|jjD]\}}|s|j|=qWx3t|jjD]\}}|s|j|=qWdS)N)rrrrrrrr&r)rredgesrr,rrHr-r-r.remove_node*s""""zSequencer.remove_nodecCsT||kst|jj|tj||jj|tj|dS)N)rfr
setdefaultrrr)rpredsuccr-r-r.r:sz
Sequencer.addcCs||ksty|j|}|j|}Wn"tk
rTtd|YnXy|j||j|Wn(tk
rtd||fYnXdS)Nz%r not a successor of anythingz%r not a successor of %r)rfrrKeyErrorrr)rrrpredssuccsr-r-r.r?s



zSequencer.removecCs+||jkp*||jkp*||jkS)N)rrr)rstepr-r-r.is_stepLszSequencer.is_stepcCs|j|std|g}g}t}|j|x|r|jd}||kr||kr|j||j|qD|j||j||jj|f}|j	|qDWt
|S)NzUnknown: %rr)rrrr"rjrrrrrextendreversed)rfinalr(todoseenrrr-r-r.	get_stepsPs"	
	


zSequencer.get_stepscsydggiig|jfddx$D]}|krU|qUWS)Nrc
s0d|<d|<dd7<j|y|}Wntk
r_g}YnXxi|D]a}|kr|t|||<qg|krgt|||<qgW||kr,g}x*j}|j|||krPqWt|}j|dS)Nrr)r"rminrjtuple)r
successors	successorconnected_component	component)graphindex
index_counterlowlinksr(stack
strongconnectr-r.rts.




z3Sequencer.strong_connections.<locals>.strongconnect)r)rrr-)rrrrr(rrr.strong_connectionsis		$"
zSequencer.strong_connectionscCsdg}xF|jD];}|j|}x%|D]}|jd||fq-WqWx"|jD]}|jd|q\W|jddj|S)Nzdigraph G {z  %s -> %s;z  %s;}
)rr"rr$)rr(rrrrr-r-r.dots	


z
Sequencer.dotN)
rrrrrrrrrrpropertyrrr-r-r-r.r!s
3r.tar.gz.tar.bz2.tar.zip.tgz.tbz.whlTc

sfdd}tjjtd}|dkr|jdr]d}nj|jdr{d}d	}nL|jdrd}d
}n.|jdrd}d}ntd|z|dkrt|d}|rT|j}xZ|D]}||qWn?tj	||}|rT|j
}x|D]}||q@W|dkrtjddkrx;|j
D]-}	t|	jts|	jjd|	_qW|jWd|r|jXdS)Ncsvt|ts|jd}tjjtjj|}|jsb|tjkrrt	d|dS)Nzutf-8zpath outside destination: %r)
rrdecodercrdrr$rTrer)rdr)dest_dirplenr-r.
check_paths
!#zunarchive.<locals>.check_path.zip.whlzip.tar.gz.tgztgzzr:gz.tar.bz2.tbztbzzr:bz2z.tartarrozUnknown format for %rrrzutf-8)rr)rr)rr)rcrdrrgrQrrnamelisttarfilergetnamesr}r
getmembersrrNrr
extractallr)
archive_filenamerformatrrarchivernamesrNtarinfor-)rrr.	unarchivesH				

rcCstj}t|}t|d}x{tj|D]j\}}}xX|D]P}tjj||}||d}	tjj|	|}
|j||
qPWq:WWdQRX|S)z*zip a directory tree into a BytesIO objectrN)	ioBytesIOrgrrcwalkrdr$r)	directoryr(dlenzfrhr*r
rNfullrelrqr-r-r.zip_dirs
rrKMGTPc@seZdZdZddddZddZdd	Zd
dZdd
Ze	ddZ
e	ddZddZe	ddZ
e	ddZdS)ProgressUNKNOWNrdcCsV|dks||kst||_|_||_d|_d|_d|_dS)NrF)rfrcurmaxstartedelapseddone)rminvalmaxvalr-r-r.rs			zProgress.__init__cCs}|j|kst|jdks9||jks9t||_tj}|jdkri||_n||j|_dS)N)rrfrrtimerr)rcurvalnowr-r-r.updates$	zProgress.updatecCs*|dkst|j|j|dS)Nr)rfrr)rincrr-r-r.	incrementszProgress.incrementcCs|j|j|S)N)rr)rr-r-r.r`szProgress.startcCs,|jdk	r|j|jd|_dS)NT)rrr)rr-r-r.stopsz
Progress.stopcCs|jdkr|jS|jS)N)runknown)rr-r-r.maximumszProgress.maximumcCsZ|jrd}nD|jdkr*d}n,d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)rrrr)rr(rHr-r-r.
percentages			"
zProgress.percentagecCsU|dkr|jdks-|j|jkr6d}ntjdtj|}|S)Nrz??:??:??z%H:%M:%S)rrrrstrftimegmtime)rdurationr(r-r-r.format_duration*s-	zProgress.format_durationcCs|jrd}|j}nd}|jdkr9d}ne|jdksZ|j|jkrcd}n;t|j|j}||j|j}|d|j}d||j|fS)NDonezETA rrz%s: %sr)rrrrrfloatr)rrrr^r-r-r.ETA3s		!	zProgress.ETAcCse|jdkrd}n|j|j|j}x%tD]}|dkrIP|d}q6Wd||fS)Nrgig@@z%d %sB/s)rrrUNITS)rr(unitr-r-r.speedFs	
zProgress.speedN)rrrrrrrr`rrrrrrrr-r-r-r.rs
	rz\{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCsTtj|r%d}t||tj|rJd}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_GLOBr>r_CHECK_MISMATCH_SET_iglob)	path_globrr-r-r.r[srccstj|d}t|dkrt|dksBt||\}}}x0|jdD]4}x+tdj|||fD]}|VqWqaWnd|krxt|D]}|VqWn|jdd\}}|dkrd}|dkrd}n|jd}|jd	}x]tj	|D]L\}}}	tj
j|}x(ttj
j||D]}
|
VqqWq4WdS)
NrrrBrz**r/rlrb\)	RICH_GLOBrrgrfrr$	std_iglobr%rcrrdr)r	rich_path_globrrrrpitemrdradicaldirr
rr-r-r.rfs*%	"r)HTTPSHandlermatch_hostnameCertificateErrorc@s(eZdZdZdZddZdS)HTTPSConnectionNTcCstj|j|jf|j}t|ddrF||_|jtt	ds|j
rjt	j}n	t	j}t	j
||j|jd|dt	jd|j
|_nt	jt	j}tt	dr|jt	jO_|jr|j|j|ji}|j
rKt	j|_|jd|j
tt	d	drK|j|d
<|j
|||_|j
r|jry0t|jj|jtjd|jWn5tk
r|jjtj|jjYnXdS)N_tunnel_hostF
SSLContext	cert_reqsssl_versionca_certsOP_NO_SSLv2cafileHAS_SNIserver_hostnamezHost verified: %s) rcreate_connectionhostporttimeoutr~sock_tunnelr|sslr
CERT_REQUIRED	CERT_NONEwrap_socketkey_file	cert_filePROTOCOL_SSLv23roptionsrload_cert_chainverify_modeload_verify_locationscheck_domainrgetpeercertrrrshutdown	SHUT_RDWRr)rr"rcontextrr-r-r.connects@!	
					


zHTTPSConnection.connect)rrrrr/r4r-r-r-r.rsrc@s7eZdZdddZddZddZdS)	rTcCs#tj|||_||_dS)N)BaseHTTPSHandlerrrr/)rrr/r-r-r.rs
	zHTTPSHandler.__init__cOs4t||}|jr0|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/)rrrr(r-r-r._conn_makers

	zHTTPSHandler._conn_makercCsqy|j|j|SWnStk
rl}z3dt|jkrWtd|jnWYdd}~XnXdS)Nzcertificate verify failedz*Unable to verify server certificate for %s)do_openr6rstrreasonrr)rrYrxr-r-r.
https_openszHTTPSHandler.https_openN)rrrrr6r:r-r-r-r.rsrc@seZdZddZdS)HTTPSOnlyHandlercCstd|dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)rrYr-r-r.	http_openszHTTPSOnlyHandler.http_openN)rrrr<r-r-r-r.r;sr;c@s"eZdZddddZdS)HTTPrNcKs2|dkrd}|j|j|||dS)Nr)_setup_connection_class)rrr rr-r-r.rsz
HTTP.__init__)rrrrr-r-r-r.r?sr?c@s"eZdZddddZdS)HTTPSrNcKs2|dkrd}|j|j|||dS)Nr)r@rA)rrr rr-r-r.rszHTTPS.__init__)rrrrr-r-r-r.rBsrBc@s+eZdZdddZddZdS)	TransportrcCs ||_tjj||dS)N)r!rrCr)rr!use_datetimer-r-r.rs	zTransport.__init__cCs|j|\}}}tdkr<t|d|j}nK|jsY||jdkrz||_|tj|f|_|jd}|S)Nr=r>r!rr)r=r>)
get_host_info	_ver_infor?r!_connection_extra_headersrHTTPConnection)rrhehx509r(r-r-r.make_connections	
zTransport.make_connectionN)rrrrrMr-r-r-r.rCsrCc@s+eZdZdddZddZdS)
SafeTransportrcCs ||_tjj||dS)N)r!rrNr)rr!rDr-r-r.rs	zSafeTransport.__init__cCs|j|\}}}|s$i}|j|d<tdkrRt|d|}nQ|jso||jdkr||_|tj|d|f|_|jd}|S)Nr!r=r>rr)r=r>)rEr!rFrBrGrHrr)rrrJrKrr(r-r-r.rMs
	
zSafeTransport.make_connectionN)rrrrrMr-r-r-r.rN
srNc@seZdZddZdS)ServerProxyc	Ks|jdd|_}|dk	rt|\}}|jdd}|dkr^t}nt}||d||d<}||_tjj	|||dS)Nr!rDrhttps	transport)
rjr!rrrrNrCrQrrOr)	rr\rr!rWr_rDtclsr^r-r-r.r s		zServerProxy.__init__N)rrrrr-r-r-r.rOsrOcKsDtjddkr |d7}nd|d<d|d<t|||S)Nrrbrnewlinezutf-8r)r}rr)rrrr-r-r.	_csv_open4s



rUc@sReZdZdeddeddediZddZd	d
ZdS)CSVBase	delimiterrB	quotechar"lineterminatorrcCs|S)Nr-)rr-r-r.	__enter__FszCSVBase.__enter__cGs|jjdS)N)rr)rrFr-r-r.__exit__IszCSVBase.__exit__N)rrrr8defaultsr[r\r-r-r-r.rV?s
rVc@s:eZdZddZddZddZeZdS)	CSVReadercKsd|krJ|d}tjddkr>tjd|}||_nt|dd|_tj|j|j|_dS)Nrrrzutf-8rdro)	r}rrrrrUcsvrwr])rrrr-r-r.rNs
zCSVReader.__init__cCs|S)Nr-)rr-r-r.__iter__YszCSVReader.__iter__cCset|j}tjddkrax<t|D].\}}t|ts/|jd||<q/W|S)Nrrzutf-8)nextrwr}rrZrrr)rr(r]rr-r-r.ra\szCSVReader.nextN)rrrrr`ra__next__r-r-r-r.r^Msr^c@s(eZdZddZddZdS)	CSVWritercKs1t|d|_tj|j|j|_dS)Nr)rUrr_writerr])rrrr-r-r.rgszCSVWriter.__init__cCsotjddkr[g}x9|D]1}t|trD|jd}|j|q W|}|jj|dS)Nrrzutf-8)r}rrrrr"rdwriterow)rrowrorr-r-r.reks
zCSVWriter.writerowN)rrrrrer-r-r-r.rcfsrccsbeZdZeejZded<dfddZddZdd	Zd
dZ	S)Configuratorinc_convertincNcs/tt|j||p%tj|_dS)N)superrgrrcrro)rconfigro)	__class__r-r.r~szConfigurator.__init__c
sfddjd}t|s?j|}jdd}jdf}|rtfdd|D}fddD}t|}|||}|rx0|jD]"\}}	t|||	qW|S)	Ncst|ttfr=t|fdd|D}njt|trd|krjj|}qi}x4|D]}||||<qwWnj|}|S)Ncsg|]}|qSr-r-)rKr])convertr-r.rMs	zBConfigurator.configure_custom.<locals>.convert.<locals>.<listcomp>z())rr&rtypedictconfigure_customrm)or(r)rmrr-r.rms(
z.Configurator.configure_custom.<locals>.convertz()r/z[]csg|]}|qSr-r-)rKrq)rmr-r.rMs	z1Configurator.configure_custom.<locals>.<listcomp>cs2g|](}t|r||fqSr-)r)rKr)rkrmr-r.rMs	)rjr;r5rrorsetattr)
rrkrpropsrrrr(rgrHr-)rkrmrr.rpszConfigurator.configure_customcCsF|j|}t|trBd|krB|j||j|<}|S)Nz())rkrrorp)rrr(r-r-r.__getitem__s
zConfigurator.__getitem__c	Cs_tjj|s*tjj|j|}tj|ddd}tj|}WdQRX|S)z*Default converter for the inc:// protocol.rorzutf-8N)	rcrdisabsr$rorrrr)rrrr(r-r-r.rhs
zConfigurator.inc_convert)
rrrrorvalue_convertersrrprtrhr-r-)rlr.rgys
rgc@s@eZdZdZddddZddZdd	ZdS)
SubprocessMixinzC
    Mixin for running subprocesses and capturing their output
    FNcCs||_||_dS)N)verboseprogress)rrxryr-r-r.rs	zSubprocessMixin.__init__cCs|j}|j}xr|j}|s(P|dk	rD|||q|s]tjjdntjj|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.
        Nr/zutf-8)	ryrxreadliner}stderrrrflushr)rrr3ryrxr,r-r-r.rws		zSubprocessMixin.readercKstj|dtjdtj|}tjd|jd|jdf}|jtjd|jd|jdf}|j|j	|j
|j
|jdk	r|jddn|jrt
jjd|S)Nstdoutr{rrzdone.mainzdone.
)
subprocessPopenPIPE	threadingThreadrwr}r`r{waitr$ryrxr}r)rcmdrrt1t2r-r-r.run_commands$
$



	zSubprocessMixin.run_command)rrrrrrwrr-r-r-r.rwsrwcCstjdd|jS)z,Normalize a python package name a la PEP 503z[-_.]+r^)rasubr)rNr-r-r.normalize_namesr)rrrrrrr)rrrrrr)r=r>)rcollectionsr
contextlibr_globrrrrloggingrcrrarr$ImportErrorrr}rrrrdummy_threadingrrrcompatrrrr	r
rrr
rrrrrrrrrrrrr	getLoggerrrrrrErDr5r<r9rVr#r>raryrrrrrrcontextmanagerrrrrrrrr5r6VERBOSEr=rrNrPrRrVrYr\Ircr_rhrjrkrqryr{r|r~rrrARCHIVE_EXTENSIONSrrrrrrrrrr5rrrr;rrFr?rBrCrNrOrUrVr^rcrgrwrr-r-r-r.<module>s

Yy
	/
	)
	,H6]+)	7.
Back to Directory File Manager