Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
B

FN†نšÝã@s”dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZddlmZmZddlmZmZmZmZdd	lmZmZmZmZmZmZm Z d
ddd
dgZ!e "e#¡Z$dZ%dZ&deddde%dfZ'dZ(Gdd„de)ƒZ*Gdd„de)ƒZ+Gdd
„d
e)ƒZ,Gdd„de,ƒZ-Gdd„de-ƒZ.Gdd
„d
e-ƒZ/e.Z0e/Z1Gdd„de)ƒZ2d)d!d"„Z3d#d$„Z4d%d&„Z5d'd(„Z6dS)*zPEP 376 implementation.é)Úunicode_literalsNé)ÚDistlibExceptionÚ	resources)ÚStringIO)Ú
get_schemeÚUnsupportedVersionError)ÚMetadataÚMETADATA_FILENAMEÚWHEEL_METADATA_FILENAMEÚLEGACY_METADATA_FILENAME)Úparse_requirementÚcached_propertyÚparse_name_and_versionÚread_exportsÚ
write_exportsÚ	CSVReaderÚ	CSVWriterÚDistributionÚBaseInstalledDistributionÚInstalledDistributionÚEggInfoDistributionÚDistributionPathzpydist-exports.jsonzpydist-commands.jsonÚ	INSTALLERÚRECORDÚ	REQUESTEDÚ	RESOURCESÚSHAREDz
.dist-infoc@s(eZdZdZdd„Zdd„Zdd„ZdS)	Ú_CachezL
    A simple cache mapping names and .dist-info paths to distributions
    cCsi|_i|_d|_dS)zZ
        Initialise an instance. There is normally one for each DistributionPath.
        FN)ÚnameÚpathÚ	generated)Úself©r#úŽ/build/wlanpi-profiler-SHjkbd/wlanpi-profiler-1.0.8/debian/wlanpi-profiler/opt/wlanpi-profiler/lib/python3.7/site-packages/distlib/database.pyÚ__init__1sz_Cache.__init__cCs|j ¡|j ¡d|_dS)zC
        Clear the cache, setting it to its initial state.
        FN)rÚclearr r!)r"r#r#r$r&9s

z_Cache.clearcCs2|j|jkr.||j|j<|j |jg¡ |¡dS)z`
        Add a distribution to the cache.
        :param dist: The distribution to add.
        N)r rÚ
setdefaultÚkeyÚappend)r"Údistr#r#r$ÚaddAsz
_Cache.addN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%r&r+r#r#r#r$r-src@s„eZdZdZddd„Zdd„Zdd	„ZeeeƒZd
d„Z	dd
„Z
dd„Zedd„ƒZ
dd„Zdd„Zddd„Zdd„Zddd„ZdS)rzU
    Represents a set of distributions installed on a path (typically sys.path).
    NFcCsD|dkrtj}||_d|_||_tƒ|_tƒ|_d|_tdƒ|_	dS)a 
        Create an instance from a path, optionally including legacy (distutils/
        setuptools/distribute) distributions.
        :param path: The path to use, as a list of directories. If not specified,
                     sys.path is used.
        :param include_egg: If True, this instance will look for and return legacy
                            distributions as well as those based on PEP 376.
        NTÚdefault)
Úsysr Ú
_include_distÚ_include_eggrÚ_cacheÚ
_cache_eggÚ_cache_enabledrÚ_scheme)r"r Zinclude_eggr#r#r$r%Os	zDistributionPath.__init__cCs|jS)N)r6)r"r#r#r$Ú_get_cache_enabledcsz#DistributionPath._get_cache_enabledcCs
||_dS)N)r6)r"Úvaluer#r#r$Ú_set_cache_enabledfsz#DistributionPath._set_cache_enabledcCs|j ¡|j ¡dS)z,
        Clears the internal cache.
        N)r4r&r5)r"r#r#r$Úclear_cacheks
zDistributionPath.clear_cachec
csRtƒ}xD|jD]8}t |¡}|dkr*q| d¡}|r|js@qt|jƒ}xü|D]ô}| |¡}|rR|j|krpqR|jr| t	¡rt
ttg}x*|D] }t
 ||¡}	| |	¡}
|
r”Pq”WqRt |
 ¡¡}t|dd}WdQRXt d|j¡| |j¡t|j||dVqR|jrR| d¡rRt d|j¡| |j¡t|j|ƒVqRWqWdS)zD
        Yield .dist-info and/or .egg(-info) distributions.
        NÚÚlegacy)ÚfileobjÚschemezFound %s)ÚmetadataÚenv)z	.egg-infoz.egg)Úsetr rÚfinder_for_pathÚfindÚis_containerÚsortedr2ÚendswithÚDISTINFO_EXTr
rrÚ	posixpathÚjoinÚ
contextlibÚclosingÚ	as_streamr	ÚloggerÚdebugr+Únew_dist_classr3Úold_dist_class)
r"Úseenr ÚfinderÚrZrsetÚentryZpossible_filenamesZmetadata_filenameZ
metadata_pathZpydistÚstreamr@r#r#r$Ú_yield_distributionsssB






z%DistributionPath._yield_distributionscCst|jj}|jo|jj}|s"|rpx4| ¡D](}t|tƒrH|j |¡q,|j |¡q,W|rdd|j_|rpd|j_dS)zk
        Scan the path for distributions and populate the cache with
        those that are found.
        TN)r4r!r3r5rWÚ
isinstancerr+)r"Zgen_distZgen_eggr*r#r#r$Ú_generate_cacheŸs

z DistributionPath._generate_cachecCs| dd¡}d ||g¡tS)ao
        The *name* and *version* parameters are converted into their
        filename-escaped form, i.e. any ``'-'`` characters are replaced
        with ``'_'`` other than the one in ``'dist-info'`` and the one
        separating the name from the version number.

        :parameter name: is converted to a standard distribution name by replacing
                         any runs of non- alphanumeric characters with a single
                         ``'-'``.
        :type name: string
        :parameter version: is converted to a standard version string. Spaces
                            become dots, and all other non-alphanumeric characters
                            (except dots) become dashes, with runs of multiple
                            dashes condensed to a single dash.
        :type version: string
        :returns: directory name
        :rtype: stringú-Ú_)ÚreplacerJrH)ÚclsrÚversionr#r#r$Údistinfo_dirname²sz!DistributionPath.distinfo_dirnameccsj|js x^| ¡D]
}|VqWnF| ¡x|jj ¡D]
}|Vq6W|jrfx|jj ¡D]
}|VqXWdS)a5
        Provides an iterator that looks for distributions and returns
        :class:`InstalledDistribution` or
        :class:`EggInfoDistribution` instances for each one of them.

        :rtype: iterator of :class:`InstalledDistribution` and
                :class:`EggInfoDistribution` instances
        N)r6rWrYr4r Úvaluesr3r5)r"r*r#r#r$Úget_distributionsÈs	
z"DistributionPath.get_distributionscCs‚d}| ¡}|js6xj| ¡D]}|j|kr|}PqWnH| ¡||jjkr\|jj|d}n"|jr~||jjkr~|jj|d}|S)a=
        Looks for a named distribution on the path.

        This function only returns the first result found, as no more than one
        value is expected. If nothing is found, ``None`` is returned.

        :rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution`
                or ``None``
        Nr)	Úlowerr6rWr(rYr4rr3r5)r"rÚresultr*r#r#r$Úget_distributionÞs

