fcF@@s dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZyddlZWnek r]ddlZnXddlmZddl m!Z!m"Z"m#Z#ddlm$Z$y&ddlm%Z%m&Z&m'Z'e(Z)Wnek re*Z)nXdd lm+Z,dd l-m.Z.m/Z/yddl0j1Z2e2j3Wnek r3e4Z2nXd d l5m6Z6dd lm7Z7ddlm8Z8e9de9de9de9dddfej:koddfknre;dnej<re4Z=e4Z>ne4Z?e4Z@e4ZAe4ZBe4ZCe4ZDe4ZEe4ZFe4ZGe4ZHe4ZIe4ZJe4ZKe4ZLe4ZMe4ZNe4ZOdePfdYZQdZRiZSdZTdZUdZVdZWdZXdZYdZZdZ[Z\d Z]d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@ddAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddegFZ^d<e_fdfYZ`d=e`fdgYZadheafdiYZbd>e`fdjYZcd?e`fdkYZdiZeejfd ZgdZhdlZid ZjdZkdmZldnZmdoZngdpZodqZpdrZqejrdsZsejrdtZteqZuduZvdvZwewZxdwZydxZze4dyZ{dzZ|dTfd{YZ}dUe}fd|YZ~d7efd}YZd~efdYZd6efdYZeZd@e;fdYZd8fdYZdZdZdZdZdZdZe4dZd[fdYZemeed\efdYZd]efdYZejdYefdYZeZdefdYZdefdYZd^efdYZeme jedVefdYZdWefdYZdXefdYZeTddidZe*dZe*dZee jee*dZeeedZe*dZdZdfdYZdZdZdZdZeejeee2dree2jeneTddieTddidZdZdZdZe4dZdZeejeee jeee2dr) ee2jendZeeedZidZdZdZdZdZejrdjZejrdejejBjZd;efdYZdZdZd9efdYZdefdYZdefdYZied6ed6ed6ZdZdefdYZdZd:e8jjfdYZdZdZdZdZdZdZe jddeQde(dZeedZedZdS(sZ Package resource API -------------------- A resource is a logical file contained within a package, or a logical subdirectory thereof. The package resource API expects resource names to have their path parts separated with ``/``, *not* whatever the local path separator is. Do not use os.path operations to manipulate resource names being passed into the API. The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in a limited way with .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. i(tabsolute_importN(t get_importer(tsix(turllibtmaptfilter(tutime(tmkdirtrenametunlink(topen(tisdirtspliti(t py31compat(tappdirs(t packagings&pkg_resources.extern.packaging.versions)pkg_resources.extern.packaging.specifierss+pkg_resources.extern.packaging.requirementss&pkg_resources.extern.packaging.markersisPython 3.3 or later is requiredt PEP440WarningcB@seZdZRS(sa Used when there is an issue with a version or specifier not complying with PEP 440. (t__name__t __module__t__doc__(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRnscC@s?ytjj|SWn$tjjk r:tjj|SXdS(N(RtversiontVersiontInvalidVersiont LegacyVersion(tv((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt parse_versionuscK@s-tj|tjtj||dS(N(tglobalstupdatet _state_varstdicttfromkeys(tvartypetkw((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_declare_statescC@sLi}t}x6tjD](\}}|d|||||tcC@s{t}tj|}|dk rwtjdkrwy-ddjtd |jdf}Wqwt k rsqwXn|S(sZReturn this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of Mac OS X that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of Mac OS X that we are *running*. To allow usage of packages that explicitly require a newer version of Mac OS X, we must also know the current version of the OS. If this condition occurs for any other platform with a version in its platform strings, this function should be extended accordingly. tdarwins macosx-%s-%st.iiN( tget_build_platformtmacosVersionStringtmatchR3tsystplatformtjoint _macosx_verstgroupt ValueError(tplattm((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_supported_platforms - trequiret run_scriptt get_providertget_distributiontload_entry_pointt get_entry_maptget_entry_infotiter_entry_pointstresource_stringtresource_streamtresource_filenametresource_listdirtresource_existstresource_isdirtdeclare_namespacet working_settadd_activation_listenertfind_distributionstset_extraction_pathtcleanup_resourcestget_default_cachet Environmentt WorkingSettResourceManagert Distributiont Requirementt EntryPointtResolutionErrortVersionConflicttDistributionNotFoundt UnknownExtratExtractionErrortparse_requirementsRt safe_namet safe_versiont get_platformtcompatible_platformst yield_linestsplit_sectionst safe_extrat to_filenametinvalid_markertevaluate_markertensure_directorytnormalize_pathtEGG_DISTt BINARY_DISTt SOURCE_DISTt CHECKOUT_DISTt DEVELOP_DISTtIMetadataProvidertIResourceProvidert FileMetadatat PathMetadatat EggMetadatat EmptyProvidertempty_providert NullProvidert EggProvidertDefaultProvidert ZipProvidertregister_findertregister_namespace_handlertregister_loader_typetfixup_namespace_packagesRtrun_maintAvailableDistributionscB@seZdZdZRS(s.Abstract base for dependency resolution errorscC@s|jjt|jS(N(t __class__RtreprR4(tself((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__repr__s(RRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR`scB@sDeZdZdZedZedZdZdZRS(s An already-installed version conflicts with the requested version. Should be initialized with the installed Distribution and the requested Requirement. s3{self.dist} is installed but {self.req} is requiredcC@s |jdS(Ni(R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytdistscC@s |jdS(Ni(R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytreqscC@s|jjtS(N(t _templatetformattlocals(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytreportscC@s$|s |S|j|f}t|S(st If required_by is non-empty, return a version of self that is a ContextualVersionConflict. (R4tContextualVersionConflict(Rt required_byR4((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt with_context s( RRRRtpropertyRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRas  RcB@s*eZdZejdZedZRS(s A VersionConflict that accepts a third parameter, the set of the requirements that required the installed Distribution. s by {self.required_by}cC@s |jdS(Ni(R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs(RRRRaRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs cB@sSeZdZdZedZedZedZdZdZ RS(s&A requested distribution was not foundsSThe '{self.req}' distribution was not found and is required by {self.requirers_str}cC@s |jdS(Ni(R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR(scC@s |jdS(Ni(R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt requirers,scC@s|js dSdj|jS(Nsthe applications, (RR>(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt requirers_str0s cC@s|jjtS(N(RRR(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR6scC@s |jS(N(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__str__9s( RRRRRRRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRb"s cB@seZdZRS(s>Distribution doesn't have an "extra feature" of the given name(RRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRc=siicC@s|t|eZdZdZdZdZdZdZRS(cC@sdS(s;Does the package's distribution contain the named metadata?N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt has_metadataR6cC@sdS(s'The named metadata resource as a stringN((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt get_metadataR6cC@sdS(sYield named metadata resource as list of non-blank non-comment lines Leading and trailing whitespace is stripped from each line, and lines with ``#`` as the first non-blank character are omitted.N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_metadata_linesR6cC@sdS(s>Is the named metadata a directory? (like ``os.path.isdir()``)N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytmetadata_isdirR6cC@sdS(s?List of metadata names in the directory (like ``os.listdir()``)N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytmetadata_listdirR6cC@sdS(s=Execute the named script in the supplied namespace dictionaryN((Rt namespace((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRFR6(RRRRRRRRF(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRws      cB@sDeZdZdZdZdZdZdZdZRS(s3An object that provides access to package resourcescC@sdS(sdReturn a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``N((tmanagert resource_name((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_resource_filenameR6cC@sdS(siReturn a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``N((RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_resource_stream R6cC@sdS(smReturn a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``N((RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_resource_stringR6cC@sdS(s,Does the package contain the named resource?N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt has_resourceR6cC@sdS(s>Is the named resource a directory? (like ``os.path.isdir()``)N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRRR6cC@sdS(s?List of resource names in the directory (like ``os.listdir()``)N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRPR6( RRRRRRRRRRP(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRxs     cB@seZdZddZedZedZdZdZ dZ ddZ dZ d Z deed Zddedd Zdded Zd ZedZdZdZdZRS(sDA collection of active distributions on sys.path (or a similar list)cC@s^g|_i|_i|_g|_|dkr<tj}nx|D]}|j|qCWdS(s?Create working set from list of path entries (default=sys.path)N(tentriest entry_keystby_keyt callbacksR3R<Rt add_entry(RRtentry((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__init__#s       cC@se|}yddlm}Wntk r1|SXy|j|Wntk r`|j|SX|S(s1 Prepare the master working set. i(t __requires__(t__main__RRRERat_build_from_requirements(tclstwsR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt _build_master0s   cC@s|g}t|}|j|t}x|D]}|j|q4Wx0tjD]%}||jkrU|j|qUqUW|jtj(|S(sQ Build a working set from a requirement spec. Rewrites sys.path. (RetresolveRZtaddR<RRR(Rtreq_specRtreqstdistsRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRDs    cC@sT|jj|g|jj|x*t|tD]}|j||tq3WdS(sAdd a path item to ``.entries``, finding any distributions on it ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than once, and the ``.entries`` of the ``sys.path`` WorkingSet should always equal ``sys.path``.) N(Rt setdefaultRRRVRRR(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRZs cC@s|jj|j|kS(s9True if `dist` is the active distribution for its project(RRR.(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt __contains__iscC@sC|jj|j}|dk r?||kr?t||n|S(sFind a distribution matching requirement `req` If there is an active distribution for the requested project, this returns it as long as it meets the version requirement specified by `req`. But, if there is an active distribution for the project and it does *not* meet the `req` requirement, ``VersionConflict`` is raised. If there is no active distribution for the requested project, ``None`` is returned. N(RRR.R3Ra(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRms cc@sgx`|D]X}|j|}|dkrGx4|jD] }|Vq5Wq||kr||VqqWdS(sYield entry point objects from `group` matching `name` If `name` is None, yields all entry points in `group` from all distributions in the working set, otherwise only ones matching both `group` and `name` are yielded (in distribution order). N(RJR3tvalues(RR@RRRtep((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRL}s    cC@sQtjdj}|d}|j||d<|j|dj||dS(s?Locate distribution for `requires` and run `script_name` scriptiRiN(R<RRR-RERF(RtrequiresRRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRFs    cc@spi}xc|jD]X}||jkr+qnx:|j|D]+}||kr9d||<|j|Vq9q9WqWdS(sYield distributions for non-duplicate projects in the working set The yield order is the order in which the items' path entries were added to the working set. iN(RRR(RtseentitemR.((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__iter__s  cC@s|r"|j|j|d|n|dkr:|j}n|jj|g}|jj|jg}| r|j|jkrdS||j|j<|j|kr|j|jn|j|kr|j|jn|j |dS(sAdd `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called. RN( t insert_onRR3tlocationRRR.RRt _added_new(RRRtinsertRtkeystkeys2((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@s+t|ddd}i}i}g}t} tjt} x|r&|jd} | |krmqFn| j| |sqFn|j| j} | dkr|j j| j} | dks| | krz|rz|} |dkr!| dkrt |j }q!t g}t g} n|j| | |d|} || j<| dkrz| j| d}t| |qzn|j| n| | kr| | }t| | j|n| j| jddd}|j|x/|D]'}| |j| j| j| | Map each requirement to the extras that demanded it. c@s@fd|jd|p$dD}j p?t|S(s Evaluate markers for req against each extra that demanded it. Return False if the req has a marker and fails evaluation. Otherwise, return True. c3@s(|]}jji|d6VqdS(textraN(tmarkertevaluate(t.0R)(R(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys s(N(N(RR3R*tany(RRR t extra_evals((Rs:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s  N(RRRR3R (((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscB@seZdZd eedZdZdZd dZ dZ dZ d e dZ d dZd Zd Zd ZRS( s5Searchable snapshot of distributions on a search pathcC@s,i|_||_||_|j|dS(s!Snapshot distributions available on a search path Any distributions found on `search_path` are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. `platform` is an optional string specifying the name of the platform that platform-specific distributions must be compatible with. If unspecified, it defaults to the current platform. `python` is an optional string naming the desired version of Python (e.g. ``'3.3'``); it defaults to the current version. You may explicitly set `platform` (and/or `python`) to ``None`` if you wish to map *all* distributions, not just those compatible with the running platform or Python version. N(t_distmapR=tpythontscan(Rt search_pathR=R0((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@sI|jdkp-|jdkp-|j|jk}|oHt|j|jS(sIs distribution `dist` acceptable for this environment? The distribution must match the platform and python version requirements specified when this environment was created, or False is returned. N(R0R3t py_versionRiR=(RRt py_compat((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytcan_addscC@s|j|jj|dS(s"Remove `dist` from the environmentN(R/R.tremove(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR6scC@sQ|dkrtj}nx2|D]*}x!t|D]}|j|q2WqWdS(sdScan `search_path` for distributions usable in this environment Any distributions found are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. Only distributions conforming to the platform/python version defined at initialization are added. N(R3R<RRVR(RR2RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR1s    cC@s|j}|jj|gS(sReturn a newest-to-oldest list of distributions for `project_name` Uses case-insensitive `project_name` comparison, assuming all the project's distributions use their project's name converted to all lowercase as their key. (tlowerR/R(RR tdistribution_key((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt __getitem__s cC@su|j|rq|jrq|jj|jg}||krq|j||jdtjddt qqndS(sLAdd `dist` if we ``can_add()`` it and it has not already been added R.thashcmptreverseN( R5t has_versionR/RR.RRtoperatort attrgetterR(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@sy|j|}Wn#tk r8|s/nd}nX|dk rI|Sx%||jD]}||krW|SqWW|j||S(sFind distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitable version of the project is already active in the specified `working_set`.) If a suitable distribution isn't active, this method returns the newest distribution in the environment that meets the ``Requirement`` in `req`. If no suitable distribution is found, and `installer` is supplied, then the result of calling the environment's ``obtain(req, installer)`` method will be returned. N(RRaR3R.tobtain(RRRTRRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s    cC@s|dk r||SdS(sObtain a distribution matching `requirement` (e.g. via download) Obtain a distro that matches requirement (e.g. via download). In the base ``Environment`` class, this routine just returns ``installer(requirement)``, unless `installer` is None, in which case None is returned instead. This method is a hook that allows subclasses to attempt other ways of obtaining a distribution before falling back to the `installer` argument.N(R3(Rt requirementR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR?#s cc@s0x)|jjD]}||r|VqqWdS(s=Yield the unique project names of the available distributionsN(R/R(RR.((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR/s cC@s{t|tr|j|nXt|trdxF|D](}x||D]}|j|qFWq5Wntd|f|S(s2In-place addition of a distribution or environmentsCan't add %r to environment(RR]RRZR(RtothertprojectR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__iadd__5s cC@s@|jgdddd}x||fD]}||7}q(W|S(s4Add an environment or distribution to an environmentR=R0N(RR3(RRAtnewR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__add__AsN(RRRR3RDtPY_MAJORRR5R6R1R9RRR R?RRCRE(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRZs        cB@seZdZRS(sTAn error occurred extracting a resource The following attributes are available from instances of this exception: manager The resource manager that raised this exception cache_path The base directory for resource extraction original_error The exception instance that caused extraction to fail (RRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRdMs cB@seZdZdZdZdZdZdZdZ dZ dZ dZ dd Z ed Zd Zd Zed ZRS(s'Manage resource extraction and packagescC@s i|_dS(N(t cached_files(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRascC@st|j|S(sDoes the named resource exist?(RGR(Rtpackage_or_requirementR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRQdscC@st|j|S(s,Is the named resource an existing directory?(RGRR(RRHR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRRhs cC@st|j||S(s4Return a true filesystem path for specified resource(RGR(RRHR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyROns cC@st|j||S(s9Return a readable file-like object for specified resource(RGR(RRHR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRNts cC@st|j||S(s%Return specified resource as a string(RGR(RRHR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRMzs cC@st|j|S(s1List the contents of the named resource directory(RGRP(RRHR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRPs cC@sttjd}|jpt}tjdj}t|jt }||_ ||_ ||_ |dS(s5Give an error message for problems extracting file(s)is Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: {old_exc} The Python egg cache directory is currently set to: {cache_path} Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. N( R<texc_infotextraction_pathRYttextwraptdedenttlstripRdRRRt cache_pathtoriginal_error(Rtold_excRNttmplterr((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytextraction_errors   cC@sx|jpt}tjj||d|}yt|Wntk rY|jnX|j|d|j |<|S(sReturn absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including its ".egg" extension. `names`, if provided, should be a sequence of path name parts "under" the egg's extraction location. This method should only be called by resource providers that need to obtain an extraction location, and only for names they intend to extract, as it tracks the generated names for possible cleanup later. s-tmpi( RJRYRRR>t_bypass_ensure_directoryt ExceptionRSt_warn_unsafe_extraction_pathRG(Rt archive_nametnamest extract_patht target_path((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytget_cache_paths    cC@swtjdkr*|jtjd r*dStj|j}|tj@sV|tj@rsd|}tj |t ndS(sN If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used. See Distribute #375 for more details. tnttwindirNs%s is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).( RRRtenvirontstattst_modetS_IWOTHtS_IWGRPtwarningstwarnt UserWarning(Rtmodetmsg((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRVs &cC@s@tjdkr<tj|jdBd@}tj||ndS(s4Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully extracting a compressed resource. They must NOT call it on resources that are already in the filesystem. `tempname` is the current (temporary) name of the file, and `filename` is the name it will be renamed to by the caller after this routine returns. tposiximiN(RRR_R`tchmod(RttempnametfilenameRf((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt postprocessscC@s%|jrtdn||_dS(sSet the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` environment variable, with various platform-specific fallbacks. See that routine's documentation for more details.) Resources are extracted to subdirectories of this path based upon information given by the ``IResourceProvider``. You may set this to a temporary directory, but then you must call ``cleanup_resources()`` to delete the extracted files when done. There is no guarantee that ``cleanup_resources()`` will be able to remove all extracted files. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call ``cleanup_resources()``.) s5Can't change extraction path, files already extractedN(RGRARJ(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRWs  cC@sdS(sB Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary directory exclusive to a single process. This method is not automatically called; you must call it explicitly or register it as an ``atexit`` function if you wish to ensure cleanup of a temporary directory used for extractions. N((Rtforce((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRXR6N((RRRR3RJRRQRRRORNRMRPRSR[t staticmethodRVRlRWRRX(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR\]s           cC@s"tjjdp!tjddS(s Return the ``PYTHON_EGG_CACHE`` environment variable or a platform-relevant user cache dir for an app named "Python-Eggs". tPYTHON_EGG_CACHEtappnames Python-Eggs(RR^RRtuser_cache_dir(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRYscC@stjdd|S(sConvert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. s[^A-Za-z0-9.]+t-(tretsub(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRfscC@sZyttjj|SWn9tjjk rU|jdd}tjdd|SXdS(sB Convert an arbitrary string to a standard version string RR8s[^A-Za-z0-9.]+RrN(RRRRRRRsRt(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRg%s cC@stjdd|jS(sConvert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased. s[^A-Za-z0-9.-]+R(RsRtR7(R)((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRl1scC@s|jddS(s|Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. RrR(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRm:scC@s;yt|Wn&tk r6}d|_d|_|SXtS(so Validate text as a PEP 508 environment marker; return an exception if invalid or False otherwise. N(Rot SyntaxErrorR3RktlinenoR(ttextte((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRnBs  cC@sLy tjj|}|jSWn%tjjk rG}t|nXdS(s Evaluate a PEP 508 environment marker. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'pyparsing' module. N(RtmarkerstMarkerR+t InvalidMarkerRu(RwR)R*Rx((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRoPs cB@seZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZRS(sETry to implement resources and metadata for arbitrary PEP 302 loaderscC@s:t|dd|_tjjt|dd|_dS(NRt__file__R6(RR3RRRtdirnamet module_path(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRfscC@s|j|j|S(N(t_fnR~(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRjscC@stj|j||S(N(tiotBytesIOR(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRmscC@s|j|j|j|S(N(t_getRR~(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRpscC@s|j|j|j|S(N(t_hasRR~(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRsscC@s%|jo$|j|j|j|S(N(tegg_infoRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRvscC@sE|js dS|j|j|j|}tjrA|jdS|S(NR6sutf-8(RRRRtPY3tdecode(RRtvalue((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRys cC@st|j|S(N(RjR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j|j|j|S(N(t_isdirRR~(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRRscC@s%|jo$|j|j|j|S(N(RRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j|j|j|S(N(t_listdirRR~(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRPscC@s)|jr%|j|j|j|SgS(N(RRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs c B@sd|}|j|s4edjen|j|jdd}|jdd}|j|j|}||dR (RtbaseR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s2t|jdr"|jj|StddS(Ntget_datas=Can't perform this operation for loaders without 'get_data()'(RRRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRsN(RRRR3tegg_nameRRRRRRRRRRRRRRPRRFRRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR~_s,                 cB@s eZdZdZdZRS(s&Provider based on a virtual filesystemcC@stj|||jdS(N(R~Rt _setup_prefix(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j}d}xt||krt|rdtjj||_tjj|d|_||_ Pn|}tjj |\}}qWdS(NsEGG-INFO( R~R3t _is_egg_pathRRtbasenameRR>Rtegg_rootR (RRtoldR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   (RRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs cB@sJeZdZdZdZdZdZdZedZ RS(s6Provides access to package resources in the filesystemcC@stjj|S(N(RRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@stjj|S(N(RRR (RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s tj|S(N(Rtlistdir(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@st|j|j|dS(Ntrb(R RR~(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s&t|d}|jSWdQXdS(NR(R R(RRtstream((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s)ttdtd}t||dS(NtSourceFileLoader(Rtimportlib_machineryttypeR3R(Rt loader_cls((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt _registers ( RRRRRRRRR(R(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs     cB@s<eZdZdZdZZdZdZdZ RS(s.Provider that returns nothing for all requestscC@stS(N(R(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR5R6cC@sdS(NR6((RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@sgS(N((RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@sdS(N((R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR sN( RRRR3R~RRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR|s    t ZipManifestscB@s#eZdZedZeZRS(s zip manifest builder c@sBtj|-fdjD}t|SWdQXdS(s Build a dictionary similar to the zipimport directory caches, except instead of tuples, store ZipInfo objects. Use a platform-specific path separator (os.sep) for the path keys for compatibility with pypy on Windows. c3@s3|])}|jdtjj|fVqdS(RN(RRtseptgetinfo(R,R(tzfile(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys sN(tzipfiletZipFiletnamelistR(RRR#((Rs:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytbuilds  (RRRR(Rtload(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRstMemoizedZipManifestscB@s)eZdZejddZdZRS(s% Memoized zipfile manifests. t manifest_modsmanifest mtimecC@svtjj|}tj|j}||ksC||j|krk|j|}|j||||Rt_extract_resourcet _eager_to_zip(RRRRteagersR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRcs     cC@s/|j}|jd}tj|}||fS(Nii(iii(t file_sizet date_timettimetmktime(tzip_stattsizeRt timestamp((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_get_date_and_sizeps  c C@s||jkr^x9|j|D]'}|j|tjj||}q#Wtjj|S|j|j|\}}tst dny(|j |j |j |}|j ||r|Stddtjj|\}} tj||jj|tj|t| ||f|j| |yt| |Wnltjk rtjj|r|j ||r|Stjdkrt|t| ||SnnXWntjk r|jnX|S(Ns>"os.rename" and "os.unlink" are not supported on this platforms .$extracttdirR\(t_indexRRRR>R}RRt WRITE_SUPPORTtIOErrorR[RRt _is_currentt_mkstemptwriteRRtcloseRRlRterrortisfileRR RS( RRRRtlastRRt real_pathtoutfttmpnam((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRysD    c C@s|j|j|\}}tjj|s2tStj|}|j|ks_|j|krctS|j j |}t |d}|j }WdQX||kS(sK Return True if the file_path is current for this zip_path RN( RRRRRRR_tst_sizeRRRR R( Rt file_pathRRRR_t zip_contentstft file_contents((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@sa|jdkrZg}x6dD].}|j|r|j|j|qqW||_n|jS(Nsnative_libs.txtseager_resources.txt(snative_libs.txtseager_resources.txt(RR3RR R(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs  cC@sy |jSWntk ri}x~|jD]s}|jtj}xX|rtjj|d }||kr||j|dPqF|jg||RR(RtindRtpartstparent((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs     cC@s.|j|}||jkp-||jkS(N(RRR(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j||jkS(N(RR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s%t|jj|j|dS(N((RRRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j|j|j|S(N(RRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|j|j|j|S(N(RRR~(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRsN(RRRR3RRRRRRRRRRnRRRRRRRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR?s$     7      cB@s;eZdZdZdZdZdZdZRS(s*Metadata handler for standalone PKG-INFO files Usage:: metadata = FileMetadata("/path/to/PKG-INFO") This provider rejects all data and metadata requests except for PKG-INFO, which is treated as existing, and will be the contents of the file at the provided location. cC@s ||_dS(N(R(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s|dkotjj|jS(NsPKG-INFO(RRR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s_|dkrtdntj|jdddd}|j}WdQX|j||S(NsPKG-INFOs(No metadata except PKG-INFO is availabletencodingsutf-8terrorsR(RRR RRt_warn_on_replacement(RRRtmetadata((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs  ! cC@sGdjd}||krCd}|jt}tj|ndS(Ns�sutf-8s2{self.path} could not be properly decoded in UTF-8(RRRRcRd(RRtreplacement_charRQRg((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s  cC@st|j|S(N(RjR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs(RRRRRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRys     cB@seZdZdZRS(ssMetadata provider for egg directories Usage:: # Development eggs: egg_info = "/path/to/PackageName.egg-info" base_dir = os.path.dirname(egg_info) metadata = PathMetadata(base_dir, egg_info) dist_name = os.path.splitext(os.path.basename(egg_info))[0] dist = Distribution(basedir, project_name=dist_name, metadata=metadata) # Unpacked egg directories: egg_path = "/path/to/PackageName-ver-pyver-etc.egg" metadata = PathMetadata(egg_path, os.path.join(egg_path,'EGG-INFO')) dist = Distribution.from_filename(egg_path, metadata=metadata) cC@s||_||_dS(N(R~R(RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR)s (RRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRzscB@seZdZdZRS(s Metadata provider for .egg filescC@s`|jtj|_||_|jrFtjj|j|j|_n |j|_|j dS(s-Create a metadata provider from a zipimporterN( RRRRRtprefixRR>R~R(Rtimporter((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR1s   ! (RRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR{.sRt_distribution_finderscC@s|t|tfind_eggs_in_zipt zipimportt zipimporterR7Rt from_location( RRRRtsubitemtsubpathRRtsubmeta((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRQs$     cC@sdS(N(((RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt find_nothingoscC@sd}t|d|dtS(sL Given a list of filenames, return them in descending order by version number. >>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg' >>> _by_version_descending(names) ['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar'] >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg' >>> _by_version_descending(names) ['Setuptools-1.2.3.egg', 'Setuptools-1.2.3b1.egg'] >>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.post1.egg' >>> _by_version_descending(names) ['Setuptools-1.2.3.post1.egg', 'Setuptools-1.2.3b1.egg'] cS@sYtjj|\}}tj|jd|g}g|D]}tjj|^q=S(s6 Parse each component of the filename Rr( RRtsplitextt itertoolstchainR RRR(RtextRtpart((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt _by_versionsR.R;(tsortedR(RXR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_by_version_descendingvs c #@sttrHtjdttjjdVdSt}fd|D}t |}xQ|D]I}tjj|}t |}x||D] } | VqWqWdS(s6Yield distributions accessible on a sys.path directoryRsEGG-INFONc3@s'|]}t|r|VqdS(N(t dist_factory(R,R(RR(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys s( t_normalize_cachedt_is_unpacked_eggR]RRzRRR>t safe_listdirRR( RRRRtfilteredtpath_item_entriesRtfullpathtfactoryR((RRs:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt find_on_paths       cC@sf|j}tt|jd}|r.tS| rEt|rEtS| r_|jdr_tStS(s9 Return a dist_factory for a path_item and entry s .egg-infos .dist-infos .egg-link(s .egg-infos .dist-info( R7R-RRtdistributions_from_metadataRRVtresolve_egg_linktNoDists(RRRR7tis_meta((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   RcB@s2eZdZdZejr'eZndZRS(sS >>> bool(NoDists()) False >>> list(NoDists()('anything')) [] cC@stS(N(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__bool__scC@s tdS(N((titer(RR ((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt__call__s(RRRRRtPY2t __nonzero__R(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs    cC@sytj|SWnnttfk r*nXtk r}|jtjtjtjfkpot |dddk}|sqnXdS(sI Attempt to list contents of path, but suppress some exceptions. twinerrori N(( RRtPermissionErrortNotADirectoryErrortOSErrorterrnotENOTDIRtEACCEStENOENTRR3(RRxt ignorable((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s! cc@stjj|}tjj|rUttj|dkrCdSt||}n t|}tjj|}t j |||dt VdS(Nit precedence( RRR}R RRRzRyRR]RRv(RtrootRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs cc@sDt|2}x(|D] }|j}|r|VqqWWdQXdS(s1 Yield non-empty lines from file at path N(R tstrip(RRtline((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytnon_empty_liness   c@s>t}fd|D}tt|}t|dS(sa Given a path to an .egg-link, resolve distributions present in the referenced path. c3@s0|]&}tjjtjj|VqdS(N(RRR>R}(R,tref(R(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys s((R%RRVtnext(Rtreferenced_pathstresolved_pathst dist_groups((Rs:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs    t FileFindert_namespace_handlerst_namespace_packagescC@s|t|(Rt path_partst module_partsR(t package_nameR=(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytposition_in_sys_pathTs NR.(R<RRRRRR/(t orig_pathRARtpRB((RAR=R<s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR5Ds"  cC@s tjz|tkrdStjd}}d|krdj|jdd }t||tkrxt |nytj |j }Wqt k rt d|qXntj|gj|tj|gx|D]}t||qWWdtjXdS(s9Declare that package 'packageName' is a namespace packageNR8isNot a package:(t_impt acquire_lockR-R<RR3R>R RSRRR/RRRRR8t release_lock(R6RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRSes&        cC@sbtjzFx?tj|dD]+}t||}|r t||q q WWdtjXdS(sDEnsure that previously-declared namespace packages include path_itemN((RERFR-RR8RRG(RRtpackageR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs cC@s`tjj||jdd}t|}x+|jD]}t||kr8Pq8q8W|SdS(sBCompute an ns-package subpath for a filesystem or zipfile importerR8iN(RRR>R RR/(RRR6RRt normalizedR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytfile_ns_handlers " cC@sdS(N(R3(RRR6R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytnull_ns_handlerscC@stjjtjj|S(s1Normalize a file/dir name for comparison purposes(RRtnormcasetrealpath(Rk((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRqscC@s9y ||SWn&tk r4t|||<}|SXdS(N(RRq(RkRtresult((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@s|jjdS(s7 Determine if given path appears to be an egg. s.egg(R7R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRscC@s.t|o-tjjtjj|ddS(s@ Determine if given path appears to be an unpacked egg. sEGG-INFOsPKG-INFO(RRRRR>(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs cC@sU|jd}|j}|rQdj|}ttj||tj|ndS(NR8(R RR>tsetattrR<R(R6RRR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR3s  cc@st|tjrVxn|jD]0}|j}|r|jd r|VqqWn-x*|D]"}xt|D] }|VqpWq]WdS(s9Yield non-empty/non-comment lines of a string or sequencet#N(RRRt splitlinesR#RRj(tstrststss((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRjs  s \w+(\.\w+)*$s (?P[^-]+) ( -(?P[^-]+) ( -py(?P[^-]+) ( -(?P.+) )? )? )? cB@seZdZd d ddZdZdZedZdZ dddZ e j dZ eddZed Zedd Zedd ZRS(s3Object representing an advertised importable objectcC@s[t|std|n||_||_t||_t||_||_dS(NsInvalid module name(tMODULERARt module_namettupletattrsR R(RRRVRXR R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@sfd|j|jf}|jr<|ddj|j7}n|jrb|ddj|j7}n|S(Ns%s = %st:R8s [%s]t,(RRVRXR>R (RRS((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRs   cC@sdt|S(NsEntryPoint.parse(%r)(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR scO@sO| s|s|r,tjdtddn|rE|j||n|jS(sH Require packages for this EntryPoint, then resolve it. sJParameters to load are deprecated. Call .resolve and .require separately.t stackleveli(RcRdtDeprecationWarningRER(RRER4tkwargs((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s cC@sdt|jddgdd}ytjt|j|SWn%tk r_}tt|nXdS(sD Resolve the entry point from its module and attrs. tfromlistRtleveliN( RRVt functoolstreduceRRXRRR(RRtexc((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s cC@sr|jr%|j r%td|n|jj|j}tj|||d|j}tttj|dS(Ns&Can't require() without a distributionR ( R RRcRRTRRRR(RRRRR#((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRE s s]\s*(?P.+?)\s*=\s*(?P[\w.]+)\s*(:\s*(?P[\w.]+))?\s*(?P\[.*\])?\s*$cC@s|jj|}|s0d}t||n|j}|j|d}|drl|djdnd}||d|d|||S(sParse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional s9EntryPoint must be in 'name=module:attrs [extras]' formatR tattrR8RR((tpatternR;RAt groupdictt _parse_extrasR (RtsrcRRCRgtresR RX((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR6 s  #cC@s9|s dStjd|}|jr2tn|jS(Ntx((R^RtspecsRAR (Rt extras_specR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRfJ s   cC@st|std|ni}xZt|D]L}|j||}|j|krptd||jn|||j '{project_name} ({version})' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommended to migrate to PEP 440 compatible versions. s R(RRRRRRKRLR#RRcRdRtvarsR(RtLVt is_legacyRQ((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_warn_legacy_version s  cC@sgy |jSWnUtk rbt|j|j}|dkr^d}t||j|n|SXdS(Ns(Missing 'Version:' header and/or %s file(R{RRyt _get_metadatatPKG_INFOR3RA(RRRQ((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s   cC@s>y |jSWn)tk r6|j|j|_nX|jS(s~ A map of extra to its list of (direct) requirements for this distribution, including the null extra. (t_Distribution__dep_mapRt_filter_extrast_build_dep_map(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_dep_map s   cC@sxttd|D]}|}|j|}|jd\}}}|oet|pet| }|rwg}nt|pd}|j|gj |qW|S(s Given a mapping of extras to dependencies, strip off environment markers and filter out any dependencies not matching the markers. RYN( RRR3RRwRnRoRlRR (tdmR)t new_extraRRR*t fails_marker((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s   cC@s`i}xSdD]K}xBt|j|D]+\}}|j|gjt|q)Wq W|S(Ns requires.txts depends.txt(s requires.txts depends.txt(RkRRR Re(RRRR)R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR, s  "'cC@s|j}g}|j|jddxS|D]K}y|j|t|Wq/tk rytd||fq/Xq/W|S(s@List of Requirements needed for this distro if `extras` are useds%s has no such extra feature %rN((RR RR3RlRRc(RR RtdepsR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR3 s   cc@s5|j|r1x|j|D] }|VqWndS(N(RR(RRR$((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRA scC@s|dkrtj}n|j|d||tjkrt|jx6|jdD]"}|tjkrWt|qWqWWndS(s>Ensure distribution is importable on `path` (default=sys.path)Rsnamespace_packages.txtN( R3R<RRRRRRRS(RRRtpkg((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytactivateF s   cC@sOdt|jt|j|jp'tf}|jrK|d|j7}n|S(s@Return what this distribution's standard .egg filename should bes %s-%s-py%sRr(RmR RR3RFR=(RRk((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRQ s  cC@s(|jrd||jfSt|SdS(Ns%s (%s)(RR(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR\ s cC@sMyt|dd}Wntk r/d}nX|p9d}d|j|fS(NRs[unknown version]s%s %s(RR3RAR (RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRb s    cC@s.|jdrt|nt|j|S(sADelegate all unrecognized public attributes to .metadata providerR(RRRR|(RRc((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt __getattr__j scK@s(|jt|tjj|||S(N(RRRRR(RRkRR ((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRp scC@sTt|jtjjr1d|j|jf}nd|j|jf}tj|S(s?Return a ``Requirement`` that matches this distribution exactlys%s==%ss%s===%s(RRRRRR R^R(Rtspec((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRw scC@sD|j||}|dkr:td||ffn|jS(s=Return the `name` entry point of `group` or raise ImportErrorsEntry point %r not foundN(RKR3RR(RR@RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRI s cC@scy |j}Wn3tk rBtj|jd|}|_nX|dk r_|j|iS|S(s=Return the entry point map for `group`, or the full entry mapsentry_points.txtN(t_ep_mapRR_RqRR3R(RR@tep_map((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRJ s    cC@s|j|j|S(s<Return the EntryPoint object for `group`+`name`, or ``None``(RJR(RR@R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRK sc C@s|p |j}|sdSt|}tjj|}g|D]}|rVt|pY|^q>}xt|D]\}}||kr|rPqdSqo||kro|jtkro| r|||krdS|tjkr|j n|j |||j ||PqoqoW|tjkr.|j n|rG|j d|n |j |dSxMt ry|j ||d} Wntk rPq[X|| =|| =| }q[WdS(sEnsure self.location is on path If replace=False (default): - If location is already in path anywhere, do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent. - Else: add to the end of path. If replace=True: - If location is already on path anywhere (not eggs) or higher priority than its parent (eggs) do nothing. - Else: - If it's an egg and its parent directory is on path, insert just ahead of the parent, removing any lower-priority entries. - Else: add it to the front of path. Nii(RRRRR}t enumerateR!RrR<tcheck_version_conflictRRRR:RA( RRtlocRtnloctbdirRDtnpathRtnp((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR sB +       cC@s|jdkrdStj|jd}t|j}x|jdD]}|tjksJ||ksJ|tkr}qJn|dkrqJnt tj|dd}|rt|j |sJ|j |jrqJnt d|||jfqJWdS( Nt setuptoolssnamespace_packages.txts top_level.txtt pkg_resourcestsiteR|sIModule %s was already imported from %s, but %s is being added to sys.path(RRR( R.RRRRqRR<RR-RR3Rt issue_warning(RtnspRtmodnametfn((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s"  cC@s8y |jWn&tk r3tdt|tSXtS(NsUnbuilt egg for (RRARRRR(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR< s   cK@sYd}x0|jD]"}|j|t||dqW|jd|j|j|S(s@Copy this distribution, substituting in any changed keyword argss<project_name version py_version platform location precedenceRN(R RRR3R|R(RR RXRc((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pytclone s  cC@s g|jD]}|r |^q S(N(R(Rtdep((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR  sN((.RRRRR3RFRrRR(RRRR:RRRRRRRR.RRRRRnRRRRRRRRRRRRRIRJRKRRR<RR (((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR] sR                      D   tEggInfoDistributioncB@seZdZRS(cC@s.t|j|j}|r*||_n|S(s Packages installed by distutils (e.g. numpy or scipy), which uses an old safe_version, and so their version numbers can get mangled when converted to filenames (e.g., 1.11.0.dev0+2329eae to 1.11.0.dev0_2329eae). These distributions will not be parsed properly downstream by Distribution and safe_version, so take an extra step and try to get the version number from the metadata file itself instead of the filename. (RyRRR{(Rt md_version((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s  (RRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR stDistInfoDistributioncB@sJeZdZdZejdZedZedZ dZ RS(sV Wrap an actual or potential sys.path entry w/metadata, .dist-info style. tMETADATAs([\(,])\s*(\d.*?)\s*([,\)])cC@sTy |jSWnBtk rO|j|j}tjjj||_|jSXdS(sParse and cache metadataN(t _pkg_infoRRRtemailtparsertParsertparsestr(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_parsed_pkg_info! s   cC@s6y |jSWn$tk r1|j|_|jSXdS(N(t_DistInfoDistribution__dep_mapRt_compute_dependencies(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR+ s   c@sigd6}|_gx3|jjdp2gD]}jt|q3Wfd}t|d}|dj|xR|jjdpgD]8}t|j}t t|||||R4(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR` s(RRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR_ scc@stt|}x|D]~}d|krA||jd }n|jdr|d j}y|t|7}Wqtk rdSXnt|VqWdS(sYield ``Requirement`` objects for each specification in `strs` `strs` must be a string, or a (possibly-nested) iterable thereof. s #s\iN(RRjRRR#R't StopIterationR^(RRRlR$((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRed s   cB@sMeZdZdZdZdZdZdZedZ RS(cC@sytt|j|Wn+tjjk rG}tt|nX|j|_ t |j}||j |_ |_ g|jD]}|j|jf^q|_ttt|j|_|j |jt|j|jrt|jndf|_t|j|_dS(s>DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!N(tsuperR^RRRtInvalidRequirementRRRt unsafe_nameRfR7R R.t specifierR=RRjRWRRlR RR*R3thashCmpRt_Requirement__hash(Rtrequirement_stringRxR R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR{ s + $cC@st|to|j|jkS(N(RR^R(RRA((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR scC@s ||k S(N((RRA((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR scC@sGt|tr1|j|jkr%tS|j}n|jj|dtS(Nt prereleases(RR]R.RRRtcontainsR(RR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s  cC@s|jS(N(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR scC@sdt|S(NsRequirement.parse(%r)(R(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR scC@st|\}|S(N(Re(RSR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s( RRRRRRRRRnR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR^z s     cC@st|kr|tfS|S(sJ Ensure object appears in the mro even for old-style classes. (tobject(tclasses((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_always_object s  cC@sPttjt|dt|}x"|D]}||kr.||Sq.WdS(s2Return an adapter factory for `ob` from `registry`RN(RtinspecttgetmroRR(tregistryR/R1tt((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s'  cC@s)tjj|}tj|dtdS(s1Ensure that the parent directory of `path` existstexist_okN(RRR}R tmakedirsR(RR}((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRp scC@s^tstdnt|\}}|rZ|rZt| rZt|t|dndS(s/Sandbox-bypassing version of ensure_directory()s*"os.mkdir" not supported on this platform.iN(RRR R RTR(RR}Rk((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRT s  cc@sd}g}xt|D]y}|jdr|jdrs|sI|rW||fVn|dd!j}g}qtd|q|j|qW||fVdS(ssSplit a string or iterable thereof into (section, content) pairs Each ``section`` is a stripped version of the section header ("[section]") and each ``content`` is a list of stripped lines excluding blank lines and comment-only lines. If there are any such lines before the first section header, they're returned in a first ``section`` of ``None``. t[t]iisInvalid section headingN(R3RjRRR#RAR(RStsectiontcontentR$((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyRk s  cO@s7tj}ztt_tj||SWd|t_XdS(N(RR tos_openttempfiletmkstemp(R4R told_open((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR s   tignoretcategoryRcO@s||||S(N((RR4R]((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt _call_aside s c@s:t|d<|jfdtDdS(s=Set up global resource manager (deliberately not state-saved)t_managerc3@s3|])}|jds|t|fVqdS(RN(RR(R,R(R(s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys sN(R\RR(R%((Rs:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt _initialize s    cC@stj}tdd||j}|j}|j}|j}|}td|D|ddtg|_ t t |j t jtjtdS(sE Prepare the master working set and make the ``require()`` API available. This function has explicit effects on the global state of pkg_resources. It is intended to be invoked once at the initialization of this module. Invocation by other packages is unsupported and done at their own risk. RRTcs@s!|]}|jdtVqdS(RN(RR(R,R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pys + scS@s|jdtS(NR(RR(R((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyR5/ R6R%N(R[RR!RERLR&RFRWRRRRRR<RRRR(RTRERLRURFR((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyt_initialize_master_working_set s        (Rt __future__RR<RRRRsR1RRRcR_R`tpkgutilR=R=RRt email.parserRRRRKRRRRERtimptpkg_resources.externRtpkg_resources.extern.six.movesRRRRRRR RRRR Rtos.pathR R timportlib.machineryt machineryRRR3R6R RRRt version_infot RuntimeErrorRRRRERTRUtresources_streamRXt resource_dirRNRWRRRMRLRPRORQRR,R-tRuntimeWarningRRRR!R'R)R,R0R1R2t _sget_nonet _sset_noneRDt__all__RUR`RaRRbRcRRRFRrRsRtRuRvRRGR?RR9RR:RRhRiRFRRHRIRJRKRwRxRR[RRRZRRdR\RYRfRgRlRmRnRoR~RRRR|R}RRRRRyRzR{RRVRRRRRRR RR%Rt ImpImporterRR+RR8R5RSRRJRKRqRRRR3RjR;RUtVERBOSEt IGNORECASERR_RuRyR]RRRRRARReRR^RRRpRTRkRtfilterwarningsRRRR(((s:/usr/lib/python2.7/site-packages/pkg_resources/__init__.pyts                                 +                                    .        d   '            ! !          }2   6