ž 7’Reå9c@s®ddlZddlZddlZddlZddlZddlZddlmZmZm Z ddl m Z ddl m Z ddlmZGdd„deƒZdS(iN(u display_pathu backup_dirurmtree(ulogger(uInstallationError(uCommandcs¶|EeZdZdZdZdZdZ‡fdd†Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Z‡S(u ZipCommanduZip individual packages.uzipu# %prog [options] ...u$DEPRECATED. Zip individual packages.c s9tt|ƒj||Ž|jdkrM|jjdddddddƒn(|jjd dd ddd ddd ƒ|jjd ddddddƒ|jjddddddddƒ|jjdddddddƒ|jjdddddddƒ|jjddddddƒ|jjd|jƒdS( Nuzipu--unzipuactionu store_trueudestuunzipuhelpu"Unzip (rather than zip) a package.u--zipu store_falseudefaultu"Zip (rather than unzip) a package.u--no-pycuno_pycuEDo not include .pyc files in zip files (useful on Google App Engine).u-lu--listulistu2List the packages available, and their zip status.u --sort-filesu sort_filesuDWith --list, sort packages according to how many files they contain.u--pathuappendupathsu?Restrict operations to the given paths (may include wildcards).u-nu --simulateu0Do not actually perform the zip/unzip operation.iT( usuperu ZipCommandu__init__unameucmd_optsu add_optionuTrueuparseruinsert_option_group(uselfuargsukw(u __class__(u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu__init__sL          uZipCommand.__init__cCsp|jstjSg}tƒ}xýtjD]ò}tjjtjj|ƒƒ}xË|jD]}tjjtjj|ƒƒ}d|krÇtjt j |dƒ|ƒrô|j |ƒ|j |ƒPqôqW|j |ƒrW|j |ƒ|j |ƒPqWqWWtjd|dj|jƒfƒq)WxJ|jD]?}||kr)d|kr)|j |ƒtjd|ƒq)q)W|S(u:All the entries of sys.path, possibly restricted by --pathu*u,Skipping path %s because it doesn't match %su, uDAdding path %s because it doesn't match anything already on sys.path(u select_pathsusysupathusetuosunormcaseuabspathureusearchufnmatchu translateuappenduaddu startswithuloggerudebugujoin(uselfuresultu match_anyupathumatch((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyupaths>s2          uZipCommand.pathscCsVtjddƒ|j|_|j|_|jrA|j||ƒS|sVtdƒ‚ng}x |D]˜}|j|ƒ\}}|jr²t j j |ƒr²td||fƒ‚n6|j rèt j j |ƒ rètd||fƒ‚n|j ||fƒqcWd}xJ|D]B\}}|jr6|j||ƒ}q |j|||jƒ}q W|S(Nu1.7u_DEPRECATION: 'pip zip' and 'pip unzip` are deprecated, and will be removed in a future release.u2You must give at least one package to zip or unzipu;The module %s (in %s) is not a zip file; cannot be unzippedu:The module %s (in %s) is not a directory; cannot be zipped(uloggeru deprecatedupathsu select_pathsusimulateulistuInstallationErroru find_packageuunzipuosupathuisdiruappenduNoneu unzip_packageu zip_packageuno_pyc(uselfuoptionsuargsupackagesuargu module_nameufilenameu last_status((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyurun\s4      uZipCommand.runc CsÚtjj|ƒ}tjj|ƒ rPtj|ƒrPtd|||fƒ‚ntjj|ƒ}||jƒkr£tj dt |ƒt |ƒt |ƒfƒntj d|t |ƒfƒ|j rÚtj dƒdStj d7_ zÚtj|ƒ}g}x|jƒD] }|j}|j|tjjƒrþ|j|ƒ} tjj||ƒ} tjjtjj| ƒƒs”tjtjj| ƒƒn| rÕ| jtjjƒrÕtjj| ƒsûtj| ƒqûqt| dƒ} | j| ƒ| jƒq|j||j|ƒfƒqW|jƒ|sbtjdt |ƒƒtj|ƒ|j|ƒn`tjd|t |ƒfƒtj|d ƒ}x$|D]\}} |j|| ƒq˜W|jƒWdtj d8_ XdS( Nu3Module %s (in %s) isn't located in a zip file in %su/Unpacking %s into %s, but %s is not on sys.pathuUnzipping %s (in %s)u3Skipping remaining operations because of --simulateiuwbuRemoving now-empty zip file %su(Removing entries in %s/ from zip file %suw( uosupathudirnameuisfileuzipfileu is_zipfileuInstallationErrorupathsuloggeruwarnu display_pathunotifyusimulateuindentuZipFileuinfolistufilenameu startswithusepureadujoinuexistsumakedirsuendswithuopenuwriteucloseuappenduinfouunlinkuremove_filename_from_pthuwritestr( uselfu module_nameufilenameu zip_filenameu package_pathuziputo_saveuinfounameucontentudestuf((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu unzip_package{sX"        uZipCommand.unzip_packagecCsN|}tjd|t|ƒfƒtjd7_|jdƒrJ|}n |d}zã||kr¥t|ƒ}tjd||fƒ|js¥tj||ƒq¥nyvtj dt|ƒƒ|jsít j |dƒ}|j |dd ƒxït j|ƒD]Þ\}}} |r)d d „| Dƒ} nx°|d f| dfgD]–\} } x‡| D]} t jj|| ƒ} t jj||t|ƒd…jt jjƒ| ƒ}| rÄ|j |dd ƒqU|j| |ƒqUWqBWqþW|jƒntj d t|ƒƒ|jst|ƒnWn ‚YnX|j|ƒWdtjd8_XdS(NuZip %s (in %s)iu.eggu.zipuMoving %s aside to %suCreating zip file in %suwu/ucSs+g|]!}|jƒjdƒs|‘qS(u.pyc(uloweruendswith(u.0uf((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu Äs u*ZipCommand.zip_package..uRemoving old directory %sTF(uloggerunotifyu display_pathuindentuendswithu backup_dirusimulateushutilumoveuinfouzipfileuZipFileuwritestruosuwalkuTrueuFalseupathujoinulenulstripusepuwriteucloseurmtreeuadd_filename_to_pth(uselfu module_nameufilenameuno_pycu orig_filenameu dest_filenameuzipudirpathudirnamesu filenamesufnsuis_dirufnufulludest((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu zip_package®sF      % 7  uZipCommand.zip_packagecsxý|jƒD]ï}t|dƒ}|jƒ}|jƒ‡fdd†|Dƒ}||kr tjdtˆƒt|ƒfƒdd„|DƒsÆtjdt|ƒƒ|jsøtj |ƒqøn2|jsøt|dƒ}|j |ƒ|jƒndSq Wtj dtˆƒƒdS( Nurcs(g|]}|jƒˆkr|‘qS((ustrip(u.0ul(ufilename(u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu às u7ZipCommand.remove_filename_from_pth..u*Removing reference to %s from .pth file %scSsg|]}|r|‘qS(((u.0uline((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu äs u %s file would be empty: deletinguwbu.Cannot find a reference to %s in any .pth file( u pth_filesuopenu readlinesucloseuloggeruinfou display_pathusimulateuosuunlinku writelinesuwarn(uselfufilenameupthufulinesu new_lines((ufilenameu)/tmp/pip-zej_zi-build/pip/commands/zip.pyuremove_filename_from_pthÚs$        u#ZipCommand.remove_filename_from_pthcCsþtjj|ƒ}|d}||jƒkrHtjdt|ƒƒn|jsútjj|ƒrÄt |ƒ}|j ƒ}|j ƒ|r°|dj dƒ r°|dd7Lsu!ZipCommand.list..uUnzipped packages:u%s (%i files)uNo unzipped packages.(u.pthu .egg-infou .egg-link(uInstallationErrorusortedupathsuosupathuexistsubasenameurstripusepuisfileuzipfileu is_zipfileudirnameuloggerunotifyu display_pathureplaceuendswithuindentulistdirusplitextuloweruinfoujoinuisdiruappendu count_packageu sort_filesusort( uselfuoptionsuargsupathubasenameuzippeduunzippedufilenameuextufullucount((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyulistsf !!       uZipCommand.listcCsPd}xCtj|ƒD]2\}}}dd„|Dƒ}|t|ƒ7}qW|S(NicSs+g|]!}|jƒjdƒs|‘qS(u.pyc(uloweruendswith(u.0uf((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu \s u,ZipCommand.count_package..(uosuwalkulen(uselfupathutotaludirpathudirnamesu filenames((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu count_packageYs uZipCommand.count_package(u__name__u __module__u __qualname__u__doc__unameuusageusummaryu__init__upathsurunu unzip_packageu zip_packageuremove_filename_from_pthuadd_filename_to_pthu pth_filesu find_packageulistu count_package(u __locals__((u __class__u)/tmp/pip-zej_zi-build/pip/commands/zip.pyu ZipCommand s*   3 ,     ;u ZipCommand(usysureufnmatchuosushutiluzipfileupip.utilu display_pathu backup_dirurmtreeupip.loguloggerupip.exceptionsuInstallationErrorupip.basecommanduCommandu ZipCommand(((u)/tmp/pip-zej_zi-build/pip/commands/zip.pyus