z!DistributionPath.get_distributionc	csÌd}|dk	rJy|j d||f¡}Wn$tk
rHtd||fƒ‚YnXx|| ¡D]p}t|dƒspt d|¡qT|j}xL|D]D}t	|ƒ\}}|dkr¦||krÀ|VPq|||kr|| 
|¡r||VPq|WqTWdS)a
        Iterates over all distributions to find which distributions provide *name*.
        If a *version* is provided, it will be used to filter the results.

        This function only returns the first result found, since no more than
        one values are expected. If the directory is not found, returns ``None``.

        :parameter version: a version specifier that indicates the version
                            required, conforming to the format in ``PEP-345``

        :type name: string
        :type version: string
        Nz%s (%s)zinvalid name or version: %r, %rÚprovideszNo "provides": %s)r7ÚmatcherÚ
ValueErrorrraÚhasattrrNrOrerÚmatch)	r"rr^rfr*ÚprovidedÚpÚp_nameÚp_verr#r#r$Úprovides_distributionøs(

z&DistributionPath.provides_distributioncCs(| |¡}|dkrtd|ƒ‚| |¡S)z5
        Return the path to a resource file.
        Nzno distribution named %r found)rdÚLookupErrorÚget_resource_path)r"rÚ
relative_pathr*r#r#r$Ú
get_file_path!s
zDistributionPath.get_file_pathccs`xZ| ¡D]N}|j}||kr
||}|dk	r@||krX||Vq
x| ¡D]
}|VqJWq
WdS)zÙ
        Return all of the exported entries in a particular category.

        :param category: The category to search for entries.
        :param name: If specified, only entries with that name are returned.
        N)raÚexportsr`)r"Úcategoryrr*rTÚdÚvr#r#r$Úget_exported_entries*sz%DistributionPath.get_exported_entries)NF)N)N)r,r-r.r/r%r8r:ÚpropertyZ
cache_enabledr;rWrYÚclassmethodr_rardrnrrrwr#r#r#r$rKs

,
)	c@s¬eZdZdZdZdZdd„Zedd„ƒZeZ	edd„ƒZ
ed	d
„ƒZdd„Zed
d„ƒZ
edd„ƒZedd„ƒZedd„ƒZedd„ƒZdd„Zdd„Zdd„Zdd„ZdS) rzª
    A base class for distributions, whether installed or from indexes.
    Either way, it must have some metadata, so that's all that's needed
    for construction.
    FcCsL||_|j|_|j ¡|_|j|_d|_d|_d|_d|_t	ƒ|_
i|_dS)zŠ
        Initialise an instance.
        :param metadata: The instance of :class:`Metadata` describing this
        distribution.
        N)r@rrbr(r^ÚlocatorÚdigestÚextrasÚcontextrBZ
download_urlsÚdigests)r"r@r#r#r$r%OszDistribution.__init__cCs|jjS)zH
        The source archive download URL for this distribution.
        )r@Ú
