ó •abc@sâdZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z dgZ ej eƒZejdejƒZejd ejejBƒZejd Zdefd „ƒYZdS( su Class representing the list of files in a distribution. Equivalent to distutils.filelist, but fixes some problems. iÿÿÿÿNi(tDistlibException(tfsdecode(t convert_pathtManifests\\w* s#.*?(?= )| (?=$)icBs›eZdZd d„Zd„Zd„Zd„Zed„Z d„Z d„Z d„Z e d ed „Ze d ed „Ze d ed „Zd „ZRS(s~A list of files built by on exploring the filesystem and filtered by applying various patterns to what we find there. cCsYtjjtjj|p!tjƒƒƒ|_|jtj|_d|_ t ƒ|_ dS(sd Initialise an instance. :param base: The base directory to explore under. N( tostpathtabspathtnormpathtgetcwdtbasetseptprefixtNonetallfilestsettfiles(tselfR ((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyt__init__*s- cCsüddlm}m}m}g|_}|j}|g}|j}|j}x¨|r÷|ƒ}tj |ƒ} xƒ| D]{} tj j || ƒ} tj| ƒ} | j } || ƒrÊ|jt | ƒƒqu|| ƒru|| ƒ ru|| ƒququWqPWdS(smFind all files under the base and set ``allfiles`` to the absolute pathnames of files found. iÿÿÿÿ(tS_ISREGtS_ISDIRtS_ISLNKN(tstatRRRR R tpoptappendRtlistdirRtjointst_modeR(RRRRR troottstackRtpushtnamestnametfullnameRtmode((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pytfindall9s"          cCsM|j|jƒs-tjj|j|ƒ}n|jjtjj|ƒƒdS(sz Add a file to the manifest. :param item: The pathname to add. This can be relative to the base. N( t startswithR RRRR RtaddR(Rtitem((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR$TscCs"x|D]}|j|ƒqWdS(s† Add a list of files to the manifest. :param items: The pathnames to add. These can be relative to the base. N(R$(RtitemsR%((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pytadd_many^s csš‡‡fd†‰tˆjƒ}|rgtƒ}x'|D]}ˆ|tjj|ƒƒq7W||O}ngtd„|DƒƒD]}tjj|Œ^q~S(s8 Return sorted files in directory order csX|j|ƒtjd|ƒ|ˆjkrTtjj|ƒ\}}ˆ||ƒndS(Nsadd_dir added %s(R$tloggertdebugR RRtsplit(tdirstdtparentt_(tadd_dirR(s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR/ls  css!|]}tjj|ƒVqdS(N(RRR*(t.0R((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pys {s(RRRRtdirnametsortedR(RtwantdirstresultR+tft path_tuple((R/Rs@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR2gs   cCstƒ|_g|_dS(sClear all collected files.N(RRR (R((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pytclear}s cCs|j|ƒ\}}}}|dkrcxé|D].}|j|dtƒs.tjd|ƒq.q.Wn°|dkr˜x¡|D]}|j|dtƒ}qvWn{|dkràxl|D].}|j|dtƒs«tjd|ƒq«q«Wn3|dkrx$|D]}|j|dtƒ}qóWnþ|dkr`xï|D]1}|j|d |ƒs(tjd ||ƒq(q(Wn³|d kr•x¤|D]}|j|d |ƒ}qsWn~|d krÌ|jdd |ƒstjd |ƒqnG|dkr|jdd |ƒstjd|ƒqntd|ƒ‚dS(sv Process a directive which either adds some files from ``allfiles`` to ``files``, or removes some files from ``files``. :param directive: The directive to process. This should be in a format compatible with distutils ``MANIFEST.in`` files: http://docs.python.org/distutils/sourcedist.html#commands tincludetanchorsno files found matching %rtexcludesglobal-includes3no files found matching %r anywhere in distributionsglobal-excludesrecursive-includeR s-no files found matching %r under directory %rsrecursive-excludetgrafts no directories found matching %rtprunes4no previously-included directories found matching %rsinvalid action %rN( t_parse_directivet_include_patterntTrueR(twarningt_exclude_patterntFalseR R(Rt directivetactiontpatternstthedirt dirpatterntpatterntfound((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pytprocess_directive‚sD                    c Cs{|jƒ}t|ƒdkrA|ddkrA|jddƒn|d}d}}}|dkr°t|ƒd krŠtd |ƒ‚ng|dD]}t|ƒ^q•}n»|dkrt|ƒd krátd|ƒ‚nt|dƒ}g|d D]}t|ƒ^qü}nT|dkr[t|ƒd krHtd|ƒ‚nt|dƒ}ntd|ƒ‚||||fS(sŸ Validate a directive. :param directive: The directive to validate. :return: A tuple of action, patterns, thedir, dir_patterns iiR8R:sglobal-includesglobal-excludesrecursive-includesrecursive-excludeR;R<is$%r expects ...is*%r expects ...s!%r expects a single sunknown action %r(R8R:sglobal-includesglobal-excludesrecursive-includesrecursive-excludeR;R<N(R8R:sglobal-includesglobal-exclude(srecursive-includesrecursive-exclude(R;R<(R*tlentinsertR RR(RRCtwordsRDRERFt dir_patterntword((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR=Ñs:    & & cCszt}|j||||ƒ}|jdkr:|jƒnx9|jD].}|j|ƒrD|jj|ƒt}qDqDW|S(s…Select strings (presumably filenames) from 'self.files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not quite the same as implemented by the 'fnmatch' module: '*' and '?' match non-special characters, where "special" is platform-dependent: slash on Unix; colon, slash, and backslash on DOS/Windows; and colon on Mac OS. If 'anchor' is true (the default), then the pattern match is more stringent: "*.py" will match "foo.py" but not "foo/bar.py". If 'anchor' is false, both of these will match. If 'prefix' is supplied, then only filenames starting with 'prefix' (itself a pattern) and ending with 'pattern', with anything in between them, will match. 'anchor' is ignored in this case. If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and 'pattern' is assumed to be either a string containing a regex or a regex object -- no translation is done, the regex is just compiled and used as-is. Selected strings will be added to self.files. Return True if files are found. N( RBt_translate_patternR R R"tsearchRR$R?(RRHR9R tis_regexRIt pattern_reR((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR>s  cCsdt}|j||||ƒ}x?t|jƒD].}|j|ƒr.|jj|ƒt}q.q.W|S(stRemove strings (presumably filenames) from 'files' that match 'pattern'. Other parameters are the same as for 'include_pattern()', above. The list 'self.files' is modified in place. Return True if files are found. This API is public to allow e.g. exclusion of SCM subdirs, e.g. when packaging source distributions (RBRPtlistRRQtremoveR?(RRHR9R RRRIRSR5((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyRA)s  c Cs|r)t|tƒr"tj|ƒS|Sntd krY|jdƒjdƒ\}}}n|r€|j|ƒ}td kr†q†nd}tjtj j |j dƒƒ} |d k r°tdkrë|jdƒ} |j|ƒt | ƒ } n2|j|ƒ} | t |ƒt | ƒt |ƒ!} tj} tjdkr>d} ntdkrnd| | j | d|fƒ}qó|t |ƒt |ƒt |ƒ!}d || | | ||f}nC|rótdkrÓd| |}qód || |t |ƒf}ntj|ƒS(sTranslate a shell-like wildcard pattern to a compiled regular expression. Return the compiled regex. If 'is_regex' true, then 'pattern' is directly compiled to a regex (if it's a string) or just returned as-is (assumes it's a regex object). iiR.ts\s\\t^s.*s%s%s%s%s.*%s%ss%s%s%s(ii(iiN(ii(ii(ii(t isinstancetstrtretcompilet_PYTHON_VERSIONt _glob_to_ret partitiontescapeRRRR R RKR ( RRHR9R RRtstartR.tendRSR t empty_patternt prefix_reR ((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyRP=s@   $ !  #   #  cCsStj|ƒ}tj}tjdkr0d}nd|}tjd||ƒ}|S(s÷Translate a shell-like glob pattern to a regular expression. Return a string containing the regex. Differs from 'fnmatch.translate()' in that '*' does not match "special characters" (which are platform-specific). s\s\\\\s\1[^%s]s((?RARPR](((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyR%s      O / (  6(RjRdtloggingRRZtsysRVRtcompatRtutilRt__all__t getLoggerRhR(R[tMt_COLLAPSE_PATTERNtSt_COMMENTED_LINEt version_infoR\tobjectR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/manifest.pyt s