source_url)r"r#r#r$r`szDistribution.source_urlcCsd|j|jfS)zX
        A utility property which displays the name and version in parentheses.
        z%s (%s))rr^)r"r#r#r$Úname_and_versioniszDistribution.name_and_versioncCs.|jj}d|j|jf}||kr*| |¡|S)z
        A set of distribution names and versions provided by this distribution.
        :return: A set of "name (version)" strings.
        z%s (%s))r@rerr^r))r"ÚplistÚsr#r#r$reps

zDistribution.providescCs8|j}t d| ¡¡t||ƒ}t|j||j|jdƒS)Nz%Getting requirements from metadata %r)r|rA)	r@rNrOZtodictÚgetattrrBÚget_requirementsr|r})r"Zreq_attrÚmdZreqtsr#r#r$Ú_get_requirements|s

zDistribution._get_requirementscCs
| d¡S)NÚrun_requires)r†)r"r#r#r$r‡ƒszDistribution.run_requirescCs
| d¡S)NÚ
meta_requires)r†)r"r#r#r$rˆ‡szDistribution.meta_requirescCs
| d¡S)NÚbuild_requires)r†)r"r#r#r$r‰‹szDistribution.build_requirescCs
| d¡S)NÚ
test_requires)r†)r"r#r#r$rŠszDistribution.test_requirescCs
| d¡S)NÚdev_requires)r†)r"r#r#r$r‹“szDistribution.dev_requiresc
	Cs¶t|ƒ}t|jjƒ}y| |j¡}Wn6tk
rZt d|¡| 	¡d}| |¡}YnX|j
}d}xJ|jD]@}t|ƒ\}}	||krˆqny| 
|	¡}PWqntk
r¬YqnXqnW|S)z¿
        Say if this instance matches (fulfills) a requirement.
        :param req: The requirement to match.
        :rtype req: str
        :return: True if it matches, else False.
        z+could not read version %r - using name onlyrF)r
rr@r?rfÚrequirementrrNÚwarningÚsplitr(rerri)
r"ÚreqrTr?rfrrcrkrlrmr#r#r$Úmatches_requirement—s*	

z Distribution.matches_requirementcCs(|jrd|j}nd}d|j|j|fS)zC
        Return a textual representation of this instance,
        z [%s]r<z<Distribution %s (%s)%s>)rrr^)r"Úsuffixr#r#r$Ú__repr__¹szDistribution.__repr__cCs>t|ƒt|ƒk	rd}n$|j|jko8|j|jko8|j|jk}|S)a<
        See if this distribution is the same as another.
        :param other: The distribution to compare with. To be equal to one
                      another. distributions must have the same type, name,
                      version and source_url.
        :return: True if it is the same, else False.
        F)Útyperr^r)r"Úotherrcr#r#r$Ú__eq__ÃszDistribution.__eq__cCst|jƒt|jƒt|jƒS)zH
        Compute hash in a way which matches the equality test.
        )Úhashrr^r)r"r#r#r$Ú__hash__ÓszDistribution.__hash__N)r,r-r.r/Zbuild_time_dependencyÚ	requestedr%rxrÚdownload_urlr€rer†r‡rˆr‰rŠr‹rr’r•r—r#r#r#r$r=s$"
cs0eZdZdZdZd‡fdd„	Zddd„Z‡ZS)	rz]
    This is the base class for installed distributions (whether PEP 376 or
    legacy).
    Ncs tt|ƒ |¡||_||_dS)a
        Initialise an instance.
        :param metadata: An instance of :class:`Metadata` which describes the
                         distribution. This will normally have been initialised
                         from a metadata file in the ``path``.
        :param path:     The path of the ``.dist-info`` or ``.egg-info``
                         directory for the distribution.
        :param env:      This is normally the :class:`DistributionPath`
                         instance where this distribution was found.
        N)Úsuperrr%r Ú	dist_path)r"r@r rA)Ú	__class__r#r$r%âsz"BaseInstalledDistribution.__init__cCsd|dkr|j}|dkr"tj}d}ntt|ƒ}d|j}||ƒ ¡}t |¡ d¡ d¡}d||fS)a”
        Get the hash of some data, using a particular hash algorithm, if
        specified.

        :param data: The data to be hashed.
        :type data: bytes
        :param hasher: The name of a hash implementation, supported by hashlib,
                       or ``None``. Examples of valid values are ``'sha1'``,
                       ``'sha224'``, ``'sha384'``, '``sha256'``, ``'md5'`` and
                       ``'sha512'``. If no hasher is specified, the ``hasher``
                       attribute of the :class:`InstalledDistribution` instance
                       is used. If the hasher is determined to be ``None``, MD5
                       is used as the hashing algorithm.
        :returns: The hash of the data. If a hasher was explicitly specified,
                  the returned hash will be prefixed with the specified hasher
                  followed by '='.
        :rtype: str
        Nr<z%s=ó=Úasciiz%s%s)	ÚhasherÚhashlibÚmd5rƒr{Úbase64Úurlsafe_b64encodeÚrstripÚdecode)r"ÚdatarŸÚprefixr{r#r#r$Úget_hashñs

z"BaseInstalledDistribution.get_hash)N)N)r,r-r.r/rŸr%r¨Ú
__classcell__r#r#)rœr$rÚscs¸eZdZdZdZd'‡fdd„	Zdd„Zdd	„Zd
d„Ze	dd
„ƒZ
dd„Zdd„Zdd„Z
dd„Zd(dd„Zdd„Ze	dd„ƒZd)dd„Zdd „Zd!d"„Zd#d$„Zd%d&„ZejZ‡ZS)*ra
    Created with the *path* of the ``.dist-info`` directory provided to the
    constructor. It reads the metadata contained in ``pydist.json`` when it is
    instantiated., or uses a passed in Metadata instance (useful for when
    dry-run mode is being used).
    Úsha256Nc
	sPg|_t |¡|_}|dkr*td|ƒ‚|rP|jrP||jjkrP|jj|j}nt|dkrÄ| 	t
¡}|dkrt| 	t¡}|dkr†| 	t¡}|dkržtdt
|fƒ‚t
 | ¡¡}t|dd}WdQRXtt|ƒ |||¡|rî|jrî|j |¡| 	d¡}|dk	|_tj |d¡}tj |¡rLt|dƒ}| ¡ d¡}	WdQRX|	 ¡|_dS)	Nzfinder unavailable for %szno %s found in %sr=)r>r?rz
top_level.txtÚrbzutf-8)ÚmodulesrrCrSrgr6r4r r@rDr
rrrKrLrMr	ršrr%r+r˜ÚosrJÚexistsÚopenÚreadr¥Ú
splitlines)
r"r r@rArSrTrVrkÚfr¦)rœr#r$r%s6






zInstalledDistribution.__init__cCsd|j|j|jfS)Nz#<InstalledDistribution %r %s at %r>)rr^r )r"r#r#r$r’=szInstalledDistribution.__repr__cCsd|j|jfS)Nz%s %s)rr^)r"r#r#r$Ú__str__AszInstalledDistribution.__str__c

Cs†g}| d¡}t | ¡¡`}t|dJ}xB|D]:}dd„tt|ƒdƒDƒ}||\}}}	| |||	f¡q0WWdQRXWdQRX|S)a"
        Get the list of installed files for the distribution
        :return: A list of tuples of path, hash and size. Note that hash and
                 size might be ``None`` for some entries. The path is exactly
                 as stored in the file (which is as in PEP 376).
        r)rVcSsg|]}d‘qS)Nr#)Ú.0Úir#r#r$ú
<listcomp>Ssz6InstalledDistribution._get_records.<locals>.<listcomp>éN)Úget_distinfo_resourcerKrLrMrÚrangeÚlenr))
r"ÚresultsrTrVZ
record_readerÚrowÚmissingr ÚchecksumÚsizer#r#r$Ú_get_recordsDs

(z"InstalledDistribution._get_recordscCsi}| t¡}|r| ¡}|S)a
        Return the information exported by this distribution.
        :return: A dictionary of exports, mapping an export category to a dict
                 of :class:`ExportEntry` instances describing the individual
                 export entries, and keyed by name.
        )r¸ÚEXPORTS_FILENAMEr)r"rcrTr#r#r$rs[s

zInstalledDistribution.exportsc	Cs8i}| t¡}|r4t | ¡¡}t|ƒ}WdQRX|S)zý
        Read exports data from a file in .ini format.

        :return: A dictionary of exports, mapping an export category to a list
                 of :class:`ExportEntry` instances describing the individual
                 export entries.
        N)r¸rÁrKrLrMr)r"rcrTrVr#r#r$ris
z"InstalledDistribution.read_exportsc	Cs.| t¡}t|dƒ}t||ƒWdQRXdS)a
        Write a dictionary of exports to a file in .ini format.
        :param exports: A dictionary of exports, mapping an export category to
                        a list of :class:`ExportEntry` instances describing the
                        individual export entries.
        ÚwN)Úget_distinfo_filerÁr¯r)r"rsÚrfr²r#r#r$rxs
z#InstalledDistribution.write_exportsc
Csh| d¡}t | ¡¡:}t|d$}x|D]\}}||kr,|Sq,WWdQRXWdQRXtd|ƒ‚dS)aW
        NOTE: This API may change in the future.

        Return the absolute path to a resource file with the given relative
        path.

        :param relative_path: The path, relative to .dist-info, of the resource
                              of interest.
        :return: The absolute path where the resource is to be found.
        r)rVNz3no resource file with relative path %r is installed)r¸rKrLrMrÚKeyError)r"rqrTrVZresources_readerÚrelativeÚdestinationr#r#r$rpƒs
z'InstalledDistribution.get_resource_pathccsx| ¡D]
}|Vq
WdS)zª
        Iterates over the ``RECORD`` entries and returns a tuple
        ``(path, hash, size)`` for each line.

        :returns: iterator of (path, hash, size)
        N)rÀ)r"rcr#r#r$Úlist_installed_files—sz*InstalledDistribution.list_installed_filesFcCs,tj |d¡}tj |j¡}| |¡}tj |d¡}| d¡}t d|¡|rRdSt|ƒÈ}x–|D]Ž}tj 	|¡s|| 
d¡r†d}	}
n4dtj |¡}
t|dƒ}| 
| ¡¡}	WdQRX| |¡sÒ|rà| |¡ràtj ||¡}| ||	|
f¡qbW| |¡rtj ||¡}| |ddf¡WdQRX|S)zÖ
        Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
        existing ``RECORD`` file is silently overwritten.

        prefix is used to determine when to write absolute paths.
        r<rzcreating %sN)z.pycz.pyoz%dr«)r­r rJÚdirnameÚ
startswithrÃrNÚinforÚisdirrGÚgetsizer¯r¨r°ÚrelpathÚwriterow)r"Úpathsr§Údry_runÚbaseZbase_under_prefixÚrecord_pathÚwriterr Ú
hash_valuer¿Úfpr#r#r$Úwrite_installed_files¡s.





z+InstalledDistribution.write_installed_filesc
Csg}tj |j¡}| d¡}xú| ¡D]î\}}}tj |¡sJtj ||¡}||krTq&tj |¡st| |dddf¡q&tj 	|¡r&t
tj |¡ƒ}|r°||kr°| |d||f¡q&|r&d|krÎ| dd¡d}nd	}t
|d
ƒ2}	| |	 ¡|¡}
|
|kr
| |d||
f¡Wd	QRXq&W|S)a¨
        Checks that the hashes and sizes of the files in ``RECORD`` are
        matched by the files themselves. Returns a (possibly empty) list of
        mismatches. Each entry in the mismatch list will be a tuple consisting
        of the path, 'exists', 'size' or 'hash' according to what didn't match
        (existence is checked first, then size, then hash), the expected
        value and the actual value.
        rr®TFr¿ú=rrNr«r–)r­r rÉrÃrÈÚisabsrJr®r)ÚisfileÚstrrÍrŽr¯r¨r°)r"Ú
mismatchesrÒrÓr rÕr¿Zactual_sizerŸr²Zactual_hashr#r#r$Úcheck_installed_filesÄs.	

 z+InstalledDistribution.check_installed_filesc	CsŽi}tj |jd¡}tj |¡rŠtj|ddd}| ¡ ¡}WdQRXx@|D]8}| dd¡\}}|dkr~| 	|g¡ 
|¡qN|||<qNW|S)	a 
        A dictionary of shared locations whose keys are in the set 'prefix',
        'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
        The corresponding value is the absolute path of that category for
        this distribution, and takes into account any paths selected by the
        user at installation time (e.g. via command-line arguments). In the
        case of the 'namespace' key, this would be a list of absolute paths
        for the roots of namespace packages in this distribution.

        The first time this property is accessed, the relevant information is
        read from the SHARED file in the .dist-info directory.
        rrTzutf-8)ÚencodingNrØrÚ	namespace)r­r rJrÚÚcodecsr¯r°r±rŽr'r))r"rcÚshared_pathr²ÚlinesÚliner(r9r#r#r$Úshared_locationsçs
z&InstalledDistribution.shared_locationsc		Cs´tj |jd¡}t d|¡|r$dSg}x6dD].}||}tj ||¡r.| d||f¡q.Wx"| dd¡D]}| d|¡qnWtj	|d	d
d}| 
d |¡¡WdQRX|S)
aa
        Write shared location information to the SHARED file in .dist-info.
        :param paths: A dictionary as described in the documentation for
        :meth:`shared_locations`.
        :param dry_run: If True, the action is logged but no file is actually
                        written.
        :return: The path of the file written to.
        rzcreating %sN)r§ÚlibÚheadersÚscriptsr¦z%s=%srßr#znamespace=%srÂzutf-8)rÞÚ
)r­r rJrNrËrÌr)Úgetràr¯Úwrite)	r"rÐrÑrárâr(r Únsr²r#r#r$Úwrite_shared_locationss	
z,InstalledDistribution.write_shared_locationscCsF|tkrtd||jfƒ‚t |j¡}|dkr<td|jƒ‚| |¡S)Nz+invalid path for a dist-info file: %r at %rzUnable to get a finder for %s)Ú
DIST_FILESrr rrCrD)r"r rSr#r#r$r¸sz+InstalledDistribution.get_distinfo_resourcecCs~| tj¡dkrT| tj¡dd…\}}||j tj¡dkrTtd||j|jfƒ‚|tkrntd||jfƒ‚tj 	|j|¡S)aû
        Returns a path located under the ``.dist-info`` directory. Returns a
        string representing the path.

        :parameter path: a ``'/'``-separated path relative to the
                         ``.dist-info`` directory or an absolute path;
                         If *path* is an absolute path and doesn't start
                         with the ``.dist-info`` directory path,
                         a :class:`DistlibException` is raised
        :type path: str
        :rtype: str
        réþÿÿÿNéÿÿÿÿz;dist-info file %r does not belong to the %r %s distributionz+invalid path for a dist-info file: %r at %r)
rDr­ÚseprŽr rrr^rírJ)r"r r_r#r#r$rÃ$sz'InstalledDistribution.get_distinfo_fileccsVtj |j¡}xB| ¡D]6\}}}tj |¡s<tj ||¡}| |j¡r|VqWdS)zó
        Iterates over the ``RECORD`` entries and returns paths for each line if
        the path is pointing to a file located in the ``.dist-info`` directory
        or one of its subdirectories.

        :returns: iterator of paths
        N)r­r rÉrÀrÙrJrÊ)r"rÒr r¾r¿r#r#r$Úlist_distinfo_filesAsz)InstalledDistribution.list_distinfo_filescCst|tƒo|j|jkS)N)rXrr )r"r”r#r#r$r•Qs
zInstalledDistribution.__eq__)NN)F)F)r,r-r.r/rŸr%r’r³rÀrrsrrrprÈr×rÝrärìr¸rÃrñr•Úobjectr—r©r#r#)rœr$rs("

##
	csjeZdZdZdZiZd‡fdd„	Zdd„Zdd	„Zd
d„Z	dd
„Z
dd„Zddd„Zdd„Z
ejZ‡ZS)raCreated with the *path* of the ``.egg-info`` directory or file provided
    to the constructor. It reads the metadata contained in the file itself, or
    if the given path happens to be a directory, the metadata is read from the
    file ``PKG-INFO`` under that directory.TNcs’dd„}||_||_|rJ|jrJ||jjkrJ|jj|j}|||j|jƒn0| |¡}|||j|jƒ|rz|jrz|j |¡t	t
|ƒ |||¡dS)NcSs||_| ¡|_||_dS)N)rrbr(r^)r‚Únrvr#r#r$Úset_name_and_versioncs
z:EggInfoDistribution.__init__.<locals>.set_name_and_version)r r›r6r5r@rr^Ú
_get_metadatar+ršrr%)r"r rArôr@)rœr#r$r%bs

zEggInfoDistribution.__init__c	sÐd}dd„‰‡fdd„}d}}| d¡rötj |¡r„tj |d¡}tj |d¡}t|dd	}tj |d
¡}	tj |d¡}||	ƒ}npt |¡}
t|
 	d¡ 
d
¡ƒ}t|dd}y,|
 	d¡}|
 	d¡ 
d¡}ˆ| 
d¡ƒ}Wntk
ròd}YnXnf| d¡rPtj |¡rBtj |d
¡}	||	ƒ}tj |d¡}tj |d¡}t|dd	}ntd|ƒ‚|rl| 
|¡|dkr²|dk	r²tj |¡r²t|dƒ}
|
 ¡ 
d¡}WdQRX|s¾g}n| ¡}||_|S)NcSs¦g}| ¡}x”|D]Œ}| ¡}| d¡r6t d|¡Pt|ƒ}|sPt d|¡q|jr`t d¡|jst| |j	¡qd 
dd„|jDƒ¡}| d|j	|f¡qW|S)	z’Create a list of dependencies from a requires.txt file.

            *data*: the contents of a setuptools-produced requires.txt file.
            ú[z.Unexpected line: quitting requirement scan: %rz#Not recognised as a requirement: %rz4extra requirements in requires.txt are not supportedz, css|]}d|VqdS)z%s%sNr#)r´Úcr#r#r$ú	<genexpr>‘szQEggInfoDistribution._get_metadata.<locals>.parse_requires_data.<locals>.<genexpr>z%s (%s))r±ÚstriprÊrNrr
r|Úconstraintsr)rrJ)r¦ÚreqsrârãrTZconsr#r#r$Úparse_requires_datazs&


z>EggInfoDistribution._get_metadata.<locals>.parse_requires_datac	sHg}y*t |dd¡}ˆ| ¡ƒ}WdQRXWntk
rBYnX|S)z’Create a list of dependencies from a requires.txt file.

            *req_path*: the path to a setuptools-produced requires.txt file.
            rTzutf-8N)ràr¯r°ÚIOError)Úreq_pathrûrÖ)rür#r$Úparse_requires_path•sz>EggInfoDistribution._get_metadata.<locals>.parse_requires_pathz.eggzEGG-INFOzPKG-INFOr=)r r?zrequires.txtz
top_level.txtzEGG-INFO/PKG-INFOÚutf8)r>r?zEGG-INFO/requires.txtzEGG-INFO/top_level.txtzutf-8z	.egg-infoz,path must end with .egg-info or .egg, got %rr«)rGr­r rÌrJr	Ú	zipimportÚzipimporterrÚget_datar¥rýrZadd_requirementsr®r¯r°r±r¬)r"r ÚrequiresrÿZtl_pathZtl_datarkÚ	meta_pathr@rþZzipfr>r¦r²r#)rür$rõwsT





z!EggInfoDistribution._get_metadatacCsd|j|j|jfS)Nz!<EggInfoDistribution %r %s at %r>)rr^r )r"r#r#r$r’ÑszEggInfoDistribution.__repr__cCsd|j|jfS)Nz%s %s)rr^)r"r#r#r$r³ÕszEggInfoDistribution.__str__cCsdg}tj |jd¡}tj |¡r`x>| ¡D]2\}}}||kr>q*tj |¡s*| |dddf¡q*W|S)a¨
        Checks that the hashes and sizes of the files in ``RECORD`` are
        matched by the files themselves. Returns a (possibly empty) list of
        mismatches. Each entry in the mismatch list will be a tuple consisting
        of the path, 'exists', 'size' or 'hash' according to what didn't match
        (existence is checked first, then size, then hash), the expected
        value and the actual value.
        zinstalled-files.txtr®TF)r­r rJr®rÈr))r"rÜrÓr r[r#r#r$rÝØs	z)EggInfoDistribution.check_installed_filesc	CsÖdd„}dd„}tj |jd¡}g}tj |¡rÒtj|ddd|}xt|D]l}| ¡}tj tj |j|¡¡}tj |¡st 	d	|¡| 
d
¡rqHtj |¡sH| |||ƒ||ƒf¡qHWWdQRX| |ddf¡|S)zµ
        Iterates over the ``installed-files.txt`` entries and returns a tuple
        ``(path, hash, size)`` for each line.

        :returns: a list of (path, hash, size)
        cSs0t|dƒ}z| ¡}Wd| ¡Xt |¡ ¡S)Nr«)r¯r°Úcloser r¡Ú	hexdigest)r r²Úcontentr#r#r$Ú_md5ós


z6EggInfoDistribution.list_installed_files.<locals>._md5cSst |¡jS)N)r­ÚstatÚst_size)r r#r#r$Ú_sizeûsz7EggInfoDistribution.list_installed_files.<locals>._sizezinstalled-files.txtrTzutf-8)rÞzNon-existent file: %s)z.pycz.pyoN)
r­r rJr®ràr¯rùÚnormpathrNrrGrÌr))r"r	rrÓrcr²rãrkr#r#r$rÈës"

&z(EggInfoDistribution.list_installed_filesFc	csžtj |jd¡}tj |¡ršd}tj|dddd}x\|D]T}| ¡}|dkrRd}q8|s8tj tj |j|¡¡}| |j¡r8|r†|Vq8|Vq8WWdQRXdS)	a
        Iterates over the ``installed-files.txt`` entries and returns paths for
        each line if the path is pointing to a file located in the
        ``.egg-info`` directory or one of its subdirectories.

        :parameter absolute: If *absolute* is ``True``, each returned path is
                          transformed into a local absolute path. Otherwise the
                          raw value from ``installed-files.txt`` is returned.
        :type absolute: boolean
        :returns: iterator of paths
        zinstalled-files.txtTrTzutf-8)rÞz./FN)	r­r rJr®ràr¯rùr
rÊ)r"ÚabsoluterÓÚskipr²rãrkr#r#r$rñs
z'EggInfoDistribution.list_distinfo_filescCst|tƒo|j|jkS)N)rXrr )r"r”r#r#r$r•.s
zEggInfoDistribution.__eq__)N)F)r,r-r.r/r˜rär%rõr’r³rÝrÈrñr•ròr—r©r#r#)rœr$rYsZ&
c@s^eZdZdZdd„Zdd„Zddd„Zd	d
„Zdd„Zddd„Z	ddd„Z
dd„Zdd„ZdS)ÚDependencyGraphaù
    Represents a dependency graph between distributions.

    The dependency relationships are stored in an ``adjacency_list`` that maps
    distributions to a list of ``(other, label)`` tuples where  ``other``
    is a distribution and the edge is labeled with ``label`` (i.e. the version
    specifier, if such was provided). Also, for more efficient traversal, for
    every distribution ``x``, a list of predecessors is kept in
    ``reverse_list[x]``. An edge from distribution ``a`` to
    distribution ``b`` means that ``a`` depends on ``b``. If any missing
    dependencies are found, they are stored in ``missing``, which is a
    dictionary that maps distributions to a list of requirements that were not
    provided by any other distributions.
    cCsi|_i|_i|_dS)N)Úadjacency_listÚreverse_listr½)r"r#r#r$r%IszDependencyGraph.__init__cCsg|j|<g|j|<dS)zÍAdd the *distribution* to the graph.

        :type distribution: :class:`distutils2.database.InstalledDistribution`
                            or :class:`distutils2.database.EggInfoDistribution`
        N)rr)r"Údistributionr#r#r$Úadd_distributionNs
z DependencyGraph.add_distributionNcCs6|j| ||f¡||j|kr2|j| |¡dS)ašAdd an edge from distribution *x* to distribution *y* with the given
        *label*.

        :type x: :class:`distutils2.database.InstalledDistribution` or
                 :class:`distutils2.database.EggInfoDistribution`
        :type y: :class:`distutils2.database.InstalledDistribution` or
                 :class:`distutils2.database.EggInfoDistribution`
        :type label: ``str`` or ``None``
        N)rr)r)r"ÚxÚyÚlabelr#r#r$Úadd_edgeXs
zDependencyGraph.add_edgecCs&t d||¡|j |g¡ |¡dS)a
        Add a missing *requirement* for the given *distribution*.

        :type distribution: :class:`distutils2.database.InstalledDistribution`
                            or :class:`distutils2.database.EggInfoDistribution`
        :type requirement: ``str``
        z
%s missing %rN)rNrOr½r'r))r"rrŒr#r#r$Úadd_missinggszDependencyGraph.add_missingcCsd|j|jfS)Nz%s %s)rr^)r"r*r#r#r$Ú
_repr_distrszDependencyGraph._repr_distrcCsŽ| |¡g}xv|j|D]h\}}| |¡}|dk	r>d||f}| d|t|ƒ¡| ||d¡}| d¡}| |dd…¡qWd |¡S)zPrints only a subgraphNz%s [%s]z    rrè)rrr)rÛÚ	repr_noderŽÚextendrJ)r"r*ÚlevelÚoutputr”rZ	suboutputÚsubsr#r#r$rus

zDependencyGraph.repr_nodeTcCsøg}| d¡xz|j ¡D]l\}}t|ƒdkr<|s<| |¡xH|D]@\}}|dk	rl| d|j|j|f¡qB| d|j|jf¡qBWqW|sêt|ƒdkrê| d¡| d¡| d¡x&|D]}| d	|j¡| d
¡q¾W| d¡| d¡dS)a9Writes a DOT output for the graph to the provided file *f*.

        If *skip_disconnected* is set to ``True``, then all distributions
        that are not dependent on any other distribution are skipped.

        :type f: has to support ``file``-like operations
        :type skip_disconnected: ``bool``
        zdigraph dependencies {
rNz"%s" -> "%s" [label="%s"]
z
"%s" -> "%s"
zsubgraph disconnected {
zlabel = "Disconnected"
zbgcolor = red
z"%s"rèz}
)rêrÚitemsrºr)r)r"r²Zskip_disconnectedÚdisconnectedr*Úadjsr”rr#r#r$Úto_dot‚s&	






zDependencyGraph.to_dotcsÒg}i}x&|j ¡D]\}}|dd…||<qWxg‰x4t| ¡ƒdd…D]\}}|sLˆ |¡||=qLWˆsrPx*| ¡D]\}}‡fdd„|Dƒ||<q|Wt ddd„ˆDƒ¡| ˆ¡q2W|t| ¡ƒfS)aa
        Perform a topological sort of the graph.
        :return: A tuple, the first element of which is a topologically sorted
                 list of distributions, and the second element of which is a
                 list of distributions that cannot be sorted because they have
                 circular dependencies and so form a cycle.
        Ncs g|]\}}|ˆkr||f‘qSr#r#)r´rurT)Ú	to_remover#r$r¶»sz4DependencyGraph.topological_sort.<locals>.<listcomp>zMoving to result: %scSsg|]}d|j|jf‘qS)z%s (%s))rr^)r´rur#r#r$r¶½s)rr Úlistr)rNrOrÚkeys)r"rcÚalistÚkrvr#)r$r$Útopological_sort¢s$

z DependencyGraph.topological_sortcCs6g}x&|j ¡D]\}}| | |¡¡qWd |¡S)zRepresentation of the graphrè)rr r)rrJ)r"rr*r"r#r#r$r’ÁszDependencyGraph.__repr__)N)r)T)
r,r-r.r/r%rrrrrr#r)r’r#r#r#r$r9s



 rr0cCsft|ƒ}tƒ}i}xX|D]P}| |¡x@|jD]6}t|ƒ\}}t d|||¡| |g¡ ||f¡q.WqWxô|D]ì}|j	|j
B|jB|jB}xÎ|D]Æ}	y| 
|	¡}
Wn6tk
rÜt d|	¡|	 ¡d}| 
|¡}
YnX|
j}d}||krJxV||D]J\}}y|
 |¡}
Wntk
r,d}
YnX|
rü| |||	¡d}PqüW|s”| ||	¡q”WqrW|S)a6Makes a dependency graph from the given distributions.

    :parameter dists: a list of distributions
    :type dists: list of :class:`distutils2.database.InstalledDistribution` and
                 :class:`distutils2.database.EggInfoDistribution` instances
    :rtype: a :class:`DependencyGraph` instance
    zAdd to provided: %s, %s, %sz+could not read version %r - using name onlyrFT)rrrrerrNrOr'r)r‡rˆr‰r‹rfrrrŽr(rirr)Údistsr?Úgraphrjr*rkrr^rrrfÚmatchedÚproviderrir#r#r$Ú
make_graphÉsD





r.cCs~||krtd|jƒ‚t|ƒ}|g}|j|}x@|rn| ¡}| |¡x$|j|D]}||krR| |¡qRWq0W| d¡|S)zÚRecursively generate a list of distributions from *dists* that are
    dependent on *dist*.

    :param dists: a list of distributions
    :param dist: a distribution, member of *dists* for which we are interested
    z1given distribution %r is not a member of the listr)rrr.rÚpopr))r*r*r+ÚdepÚtodoruÚsuccr#r#r$Úget_dependent_distsÿs



r3cCsv||krtd|jƒ‚t|ƒ}g}|j|}xD|rp| ¡d}| |¡x$|j|D]}||krT| |¡qTWq.W|S)zÙRecursively generate a list of distributions from *dists* that are
    required by *dist*.

    :param dists: a list of distributions
    :param dist: a distribution, member of *dists* for which we are interested
    z1given distribution %r is not a member of the listr)rrr.rr/r))r*r*r+rr1ruÚpredr#r#r$Úget_required_distss


r5cKs4| dd¡}tf|Ž}||_||_|p(d|_t|ƒS)zO
    A convenience method for making a dist given just a name and version.
    ÚsummaryzPlaceholder for summary)r/r	rr^r6r)rr^Úkwargsr6r…r#r#r$Ú	make_dist2s

r8)r0)7r/Ú
__future__rr¢ràrKr Úloggingr­rIr1rr<rrÚcompatrr^rrr@r	r
rrÚutilr
rrrrrrÚ__all__Ú	getLoggerr,rNrÁZCOMMANDS_FILENAMErírHròrrrrrrrPrQrr.r3r5r8r#r#r#r$Ú<module>sV$

s7J]
6