├── venv ├── bin │ ├── python2 │ ├── python2.7 │ ├── python │ ├── pip │ ├── pep8 │ ├── pip-2.7 │ ├── easy_install │ ├── easy_install-2.7 │ ├── activate_this.py │ ├── activate.csh │ ├── activate │ └── activate.fish ├── lib │ └── python2.7 │ │ ├── no-global-site-packages.txt │ │ ├── site-packages │ │ ├── pep8-1.4.5-py2.7.egg-info │ │ │ ├── not-zip-safe │ │ │ ├── top_level.txt │ │ │ ├── dependency_links.txt │ │ │ ├── namespace_packages.txt │ │ │ ├── entry_points.txt │ │ │ ├── installed-files.txt │ │ │ ├── SOURCES.txt │ │ │ └── PKG-INFO │ │ ├── pip-1.2.1-py2.7.egg │ │ │ ├── EGG-INFO │ │ │ │ ├── not-zip-safe │ │ │ │ ├── top_level.txt │ │ │ │ ├── dependency_links.txt │ │ │ │ ├── entry_points.txt │ │ │ │ └── SOURCES.txt │ │ │ └── pip │ │ │ │ ├── commands │ │ │ │ ├── __init__.py │ │ │ │ ├── zip.pyc │ │ │ │ ├── bundle.pyc │ │ │ │ ├── freeze.pyc │ │ │ │ ├── help.pyc │ │ │ │ ├── search.pyc │ │ │ │ ├── unzip.pyc │ │ │ │ ├── __init__.pyc │ │ │ │ ├── install.pyc │ │ │ │ ├── completion.pyc │ │ │ │ ├── uninstall.pyc │ │ │ │ ├── unzip.py │ │ │ │ ├── help.py │ │ │ │ ├── bundle.py │ │ │ │ ├── uninstall.py │ │ │ │ ├── completion.py │ │ │ │ ├── freeze.py │ │ │ │ ├── search.py │ │ │ │ ├── install.py │ │ │ │ └── zip.py │ │ │ │ ├── status_codes.py │ │ │ │ ├── index.pyc │ │ │ │ ├── log.pyc │ │ │ │ ├── req.pyc │ │ │ │ ├── util.pyc │ │ │ │ ├── runner.pyc │ │ │ │ ├── vcs │ │ │ │ ├── git.pyc │ │ │ │ ├── bazaar.pyc │ │ │ │ ├── __init__.pyc │ │ │ │ ├── mercurial.pyc │ │ │ │ ├── subversion.pyc │ │ │ │ ├── bazaar.py │ │ │ │ ├── mercurial.py │ │ │ │ ├── __init__.py │ │ │ │ ├── git.py │ │ │ │ └── subversion.py │ │ │ │ ├── __init__.pyc │ │ │ │ ├── __main__.pyc │ │ │ │ ├── baseparser.pyc │ │ │ │ ├── download.pyc │ │ │ │ ├── exceptions.pyc │ │ │ │ ├── locations.pyc │ │ │ │ ├── basecommand.pyc │ │ │ │ ├── status_codes.pyc │ │ │ │ ├── backwardcompat.pyc │ │ │ │ ├── __main__.py │ │ │ │ ├── runner.py │ │ │ │ ├── exceptions.py │ │ │ │ ├── locations.py │ │ │ │ ├── backwardcompat.py │ │ │ │ ├── log.py │ │ │ │ ├── basecommand.py │ │ │ │ ├── __init__.py │ │ │ │ ├── baseparser.py │ │ │ │ └── download.py │ │ ├── setuptools.pth │ │ ├── pep8.pyc │ │ ├── setuptools-0.6c11-py2.7.egg │ │ └── easy-install.pth │ │ ├── orig-prefix.txt │ │ ├── os.py │ │ ├── re.py │ │ ├── abc.py │ │ ├── config │ │ ├── sre.py │ │ ├── stat.py │ │ ├── _abcoll.py │ │ ├── codecs.py │ │ ├── encodings │ │ ├── fnmatch.py │ │ ├── locale.py │ │ ├── ntpath.py │ │ ├── types.py │ │ ├── UserDict.py │ │ ├── abc.pyc │ │ ├── copy_reg.py │ │ ├── lib-dynload │ │ ├── linecache.py │ │ ├── os.pyc │ │ ├── posixpath.py │ │ ├── re.pyc │ │ ├── sre_parse.py │ │ ├── warnings.py │ │ ├── _weakrefset.py │ │ ├── genericpath.py │ │ ├── site.pyc │ │ ├── sre_compile.py │ │ ├── stat.pyc │ │ ├── types.pyc │ │ ├── UserDict.pyc │ │ ├── _abcoll.pyc │ │ ├── codecs.pyc │ │ ├── copy_reg.pyc │ │ ├── fnmatch.pyc │ │ ├── locale.pyc │ │ ├── sre_constants.py │ │ ├── warnings.pyc │ │ ├── linecache.pyc │ │ ├── posixpath.pyc │ │ ├── sre_parse.pyc │ │ ├── _weakrefset.pyc │ │ ├── genericpath.pyc │ │ ├── sre_compile.pyc │ │ ├── sre_constants.pyc │ │ └── distutils │ │ ├── __init__.pyc │ │ ├── distutils.cfg │ │ └── __init__.py ├── .Python └── include │ └── python2.7 ├── README.md ├── problem1.py ├── problem2.py ├── problem4.py └── problem3.py /venv/bin/python2: -------------------------------------------------------------------------------- 1 | python -------------------------------------------------------------------------------- /venv/bin/python2.7: -------------------------------------------------------------------------------- 1 | python -------------------------------------------------------------------------------- /venv/lib/python2.7/no-global-site-packages.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /venv/.Python: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/Python -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/not-zip-safe: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/orig-prefix.txt: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7 -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | pep8 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/EGG-INFO/not-zip-safe: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/EGG-INFO/top_level.txt: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/setuptools.pth: -------------------------------------------------------------------------------- 1 | ./setuptools-0.6c11-py2.7.egg 2 | -------------------------------------------------------------------------------- /venv/bin/python: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/bin/python -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/namespace_packages.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/EGG-INFO/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /venv/include/python2.7: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -------------------------------------------------------------------------------- /venv/lib/python2.7/os.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py -------------------------------------------------------------------------------- /venv/lib/python2.7/re.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py -------------------------------------------------------------------------------- /venv/lib/python2.7/abc.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.py -------------------------------------------------------------------------------- /venv/lib/python2.7/config: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -------------------------------------------------------------------------------- /venv/lib/python2.7/sre.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre.py -------------------------------------------------------------------------------- /venv/lib/python2.7/stat.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.py -------------------------------------------------------------------------------- /venv/lib/python2.7/_abcoll.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py -------------------------------------------------------------------------------- /venv/lib/python2.7/codecs.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py -------------------------------------------------------------------------------- /venv/lib/python2.7/encodings: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings -------------------------------------------------------------------------------- /venv/lib/python2.7/fnmatch.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/fnmatch.py -------------------------------------------------------------------------------- /venv/lib/python2.7/locale.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py -------------------------------------------------------------------------------- /venv/lib/python2.7/ntpath.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ntpath.py -------------------------------------------------------------------------------- /venv/lib/python2.7/types.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.py -------------------------------------------------------------------------------- /venv/lib/python2.7/UserDict.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py -------------------------------------------------------------------------------- /venv/lib/python2.7/abc.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/abc.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/copy_reg.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py -------------------------------------------------------------------------------- /venv/lib/python2.7/lib-dynload: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload -------------------------------------------------------------------------------- /venv/lib/python2.7/linecache.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/linecache.py -------------------------------------------------------------------------------- /venv/lib/python2.7/os.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/os.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/posixpath.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py -------------------------------------------------------------------------------- /venv/lib/python2.7/re.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/re.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_parse.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.py -------------------------------------------------------------------------------- /venv/lib/python2.7/warnings.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py -------------------------------------------------------------------------------- /venv/lib/python2.7/_weakrefset.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_weakrefset.py -------------------------------------------------------------------------------- /venv/lib/python2.7/genericpath.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py -------------------------------------------------------------------------------- /venv/lib/python2.7/site.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_compile.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py -------------------------------------------------------------------------------- /venv/lib/python2.7/stat.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/stat.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/types.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/types.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/UserDict.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/UserDict.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/_abcoll.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/_abcoll.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/codecs.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/codecs.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/copy_reg.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/copy_reg.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/fnmatch.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/fnmatch.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/locale.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/locale.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_constants.py: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.py -------------------------------------------------------------------------------- /venv/lib/python2.7/warnings.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/warnings.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/linecache.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/linecache.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/posixpath.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/posixpath.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_parse.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/sre_parse.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/_weakrefset.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/_weakrefset.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/genericpath.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/genericpath.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | [console_scripts] 2 | pep8 = pep8:_main 3 | 4 | -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_compile.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/sre_compile.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/sre_constants.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/sre_constants.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/distutils/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/distutils/__init__.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pep8.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/EGG-INFO/entry_points.txt: -------------------------------------------------------------------------------- 1 | [console_scripts] 2 | pip = pip:main 3 | pip-2.7 = pip:main 4 | 5 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/status_codes.py: -------------------------------------------------------------------------------- 1 | SUCCESS = 0 2 | ERROR = 1 3 | UNKNOWN_ERROR = 2 4 | VIRTUALENV_NOT_FOUND = 3 5 | NO_MATCHES_FOUND = 23 6 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/index.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/index.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/log.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/log.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/runner.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/runner.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/git.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/git.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__init__.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__main__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__main__.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/baseparser.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/baseparser.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/download.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/download.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/exceptions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/exceptions.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/locations.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/locations.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/bazaar.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/bazaar.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/zip.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/zip.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/status_codes.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/status_codes.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/__init__.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/backwardcompat.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/backwardcompat.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/bundle.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/bundle.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/freeze.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/freeze.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/help.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/help.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/search.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/search.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/unzip.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/unzip.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/mercurial.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/mercurial.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/subversion.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/subversion.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from .runner import run 3 | 4 | if __name__ == '__main__': 5 | exit = run() 6 | if exit: 7 | sys.exit(exit) 8 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/__init__.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/completion.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/completion.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/uninstall.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/john-sandall/euler/master/venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/uninstall.pyc -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/unzip.py: -------------------------------------------------------------------------------- 1 | from pip.commands.zip import ZipCommand 2 | 3 | 4 | class UnzipCommand(ZipCommand): 5 | name = 'unzip' 6 | summary = 'Unzip individual packages' 7 | 8 | 9 | UnzipCommand() 10 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/installed-files.txt: -------------------------------------------------------------------------------- 1 | ../pep8.py 2 | ../pep8.pyc 3 | ./ 4 | dependency_links.txt 5 | entry_points.txt 6 | namespace_packages.txt 7 | not-zip-safe 8 | PKG-INFO 9 | SOURCES.txt 10 | top_level.txt 11 | ../../../../bin/pep8 12 | -------------------------------------------------------------------------------- /venv/lib/python2.7/distutils/distutils.cfg: -------------------------------------------------------------------------------- 1 | # This is a config file local to this virtualenv installation 2 | # You may include options that will be used by all distutils commands, 3 | # and by easy_install. For instance: 4 | # 5 | # [easy_install] 6 | # find_links = http://mylocalsite 7 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/easy-install.pth: -------------------------------------------------------------------------------- 1 | import sys; sys.__plen = len(sys.path) 2 | ./setuptools-0.6c11-py2.7.egg 3 | ./pip-1.2.1-py2.7.egg 4 | import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) 5 | -------------------------------------------------------------------------------- /venv/bin/pip: -------------------------------------------------------------------------------- 1 | #!/Users/john/yplan/euler/venv/bin/python 2 | # EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.2.1','console_scripts','pip' 3 | __requires__ = 'pip==1.2.1' 4 | import sys 5 | from pkg_resources import load_entry_point 6 | 7 | sys.exit( 8 | load_entry_point('pip==1.2.1', 'console_scripts', 'pip')() 9 | ) 10 | -------------------------------------------------------------------------------- /venv/bin/pep8: -------------------------------------------------------------------------------- 1 | #!/Users/john/yplan/euler/venv/bin/python 2 | # EASY-INSTALL-ENTRY-SCRIPT: 'pep8==1.4.5','console_scripts','pep8' 3 | __requires__ = 'pep8==1.4.5' 4 | import sys 5 | from pkg_resources import load_entry_point 6 | 7 | sys.exit( 8 | load_entry_point('pep8==1.4.5', 'console_scripts', 'pep8')() 9 | ) 10 | -------------------------------------------------------------------------------- /venv/bin/pip-2.7: -------------------------------------------------------------------------------- 1 | #!/Users/john/yplan/euler/venv/bin/python 2 | # EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.2.1','console_scripts','pip-2.7' 3 | __requires__ = 'pip==1.2.1' 4 | import sys 5 | from pkg_resources import load_entry_point 6 | 7 | sys.exit( 8 | load_entry_point('pip==1.2.1', 'console_scripts', 'pip-2.7')() 9 | ) 10 | -------------------------------------------------------------------------------- /venv/bin/easy_install: -------------------------------------------------------------------------------- 1 | #!/Users/john/yplan/euler/venv/bin/python 2 | # EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c11','console_scripts','easy_install' 3 | __requires__ = 'setuptools==0.6c11' 4 | import sys 5 | from pkg_resources import load_entry_point 6 | 7 | sys.exit( 8 | load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')() 9 | ) 10 | -------------------------------------------------------------------------------- /venv/bin/easy_install-2.7: -------------------------------------------------------------------------------- 1 | #!/Users/john/yplan/euler/venv/bin/python 2 | # EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c11','console_scripts','easy_install-2.7' 3 | __requires__ = 'setuptools==0.6c11' 4 | import sys 5 | from pkg_resources import load_entry_point 6 | 7 | sys.exit( 8 | load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install-2.7')() 9 | ) 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Project Euler 2 | ============= 3 | 4 | **Mini-Python projects from [projecteuler.net](http://projecteuler.net)** 5 | 6 | Completed: 7 | ---------- 8 | 9 | * [Problem 1 - Multiples of 3 and 5](http://projecteuler.net/problem=1) 10 | * [Problem 2 - Even Fibonacci numbers](http://projecteuler.net/problem=2) 11 | * [Problem 3 - Largest prime factor](http://projecteuler.net/problem=3) 12 | * [Problem 4 - Largest palindrome product](http://projecteuler.net/problem=4) 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/runner.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | 5 | def run(): 6 | base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 7 | ## FIXME: this is kind of crude; if we could create a fake pip 8 | ## module, then exec into it and update pip.__path__ properly, we 9 | ## wouldn't have to update sys.path: 10 | sys.path.insert(0, base) 11 | import pip 12 | return pip.main() 13 | 14 | 15 | if __name__ == '__main__': 16 | exit = run() 17 | if exit: 18 | sys.exit(exit) 19 | -------------------------------------------------------------------------------- /problem1.py: -------------------------------------------------------------------------------- 1 | # Project Euler Problem #1: Multiples of 3 and 5 2 | # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these 3 | # multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. 4 | 5 | # sumMultiples() returns the sum of all the multiples of a number less than n. We then add these up for 3 & 5 and 6 | # remove double counting. 7 | 8 | 9 | def sum_multiples(multiplier, n): 10 | return sum(range(0, n, multiplier)) 11 | 12 | print sum_multiples(3, 1000) + sum_multiples(5, 1000) - sum_multiples(15, 1000) 13 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/exceptions.py: -------------------------------------------------------------------------------- 1 | """Exceptions used throughout package""" 2 | 3 | 4 | class PipError(Exception): 5 | """Base pip exception""" 6 | 7 | 8 | class InstallationError(PipError): 9 | """General exception during installation""" 10 | 11 | 12 | class UninstallationError(PipError): 13 | """General exception during uninstallation""" 14 | 15 | 16 | class DistributionNotFound(InstallationError): 17 | """Raised when a distribution cannot be found to satisfy a requirement""" 18 | 19 | 20 | class BestVersionAlreadyInstalled(PipError): 21 | """Raised when the most up-to-date version of a package is already 22 | installed. """ 23 | 24 | 25 | class BadCommand(PipError): 26 | """Raised when virtualenv or a command is not found""" 27 | 28 | 29 | class CommandError(PipError): 30 | """Raised when there is an error in command-line arguments""" 31 | -------------------------------------------------------------------------------- /problem2.py: -------------------------------------------------------------------------------- 1 | # Project Euler Problem #2: Even Fibonacci numbers 2 | 3 | # Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the 4 | # first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... 5 | # By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the 6 | # even-valued terms. 7 | 8 | 9 | # fibonacci() is a generator, yields fibonacci sequence 10 | def fibonacci(): 11 | t_1, t_2 = 1, 1 12 | while True: 13 | (t_2, t_1) = (t_1 + t_2, t_2) 14 | yield t_1 15 | 16 | 17 | # stop_at() takes a stop number, n, and a generator function, f, yielding sequence from f if < n 18 | def stop_at(n, f): 19 | x = f.next() 20 | while x < n: 21 | yield x 22 | x = f.next() 23 | else: 24 | return 25 | 26 | 27 | # check_even() takes a generator, f, yielding any even numbers from the f sequence 28 | def check_even(f): 29 | while True: 30 | x = f.next() 31 | if x % 2 == 0: 32 | yield x 33 | 34 | 35 | print sum(check_even(stop_at(4000000, fibonacci()))) 36 | -------------------------------------------------------------------------------- /problem4.py: -------------------------------------------------------------------------------- 1 | # Project Euler Problem #4: Largest palindrome product 2 | 3 | # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 4 | # 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. 5 | 6 | 7 | # Checks if n is a palindromic number. 8 | def is_palindrome(n): 9 | if str(n) == str(n)[::-1]: 10 | return True 11 | else: 12 | return False 13 | 14 | 15 | # Digits allows easy manipulation of the problem, e.g. solve example above by setting digits = 2. 16 | digits = 3 17 | # Range to iterate over, equals range(999,99,-1) for digits = 3. 18 | values = range(10 ** digits - 1, 10 ** (digits-1) - 1, -1) 19 | # Somewhere to store our "winning" combination 20 | largest = [0, 0, 0] 21 | 22 | 23 | # Iterate over range, break if its impossible to beat our winning combination, and update if new winner found. 24 | for i, j in ((i, j) for i in values for j in values): 25 | if i ** 2 < largest[2]: 26 | break 27 | if is_palindrome(i * j) and (i * j > largest[2]): 28 | largest = [i, j, i * j] 29 | 30 | 31 | print "%d x %d = %d" % (largest[0], largest[1], largest[2]) 32 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/EGG-INFO/SOURCES.txt: -------------------------------------------------------------------------------- 1 | AUTHORS.txt 2 | LICENSE.txt 3 | MANIFEST.in 4 | setup.cfg 5 | setup.py 6 | docs/ci-server-step-by-step.txt 7 | docs/configuration.txt 8 | docs/contributing.txt 9 | docs/glossary.txt 10 | docs/index.txt 11 | docs/installing.txt 12 | docs/news.txt 13 | docs/other-tools.txt 14 | docs/requirements.txt 15 | docs/usage.txt 16 | pip/__init__.py 17 | pip/__main__.py 18 | pip/backwardcompat.py 19 | pip/basecommand.py 20 | pip/baseparser.py 21 | pip/download.py 22 | pip/exceptions.py 23 | pip/index.py 24 | pip/locations.py 25 | pip/log.py 26 | pip/req.py 27 | pip/runner.py 28 | pip/status_codes.py 29 | pip/util.py 30 | pip.egg-info/PKG-INFO 31 | pip.egg-info/SOURCES.txt 32 | pip.egg-info/dependency_links.txt 33 | pip.egg-info/entry_points.txt 34 | pip.egg-info/not-zip-safe 35 | pip.egg-info/top_level.txt 36 | pip/commands/__init__.py 37 | pip/commands/bundle.py 38 | pip/commands/completion.py 39 | pip/commands/freeze.py 40 | pip/commands/help.py 41 | pip/commands/install.py 42 | pip/commands/search.py 43 | pip/commands/uninstall.py 44 | pip/commands/unzip.py 45 | pip/commands/zip.py 46 | pip/vcs/__init__.py 47 | pip/vcs/bazaar.py 48 | pip/vcs/git.py 49 | pip/vcs/mercurial.py 50 | pip/vcs/subversion.py -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | CHANGES.txt 2 | MANIFEST.in 3 | README.rst 4 | pep8.py 5 | setup.cfg 6 | setup.py 7 | docs/Makefile 8 | docs/advanced.rst 9 | docs/api.rst 10 | docs/conf.py 11 | docs/developer.rst 12 | docs/index.rst 13 | docs/intro.rst 14 | docs/make.bat 15 | pep8.egg-info/PKG-INFO 16 | pep8.egg-info/SOURCES.txt 17 | pep8.egg-info/dependency_links.txt 18 | pep8.egg-info/entry_points.txt 19 | pep8.egg-info/namespace_packages.txt 20 | pep8.egg-info/not-zip-safe 21 | pep8.egg-info/top_level.txt 22 | testsuite/E10.py 23 | testsuite/E11.py 24 | testsuite/E12.py 25 | testsuite/E12not.py 26 | testsuite/E20.py 27 | testsuite/E21.py 28 | testsuite/E22.py 29 | testsuite/E23.py 30 | testsuite/E24.py 31 | testsuite/E25.py 32 | testsuite/E26.py 33 | testsuite/E27.py 34 | testsuite/E30.py 35 | testsuite/E30not.py 36 | testsuite/E40.py 37 | testsuite/E50.py 38 | testsuite/E70.py 39 | testsuite/E71.py 40 | testsuite/E72.py 41 | testsuite/E90.py 42 | testsuite/W19.py 43 | testsuite/W29.py 44 | testsuite/W39.py 45 | testsuite/W60.py 46 | testsuite/__init__.py 47 | testsuite/latin-1.py 48 | testsuite/python3.py 49 | testsuite/support.py 50 | testsuite/test_all.py 51 | testsuite/test_api.py 52 | testsuite/test_shell.py 53 | testsuite/utf-8.py -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/help.py: -------------------------------------------------------------------------------- 1 | from pip.basecommand import (Command, command_dict, 2 | load_all_commands, SUCCESS, 3 | ERROR) 4 | from pip.exceptions import CommandError 5 | from pip.baseparser import parser 6 | 7 | 8 | class HelpCommand(Command): 9 | name = 'help' 10 | usage = '%prog' 11 | summary = 'Show available commands' 12 | 13 | def run(self, options, args): 14 | load_all_commands() 15 | if args: 16 | ## FIXME: handle errors better here 17 | command = args[0] 18 | if command not in command_dict: 19 | raise CommandError('No command with the name: %s' % command) 20 | command = command_dict[command] 21 | command.parser.print_help() 22 | return SUCCESS 23 | parser.print_help() 24 | print('\nCommands available:') 25 | commands = list(set(command_dict.values())) 26 | commands.sort(key=lambda x: x.name) 27 | for command in commands: 28 | if command.hidden: 29 | continue 30 | print(' %s: %s' % (command.name, command.summary)) 31 | return SUCCESS 32 | 33 | HelpCommand() 34 | -------------------------------------------------------------------------------- /venv/bin/activate_this.py: -------------------------------------------------------------------------------- 1 | """By using execfile(this_file, dict(__file__=this_file)) you will 2 | activate this virtualenv environment. 3 | 4 | This can be used when you must use an existing Python interpreter, not 5 | the virtualenv bin/python 6 | """ 7 | 8 | try: 9 | __file__ 10 | except NameError: 11 | raise AssertionError( 12 | "You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))") 13 | import sys 14 | import os 15 | 16 | old_os_path = os.environ['PATH'] 17 | os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path 18 | base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 19 | if sys.platform == 'win32': 20 | site_packages = os.path.join(base, 'Lib', 'site-packages') 21 | else: 22 | site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages') 23 | prev_sys_path = list(sys.path) 24 | import site 25 | site.addsitedir(site_packages) 26 | sys.real_prefix = sys.prefix 27 | sys.prefix = base 28 | # Move the added items to the front of the path: 29 | new_sys_path = [] 30 | for item in list(sys.path): 31 | if item not in prev_sys_path: 32 | new_sys_path.append(item) 33 | sys.path.remove(item) 34 | sys.path[:0] = new_sys_path 35 | -------------------------------------------------------------------------------- /problem3.py: -------------------------------------------------------------------------------- 1 | # Project Euler Problem #3: Largest prime factor 2 | # The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? 3 | 4 | import math 5 | 6 | 7 | # checks if n is prime 8 | def is_prime(n): 9 | for x in range(2, int(math.sqrt(n) + 1)): 10 | if n % x == 0: 11 | return False 12 | return True 13 | 14 | 15 | # generator function, creates a sequence of prime numbers less than n 16 | def generate_primes(n): 17 | number = 2 18 | while number <= n: 19 | if is_prime(number): 20 | yield number 21 | number += 1 22 | 23 | 24 | # find prime factors of n: check first if n is prime; if not look through sequence of primes for lowest prime divisor; 25 | # when a divisor is found, recursively call the function with the quotient 26 | def find_prime_factors(n): 27 | prime_factors = [] 28 | if is_prime(n): 29 | prime_factors += [n] 30 | else: 31 | for x in generate_primes(n): 32 | if n % x == 0: 33 | prime_factors += [x] 34 | prime_factors += find_prime_factors(n / x) 35 | break 36 | return prime_factors 37 | 38 | 39 | print max(find_prime_factors(600851475143)) 40 | -------------------------------------------------------------------------------- /venv/bin/activate.csh: -------------------------------------------------------------------------------- 1 | # This file must be used with "source bin/activate.csh" *from csh*. 2 | # You cannot run it directly. 3 | # Created by Davide Di Blasi . 4 | 5 | alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc' 6 | 7 | # Unset irrelevant variables. 8 | deactivate nondestructive 9 | 10 | setenv VIRTUAL_ENV "/Users/john/yplan/euler/venv" 11 | 12 | set _OLD_VIRTUAL_PATH="$PATH" 13 | setenv PATH "$VIRTUAL_ENV/bin:$PATH" 14 | 15 | 16 | 17 | if ("" != "") then 18 | set env_name = "" 19 | else 20 | if (`basename "$VIRTUAL_ENV"` == "__") then 21 | # special case for Aspen magic directories 22 | # see http://www.zetadev.com/software/aspen/ 23 | set env_name = `basename \`dirname "$VIRTUAL_ENV"\`` 24 | else 25 | set env_name = `basename "$VIRTUAL_ENV"` 26 | endif 27 | endif 28 | 29 | # Could be in a non-interactive environment, 30 | # in which case, $prompt is undefined and we wouldn't 31 | # care about the prompt anyway. 32 | if ( $?prompt ) then 33 | set _OLD_VIRTUAL_PROMPT="$prompt" 34 | set prompt = "[$env_name] $prompt" 35 | endif 36 | 37 | unset env_name 38 | 39 | alias pydoc python -m pydoc 40 | 41 | rehash 42 | 43 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/bundle.py: -------------------------------------------------------------------------------- 1 | from pip.locations import build_prefix, src_prefix 2 | from pip.util import display_path, backup_dir 3 | from pip.log import logger 4 | from pip.exceptions import InstallationError 5 | from pip.commands.install import InstallCommand 6 | 7 | 8 | class BundleCommand(InstallCommand): 9 | name = 'bundle' 10 | usage = '%prog [OPTIONS] BUNDLE_NAME.pybundle PACKAGE_NAMES...' 11 | summary = 'Create pybundles (archives containing multiple packages)' 12 | bundle = True 13 | 14 | def __init__(self): 15 | super(BundleCommand, self).__init__() 16 | # bundle uses different default source and build dirs 17 | build_opt = self.parser.get_option("--build") 18 | build_opt.default = backup_dir(build_prefix, '-bundle') 19 | src_opt = self.parser.get_option("--src") 20 | src_opt.default = backup_dir(src_prefix, '-bundle') 21 | self.parser.set_defaults(**{ 22 | src_opt.dest: src_opt.default, 23 | build_opt.dest: build_opt.default, 24 | }) 25 | 26 | def run(self, options, args): 27 | if not args: 28 | raise InstallationError('You must give a bundle filename') 29 | # We have to get everything when creating a bundle: 30 | options.ignore_installed = True 31 | logger.notify('Putting temporary build files in %s and source/develop files in %s' 32 | % (display_path(options.build_dir), display_path(options.src_dir))) 33 | self.bundle_filename = args.pop(0) 34 | requirement_set = super(BundleCommand, self).run(options, args) 35 | return requirement_set 36 | 37 | 38 | BundleCommand() 39 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/uninstall.py: -------------------------------------------------------------------------------- 1 | from pip.req import InstallRequirement, RequirementSet, parse_requirements 2 | from pip.basecommand import Command 3 | from pip.exceptions import InstallationError 4 | 5 | 6 | class UninstallCommand(Command): 7 | name = 'uninstall' 8 | usage = '%prog [OPTIONS] PACKAGE_NAMES ...' 9 | summary = 'Uninstall packages' 10 | 11 | def __init__(self): 12 | super(UninstallCommand, self).__init__() 13 | self.parser.add_option( 14 | '-r', '--requirement', 15 | dest='requirements', 16 | action='append', 17 | default=[], 18 | metavar='FILENAME', 19 | help='Uninstall all the packages listed in the given requirements file. ' 20 | 'This option can be used multiple times.') 21 | self.parser.add_option( 22 | '-y', '--yes', 23 | dest='yes', 24 | action='store_true', 25 | help="Don't ask for confirmation of uninstall deletions.") 26 | 27 | def run(self, options, args): 28 | requirement_set = RequirementSet( 29 | build_dir=None, 30 | src_dir=None, 31 | download_dir=None) 32 | for name in args: 33 | requirement_set.add_requirement( 34 | InstallRequirement.from_line(name)) 35 | for filename in options.requirements: 36 | for req in parse_requirements(filename, options=options): 37 | requirement_set.add_requirement(req) 38 | if not requirement_set.has_requirements: 39 | raise InstallationError('You must give at least one requirement ' 40 | 'to %(name)s (see "pip help %(name)s")' % dict(name=self.name)) 41 | requirement_set.uninstall(auto_confirm=options.yes) 42 | 43 | UninstallCommand() 44 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/completion.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from pip.basecommand import Command 3 | 4 | BASE_COMPLETION = """ 5 | # pip %(shell)s completion start%(script)s# pip %(shell)s completion end 6 | """ 7 | 8 | COMPLETION_SCRIPTS = { 9 | 'bash': """ 10 | _pip_completion() 11 | { 12 | COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\ 13 | COMP_CWORD=$COMP_CWORD \\ 14 | PIP_AUTO_COMPLETE=1 $1 ) ) 15 | } 16 | complete -o default -F _pip_completion pip 17 | """, 'zsh': """ 18 | function _pip_completion { 19 | local words cword 20 | read -Ac words 21 | read -cn cword 22 | reply=( $( COMP_WORDS="$words[*]" \\ 23 | COMP_CWORD=$(( cword-1 )) \\ 24 | PIP_AUTO_COMPLETE=1 $words[1] ) ) 25 | } 26 | compctl -K _pip_completion pip 27 | """} 28 | 29 | 30 | class CompletionCommand(Command): 31 | name = 'completion' 32 | summary = 'A helper command to be used for command completion' 33 | hidden = True 34 | 35 | def __init__(self): 36 | super(CompletionCommand, self).__init__() 37 | self.parser.add_option( 38 | '--bash', '-b', 39 | action='store_const', 40 | const='bash', 41 | dest='shell', 42 | help='Emit completion code for bash') 43 | self.parser.add_option( 44 | '--zsh', '-z', 45 | action='store_const', 46 | const='zsh', 47 | dest='shell', 48 | help='Emit completion code for zsh') 49 | 50 | def run(self, options, args): 51 | """Prints the completion code of the given shell""" 52 | shells = COMPLETION_SCRIPTS.keys() 53 | shell_options = ['--'+shell for shell in sorted(shells)] 54 | if options.shell in shells: 55 | script = COMPLETION_SCRIPTS.get(options.shell, '') 56 | print(BASE_COMPLETION % {'script': script, 'shell': options.shell}) 57 | else: 58 | sys.stderr.write('ERROR: You must pass %s\n' % ' or '.join(shell_options)) 59 | 60 | CompletionCommand() 61 | -------------------------------------------------------------------------------- /venv/bin/activate: -------------------------------------------------------------------------------- 1 | # This file must be used with "source bin/activate" *from bash* 2 | # you cannot run it directly 3 | 4 | deactivate () { 5 | unset pydoc 6 | 7 | # reset old environment variables 8 | if [ -n "$_OLD_VIRTUAL_PATH" ] ; then 9 | PATH="$_OLD_VIRTUAL_PATH" 10 | export PATH 11 | unset _OLD_VIRTUAL_PATH 12 | fi 13 | if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then 14 | PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" 15 | export PYTHONHOME 16 | unset _OLD_VIRTUAL_PYTHONHOME 17 | fi 18 | 19 | # This should detect bash and zsh, which have a hash command that must 20 | # be called to get it to forget past commands. Without forgetting 21 | # past commands the $PATH changes we made may not be respected 22 | if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then 23 | hash -r 2>/dev/null 24 | fi 25 | 26 | if [ -n "$_OLD_VIRTUAL_PS1" ] ; then 27 | PS1="$_OLD_VIRTUAL_PS1" 28 | export PS1 29 | unset _OLD_VIRTUAL_PS1 30 | fi 31 | 32 | unset VIRTUAL_ENV 33 | if [ ! "$1" = "nondestructive" ] ; then 34 | # Self destruct! 35 | unset -f deactivate 36 | fi 37 | } 38 | 39 | # unset irrelevant variables 40 | deactivate nondestructive 41 | 42 | VIRTUAL_ENV="/Users/john/yplan/euler/venv" 43 | export VIRTUAL_ENV 44 | 45 | _OLD_VIRTUAL_PATH="$PATH" 46 | PATH="$VIRTUAL_ENV/bin:$PATH" 47 | export PATH 48 | 49 | # unset PYTHONHOME if set 50 | # this will fail if PYTHONHOME is set to the empty string (which is bad anyway) 51 | # could use `if (set -u; : $PYTHONHOME) ;` in bash 52 | if [ -n "$PYTHONHOME" ] ; then 53 | _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" 54 | unset PYTHONHOME 55 | fi 56 | 57 | if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then 58 | _OLD_VIRTUAL_PS1="$PS1" 59 | if [ "x" != x ] ; then 60 | PS1="$PS1" 61 | else 62 | if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then 63 | # special case for Aspen magic directories 64 | # see http://www.zetadev.com/software/aspen/ 65 | PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" 66 | else 67 | PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" 68 | fi 69 | fi 70 | export PS1 71 | fi 72 | 73 | alias pydoc="python -m pydoc" 74 | 75 | # This should detect bash and zsh, which have a hash command that must 76 | # be called to get it to forget past commands. Without forgetting 77 | # past commands the $PATH changes we made may not be respected 78 | if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then 79 | hash -r 2>/dev/null 80 | fi 81 | -------------------------------------------------------------------------------- /venv/bin/activate.fish: -------------------------------------------------------------------------------- 1 | # This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org) 2 | # you cannot run it directly 3 | 4 | function deactivate -d "Exit virtualenv and return to normal shell environment" 5 | # reset old environment variables 6 | if test -n "$_OLD_VIRTUAL_PATH" 7 | set -gx PATH $_OLD_VIRTUAL_PATH 8 | set -e _OLD_VIRTUAL_PATH 9 | end 10 | if test -n "$_OLD_VIRTUAL_PYTHONHOME" 11 | set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME 12 | set -e _OLD_VIRTUAL_PYTHONHOME 13 | end 14 | 15 | if test -n "$_OLD_FISH_PROMPT_OVERRIDE" 16 | functions -e fish_prompt 17 | set -e _OLD_FISH_PROMPT_OVERRIDE 18 | . ( begin 19 | printf "function fish_prompt\n\t#" 20 | functions _old_fish_prompt 21 | end | psub ) 22 | functions -e _old_fish_prompt 23 | end 24 | 25 | set -e VIRTUAL_ENV 26 | if test "$argv[1]" != "nondestructive" 27 | # Self destruct! 28 | functions -e deactivate 29 | end 30 | end 31 | 32 | # unset irrelevant variables 33 | deactivate nondestructive 34 | 35 | set -gx VIRTUAL_ENV "/Users/john/yplan/euler/venv" 36 | 37 | set -gx _OLD_VIRTUAL_PATH $PATH 38 | set -gx PATH "$VIRTUAL_ENV/bin" $PATH 39 | 40 | # unset PYTHONHOME if set 41 | if set -q PYTHONHOME 42 | set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME 43 | set -e PYTHONHOME 44 | end 45 | 46 | if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" 47 | # fish uses a function instead of an env var to generate the prompt. 48 | 49 | # save the current fish_prompt function as the function _old_fish_prompt 50 | . ( begin 51 | printf "function _old_fish_prompt\n\t#" 52 | functions fish_prompt 53 | end | psub ) 54 | 55 | # with the original prompt function renamed, we can override with our own. 56 | function fish_prompt 57 | # Prompt override? 58 | if test -n "" 59 | printf "%s%s%s" "" (set_color normal) (_old_fish_prompt) 60 | return 61 | end 62 | # ...Otherwise, prepend env 63 | set -l _checkbase (basename "$VIRTUAL_ENV") 64 | if test $_checkbase = "__" 65 | # special case for Aspen magic directories 66 | # see http://www.zetadev.com/software/aspen/ 67 | printf "%s[%s]%s %s" (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) (_old_fish_prompt) 68 | else 69 | printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt) 70 | end 71 | end 72 | 73 | set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" 74 | end 75 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/locations.py: -------------------------------------------------------------------------------- 1 | """Locations where we look for configs, install stuff, etc""" 2 | 3 | import sys 4 | import site 5 | import os 6 | import tempfile 7 | from pip.backwardcompat import get_python_lib 8 | 9 | 10 | def running_under_virtualenv(): 11 | """ 12 | Return True if we're running inside a virtualenv, False otherwise. 13 | 14 | """ 15 | return hasattr(sys, 'real_prefix') 16 | 17 | 18 | def virtualenv_no_global(): 19 | """ 20 | Return True if in a venv and no system site packages. 21 | """ 22 | #this mirrors the logic in virtualenv.py for locating the no-global-site-packages.txt file 23 | site_mod_dir = os.path.dirname(os.path.abspath(site.__file__)) 24 | no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt') 25 | if running_under_virtualenv() and os.path.isfile(no_global_file): 26 | return True 27 | 28 | 29 | if running_under_virtualenv(): 30 | build_prefix = os.path.join(sys.prefix, 'build') 31 | src_prefix = os.path.join(sys.prefix, 'src') 32 | else: 33 | # Use tempfile to create a temporary folder for build 34 | # Note: we are NOT using mkdtemp so we can have a consistent build dir 35 | build_prefix = os.path.join(tempfile.gettempdir(), 'pip-build') 36 | 37 | ## FIXME: keep src in cwd for now (it is not a temporary folder) 38 | try: 39 | src_prefix = os.path.join(os.getcwd(), 'src') 40 | except OSError: 41 | # In case the current working directory has been renamed or deleted 42 | sys.exit("The folder you are executing pip from can no longer be found.") 43 | 44 | # under Mac OS X + virtualenv sys.prefix is not properly resolved 45 | # it is something like /path/to/python/bin/.. 46 | build_prefix = os.path.abspath(build_prefix) 47 | src_prefix = os.path.abspath(src_prefix) 48 | 49 | # FIXME doesn't account for venv linked to global site-packages 50 | 51 | site_packages = get_python_lib() 52 | user_dir = os.path.expanduser('~') 53 | if sys.platform == 'win32': 54 | bin_py = os.path.join(sys.prefix, 'Scripts') 55 | # buildout uses 'bin' on Windows too? 56 | if not os.path.exists(bin_py): 57 | bin_py = os.path.join(sys.prefix, 'bin') 58 | default_storage_dir = os.path.join(user_dir, 'pip') 59 | default_config_file = os.path.join(default_storage_dir, 'pip.ini') 60 | default_log_file = os.path.join(default_storage_dir, 'pip.log') 61 | else: 62 | bin_py = os.path.join(sys.prefix, 'bin') 63 | default_storage_dir = os.path.join(user_dir, '.pip') 64 | default_config_file = os.path.join(default_storage_dir, 'pip.conf') 65 | default_log_file = os.path.join(default_storage_dir, 'pip.log') 66 | # Forcing to use /usr/local/bin for standard Mac OS X framework installs 67 | # Also log to ~/Library/Logs/ for use with the Console.app log viewer 68 | if sys.platform[:6] == 'darwin' and sys.prefix[:16] == '/System/Library/': 69 | bin_py = '/usr/local/bin' 70 | default_log_file = os.path.join(user_dir, 'Library/Logs/pip.log') 71 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/backwardcompat.py: -------------------------------------------------------------------------------- 1 | """Stuff that differs in different Python versions""" 2 | 3 | import os 4 | import imp 5 | import sys 6 | import site 7 | 8 | __all__ = ['WindowsError'] 9 | 10 | uses_pycache = hasattr(imp,'cache_from_source') 11 | 12 | try: 13 | WindowsError = WindowsError 14 | except NameError: 15 | class NeverUsedException(Exception): 16 | """this exception should never be raised""" 17 | WindowsError = NeverUsedException 18 | 19 | 20 | console_encoding = sys.__stdout__.encoding 21 | 22 | if sys.version_info >= (3,): 23 | from io import StringIO, BytesIO 24 | from functools import reduce 25 | from urllib.error import URLError, HTTPError 26 | from queue import Queue, Empty 27 | from urllib.request import url2pathname 28 | from urllib.request import urlretrieve 29 | from email import message as emailmessage 30 | import urllib.parse as urllib 31 | import urllib.request as urllib2 32 | import configparser as ConfigParser 33 | import xmlrpc.client as xmlrpclib 34 | import urllib.parse as urlparse 35 | import http.client as httplib 36 | 37 | def cmp(a, b): 38 | return (a > b) - (a < b) 39 | 40 | def b(s): 41 | return s.encode('utf-8') 42 | 43 | def u(s): 44 | return s.decode('utf-8') 45 | 46 | def console_to_str(s): 47 | try: 48 | return s.decode(console_encoding) 49 | except UnicodeDecodeError: 50 | return s.decode('utf_8') 51 | 52 | def fwrite(f, s): 53 | f.buffer.write(b(s)) 54 | 55 | bytes = bytes 56 | string_types = (str,) 57 | raw_input = input 58 | else: 59 | from cStringIO import StringIO 60 | from urllib2 import URLError, HTTPError 61 | from Queue import Queue, Empty 62 | from urllib import url2pathname, urlretrieve 63 | from email import Message as emailmessage 64 | import urllib 65 | import urllib2 66 | import urlparse 67 | import ConfigParser 68 | import xmlrpclib 69 | import httplib 70 | 71 | def b(s): 72 | return s 73 | 74 | def u(s): 75 | return s 76 | 77 | def console_to_str(s): 78 | return s 79 | 80 | def fwrite(f, s): 81 | f.write(s) 82 | 83 | bytes = str 84 | string_types = (basestring,) 85 | reduce = reduce 86 | cmp = cmp 87 | raw_input = raw_input 88 | BytesIO = StringIO 89 | 90 | 91 | from distutils.sysconfig import get_python_lib, get_python_version 92 | 93 | #site.USER_SITE was created in py2.6 94 | user_site = getattr(site,'USER_SITE',None) 95 | 96 | def product(*args, **kwds): 97 | # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy 98 | # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111 99 | pools = list(map(tuple, args)) * kwds.get('repeat', 1) 100 | result = [[]] 101 | for pool in pools: 102 | result = [x+[y] for x in result for y in pool] 103 | for prod in result: 104 | yield tuple(prod) 105 | 106 | def home_lib(home): 107 | """Return the lib dir under the 'home' installation scheme""" 108 | if hasattr(sys, 'pypy_version_info'): 109 | lib = 'site-packages' 110 | else: 111 | lib = os.path.join('lib', 'python') 112 | return os.path.join(home, lib) 113 | -------------------------------------------------------------------------------- /venv/lib/python2.7/distutils/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import warnings 4 | import imp 5 | import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib 6 | # Important! To work on pypy, this must be a module that resides in the 7 | # lib-python/modified-x.y.z directory 8 | 9 | dirname = os.path.dirname 10 | 11 | distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils') 12 | if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)): 13 | warnings.warn( 14 | "The virtualenv distutils package at %s appears to be in the same location as the system distutils?") 15 | else: 16 | __path__.insert(0, distutils_path) 17 | real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY)) 18 | # Copy the relevant attributes 19 | try: 20 | __revision__ = real_distutils.__revision__ 21 | except AttributeError: 22 | pass 23 | __version__ = real_distutils.__version__ 24 | 25 | from distutils import dist, sysconfig 26 | 27 | try: 28 | basestring 29 | except NameError: 30 | basestring = str 31 | 32 | ## patch build_ext (distutils doesn't know how to get the libs directory 33 | ## path on windows - it hardcodes the paths around the patched sys.prefix) 34 | 35 | if sys.platform == 'win32': 36 | from distutils.command.build_ext import build_ext as old_build_ext 37 | class build_ext(old_build_ext): 38 | def finalize_options (self): 39 | if self.library_dirs is None: 40 | self.library_dirs = [] 41 | elif isinstance(self.library_dirs, basestring): 42 | self.library_dirs = self.library_dirs.split(os.pathsep) 43 | 44 | self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs")) 45 | old_build_ext.finalize_options(self) 46 | 47 | from distutils.command import build_ext as build_ext_module 48 | build_ext_module.build_ext = build_ext 49 | 50 | ## distutils.dist patches: 51 | 52 | old_find_config_files = dist.Distribution.find_config_files 53 | def find_config_files(self): 54 | found = old_find_config_files(self) 55 | system_distutils = os.path.join(distutils_path, 'distutils.cfg') 56 | #if os.path.exists(system_distutils): 57 | # found.insert(0, system_distutils) 58 | # What to call the per-user config file 59 | if os.name == 'posix': 60 | user_filename = ".pydistutils.cfg" 61 | else: 62 | user_filename = "pydistutils.cfg" 63 | user_filename = os.path.join(sys.prefix, user_filename) 64 | if os.path.isfile(user_filename): 65 | for item in list(found): 66 | if item.endswith('pydistutils.cfg'): 67 | found.remove(item) 68 | found.append(user_filename) 69 | return found 70 | dist.Distribution.find_config_files = find_config_files 71 | 72 | ## distutils.sysconfig patches: 73 | 74 | old_get_python_inc = sysconfig.get_python_inc 75 | def sysconfig_get_python_inc(plat_specific=0, prefix=None): 76 | if prefix is None: 77 | prefix = sys.real_prefix 78 | return old_get_python_inc(plat_specific, prefix) 79 | sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__ 80 | sysconfig.get_python_inc = sysconfig_get_python_inc 81 | 82 | old_get_python_lib = sysconfig.get_python_lib 83 | def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None): 84 | if standard_lib and prefix is None: 85 | prefix = sys.real_prefix 86 | return old_get_python_lib(plat_specific, standard_lib, prefix) 87 | sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__ 88 | sysconfig.get_python_lib = sysconfig_get_python_lib 89 | 90 | old_get_config_vars = sysconfig.get_config_vars 91 | def sysconfig_get_config_vars(*args): 92 | real_vars = old_get_config_vars(*args) 93 | if sys.platform == 'win32': 94 | lib_dir = os.path.join(sys.real_prefix, "libs") 95 | if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars: 96 | real_vars['LIBDIR'] = lib_dir # asked for all 97 | elif isinstance(real_vars, list) and 'LIBDIR' in args: 98 | real_vars = real_vars + [lib_dir] # asked for list 99 | return real_vars 100 | sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__ 101 | sysconfig.get_config_vars = sysconfig_get_config_vars 102 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/freeze.py: -------------------------------------------------------------------------------- 1 | import re 2 | import sys 3 | import pkg_resources 4 | import pip 5 | from pip.req import InstallRequirement 6 | from pip.log import logger 7 | from pip.basecommand import Command 8 | from pip.util import get_installed_distributions 9 | 10 | 11 | class FreezeCommand(Command): 12 | name = 'freeze' 13 | usage = '%prog [OPTIONS]' 14 | summary = 'Output all currently installed packages (exact versions) to stdout' 15 | 16 | def __init__(self): 17 | super(FreezeCommand, self).__init__() 18 | self.parser.add_option( 19 | '-r', '--requirement', 20 | dest='requirement', 21 | action='store', 22 | default=None, 23 | metavar='FILENAME', 24 | help='Use the given requirements file as a hint about how to generate the new frozen requirements') 25 | self.parser.add_option( 26 | '-f', '--find-links', 27 | dest='find_links', 28 | action='append', 29 | default=[], 30 | metavar='URL', 31 | help='URL for finding packages, which will be added to the frozen requirements file') 32 | self.parser.add_option( 33 | '-l', '--local', 34 | dest='local', 35 | action='store_true', 36 | default=False, 37 | help='If in a virtualenv, do not report globally-installed packages') 38 | 39 | def setup_logging(self): 40 | logger.move_stdout_to_stderr() 41 | 42 | def run(self, options, args): 43 | requirement = options.requirement 44 | find_links = options.find_links or [] 45 | local_only = options.local 46 | ## FIXME: Obviously this should be settable: 47 | find_tags = False 48 | skip_match = None 49 | 50 | skip_regex = options.skip_requirements_regex 51 | if skip_regex: 52 | skip_match = re.compile(skip_regex) 53 | 54 | dependency_links = [] 55 | 56 | f = sys.stdout 57 | 58 | for dist in pkg_resources.working_set: 59 | if dist.has_metadata('dependency_links.txt'): 60 | dependency_links.extend(dist.get_metadata_lines('dependency_links.txt')) 61 | for link in find_links: 62 | if '#egg=' in link: 63 | dependency_links.append(link) 64 | for link in find_links: 65 | f.write('-f %s\n' % link) 66 | installations = {} 67 | for dist in get_installed_distributions(local_only=local_only): 68 | req = pip.FrozenRequirement.from_dist(dist, dependency_links, find_tags=find_tags) 69 | installations[req.name] = req 70 | if requirement: 71 | req_f = open(requirement) 72 | for line in req_f: 73 | if not line.strip() or line.strip().startswith('#'): 74 | f.write(line) 75 | continue 76 | if skip_match and skip_match.search(line): 77 | f.write(line) 78 | continue 79 | elif line.startswith('-e') or line.startswith('--editable'): 80 | if line.startswith('-e'): 81 | line = line[2:].strip() 82 | else: 83 | line = line[len('--editable'):].strip().lstrip('=') 84 | line_req = InstallRequirement.from_editable(line, default_vcs=options.default_vcs) 85 | elif (line.startswith('-r') or line.startswith('--requirement') 86 | or line.startswith('-Z') or line.startswith('--always-unzip') 87 | or line.startswith('-f') or line.startswith('-i') 88 | or line.startswith('--extra-index-url') 89 | or line.startswith('--find-links') 90 | or line.startswith('--index-url')): 91 | f.write(line) 92 | continue 93 | else: 94 | line_req = InstallRequirement.from_line(line) 95 | if not line_req.name: 96 | logger.notify("Skipping line because it's not clear what it would install: %s" 97 | % line.strip()) 98 | logger.notify(" (add #egg=PackageName to the URL to avoid this warning)") 99 | continue 100 | if line_req.name not in installations: 101 | logger.warn("Requirement file contains %s, but that package is not installed" 102 | % line.strip()) 103 | continue 104 | f.write(str(installations[line_req.name])) 105 | del installations[line_req.name] 106 | f.write('## The following requirements were added by pip --freeze:\n') 107 | for installation in sorted(installations.values(), key=lambda x: x.name): 108 | f.write(str(installation)) 109 | 110 | 111 | FreezeCommand() 112 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/search.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import textwrap 3 | import pkg_resources 4 | import pip.download 5 | from pip.basecommand import Command, SUCCESS 6 | from pip.util import get_terminal_size 7 | from pip.log import logger 8 | from pip.backwardcompat import xmlrpclib, reduce, cmp 9 | from pip.exceptions import CommandError 10 | from pip.status_codes import NO_MATCHES_FOUND 11 | from distutils.version import StrictVersion, LooseVersion 12 | 13 | 14 | class SearchCommand(Command): 15 | name = 'search' 16 | usage = '%prog QUERY' 17 | summary = 'Search PyPI' 18 | 19 | def __init__(self): 20 | super(SearchCommand, self).__init__() 21 | self.parser.add_option( 22 | '--index', 23 | dest='index', 24 | metavar='URL', 25 | default='http://pypi.python.org/pypi', 26 | help='Base URL of Python Package Index (default %default)') 27 | 28 | def run(self, options, args): 29 | if not args: 30 | raise CommandError('Missing required argument (search query).') 31 | query = args 32 | index_url = options.index 33 | 34 | pypi_hits = self.search(query, index_url) 35 | hits = transform_hits(pypi_hits) 36 | 37 | terminal_width = None 38 | if sys.stdout.isatty(): 39 | terminal_width = get_terminal_size()[0] 40 | 41 | print_results(hits, terminal_width=terminal_width) 42 | if pypi_hits: 43 | return SUCCESS 44 | return NO_MATCHES_FOUND 45 | 46 | def search(self, query, index_url): 47 | pypi = xmlrpclib.ServerProxy(index_url, pip.download.xmlrpclib_transport) 48 | hits = pypi.search({'name': query, 'summary': query}, 'or') 49 | return hits 50 | 51 | 52 | def transform_hits(hits): 53 | """ 54 | The list from pypi is really a list of versions. We want a list of 55 | packages with the list of versions stored inline. This converts the 56 | list from pypi into one we can use. 57 | """ 58 | packages = {} 59 | for hit in hits: 60 | name = hit['name'] 61 | summary = hit['summary'] 62 | version = hit['version'] 63 | score = hit['_pypi_ordering'] 64 | if score is None: 65 | score = 0 66 | 67 | if name not in packages.keys(): 68 | packages[name] = {'name': name, 'summary': summary, 'versions': [version], 'score': score} 69 | else: 70 | packages[name]['versions'].append(version) 71 | 72 | # if this is the highest version, replace summary and score 73 | if version == highest_version(packages[name]['versions']): 74 | packages[name]['summary'] = summary 75 | packages[name]['score'] = score 76 | 77 | # each record has a unique name now, so we will convert the dict into a list sorted by score 78 | package_list = sorted(packages.values(), key=lambda x: x['score'], reverse=True) 79 | return package_list 80 | 81 | 82 | def print_results(hits, name_column_width=25, terminal_width=None): 83 | installed_packages = [p.project_name for p in pkg_resources.working_set] 84 | for hit in hits: 85 | name = hit['name'] 86 | summary = hit['summary'] or '' 87 | if terminal_width is not None: 88 | # wrap and indent summary to fit terminal 89 | summary = textwrap.wrap(summary, terminal_width - name_column_width - 5) 90 | summary = ('\n' + ' ' * (name_column_width + 3)).join(summary) 91 | line = '%s - %s' % (name.ljust(name_column_width), summary) 92 | try: 93 | logger.notify(line) 94 | if name in installed_packages: 95 | dist = pkg_resources.get_distribution(name) 96 | logger.indent += 2 97 | try: 98 | latest = highest_version(hit['versions']) 99 | if dist.version == latest: 100 | logger.notify('INSTALLED: %s (latest)' % dist.version) 101 | else: 102 | logger.notify('INSTALLED: %s' % dist.version) 103 | logger.notify('LATEST: %s' % latest) 104 | finally: 105 | logger.indent -= 2 106 | except UnicodeEncodeError: 107 | pass 108 | 109 | 110 | def compare_versions(version1, version2): 111 | try: 112 | return cmp(StrictVersion(version1), StrictVersion(version2)) 113 | # in case of abnormal version number, fall back to LooseVersion 114 | except ValueError: 115 | pass 116 | try: 117 | return cmp(LooseVersion(version1), LooseVersion(version2)) 118 | except TypeError: 119 | # certain LooseVersion comparions raise due to unorderable types, 120 | # fallback to string comparison 121 | return cmp([str(v) for v in LooseVersion(version1).version], 122 | [str(v) for v in LooseVersion(version2).version]) 123 | 124 | 125 | def highest_version(versions): 126 | return reduce((lambda v1, v2: compare_versions(v1, v2) == 1 and v1 or v2), versions) 127 | 128 | 129 | SearchCommand() 130 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/bazaar.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | import re 4 | from pip.backwardcompat import urlparse 5 | from pip.log import logger 6 | from pip.util import rmtree, display_path, call_subprocess 7 | from pip.vcs import vcs, VersionControl 8 | from pip.download import path_to_url2 9 | 10 | 11 | class Bazaar(VersionControl): 12 | name = 'bzr' 13 | dirname = '.bzr' 14 | repo_name = 'branch' 15 | bundle_file = 'bzr-branch.txt' 16 | schemes = ('bzr', 'bzr+http', 'bzr+https', 'bzr+ssh', 'bzr+sftp', 'bzr+ftp', 'bzr+lp') 17 | guide = ('# This was a Bazaar branch; to make it a branch again run:\n' 18 | 'bzr branch -r %(rev)s %(url)s .\n') 19 | 20 | def __init__(self, url=None, *args, **kwargs): 21 | super(Bazaar, self).__init__(url, *args, **kwargs) 22 | # Python >= 2.7.4, 3.3 doesn't have uses_fragment or non_hierarchical 23 | # Register lp but do not expose as a scheme to support bzr+lp. 24 | if getattr(urlparse, 'uses_fragment', None): 25 | urlparse.uses_fragment.extend(['lp']) 26 | urlparse.non_hierarchical.extend(['lp']) 27 | 28 | def parse_vcs_bundle_file(self, content): 29 | url = rev = None 30 | for line in content.splitlines(): 31 | if not line.strip() or line.strip().startswith('#'): 32 | continue 33 | match = re.search(r'^bzr\s*branch\s*-r\s*(\d*)', line) 34 | if match: 35 | rev = match.group(1).strip() 36 | url = line[match.end():].strip().split(None, 1)[0] 37 | if url and rev: 38 | return url, rev 39 | return None, None 40 | 41 | def export(self, location): 42 | """Export the Bazaar repository at the url to the destination location""" 43 | temp_dir = tempfile.mkdtemp('-export', 'pip-') 44 | self.unpack(temp_dir) 45 | if os.path.exists(location): 46 | # Remove the location to make sure Bazaar can export it correctly 47 | rmtree(location) 48 | try: 49 | call_subprocess([self.cmd, 'export', location], cwd=temp_dir, 50 | filter_stdout=self._filter, show_stdout=False) 51 | finally: 52 | rmtree(temp_dir) 53 | 54 | def switch(self, dest, url, rev_options): 55 | call_subprocess([self.cmd, 'switch', url], cwd=dest) 56 | 57 | def update(self, dest, rev_options): 58 | call_subprocess( 59 | [self.cmd, 'pull', '-q'] + rev_options, cwd=dest) 60 | 61 | def obtain(self, dest): 62 | url, rev = self.get_url_rev() 63 | if rev: 64 | rev_options = ['-r', rev] 65 | rev_display = ' (to revision %s)' % rev 66 | else: 67 | rev_options = [] 68 | rev_display = '' 69 | if self.check_destination(dest, url, rev_options, rev_display): 70 | logger.notify('Checking out %s%s to %s' 71 | % (url, rev_display, display_path(dest))) 72 | call_subprocess( 73 | [self.cmd, 'branch', '-q'] + rev_options + [url, dest]) 74 | 75 | def get_url_rev(self): 76 | # hotfix the URL scheme after removing bzr+ from bzr+ssh:// readd it 77 | url, rev = super(Bazaar, self).get_url_rev() 78 | if url.startswith('ssh://'): 79 | url = 'bzr+' + url 80 | return url, rev 81 | 82 | def get_url(self, location): 83 | urls = call_subprocess( 84 | [self.cmd, 'info'], show_stdout=False, cwd=location) 85 | for line in urls.splitlines(): 86 | line = line.strip() 87 | for x in ('checkout of branch: ', 88 | 'parent branch: '): 89 | if line.startswith(x): 90 | repo = line.split(x)[1] 91 | if self._is_local_repository(repo): 92 | return path_to_url2(repo) 93 | return repo 94 | return None 95 | 96 | def get_revision(self, location): 97 | revision = call_subprocess( 98 | [self.cmd, 'revno'], show_stdout=False, cwd=location) 99 | return revision.splitlines()[-1] 100 | 101 | def get_tag_revs(self, location): 102 | tags = call_subprocess( 103 | [self.cmd, 'tags'], show_stdout=False, cwd=location) 104 | tag_revs = [] 105 | for line in tags.splitlines(): 106 | tags_match = re.search(r'([.\w-]+)\s*(.*)$', line) 107 | if tags_match: 108 | tag = tags_match.group(1) 109 | rev = tags_match.group(2) 110 | tag_revs.append((rev.strip(), tag.strip())) 111 | return dict(tag_revs) 112 | 113 | def get_src_requirement(self, dist, location, find_tags): 114 | repo = self.get_url(location) 115 | if not repo.lower().startswith('bzr:'): 116 | repo = 'bzr+' + repo 117 | egg_project_name = dist.egg_name().split('-', 1)[0] 118 | if not repo: 119 | return None 120 | current_rev = self.get_revision(location) 121 | tag_revs = self.get_tag_revs(location) 122 | 123 | if current_rev in tag_revs: 124 | # It's a tag 125 | full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev]) 126 | else: 127 | full_egg_name = '%s-dev_r%s' % (dist.egg_name(), current_rev) 128 | return '%s@%s#egg=%s' % (repo, current_rev, full_egg_name) 129 | 130 | 131 | vcs.register(Bazaar) 132 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/mercurial.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | import re 4 | import sys 5 | from pip.util import call_subprocess 6 | from pip.util import display_path, rmtree 7 | from pip.log import logger 8 | from pip.vcs import vcs, VersionControl 9 | from pip.download import path_to_url2 10 | from pip.backwardcompat import ConfigParser 11 | 12 | 13 | class Mercurial(VersionControl): 14 | name = 'hg' 15 | dirname = '.hg' 16 | repo_name = 'clone' 17 | schemes = ('hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http') 18 | bundle_file = 'hg-clone.txt' 19 | guide = ('# This was a Mercurial repo; to make it a repo again run:\n' 20 | 'hg init\nhg pull %(url)s\nhg update -r %(rev)s\n') 21 | 22 | def parse_vcs_bundle_file(self, content): 23 | url = rev = None 24 | for line in content.splitlines(): 25 | if not line.strip() or line.strip().startswith('#'): 26 | continue 27 | url_match = re.search(r'hg\s*pull\s*(.*)\s*', line) 28 | if url_match: 29 | url = url_match.group(1).strip() 30 | rev_match = re.search(r'^hg\s*update\s*-r\s*(.*)\s*', line) 31 | if rev_match: 32 | rev = rev_match.group(1).strip() 33 | if url and rev: 34 | return url, rev 35 | return None, None 36 | 37 | def export(self, location): 38 | """Export the Hg repository at the url to the destination location""" 39 | temp_dir = tempfile.mkdtemp('-export', 'pip-') 40 | self.unpack(temp_dir) 41 | try: 42 | call_subprocess( 43 | [self.cmd, 'archive', location], 44 | filter_stdout=self._filter, show_stdout=False, cwd=temp_dir) 45 | finally: 46 | rmtree(temp_dir) 47 | 48 | def switch(self, dest, url, rev_options): 49 | repo_config = os.path.join(dest, self.dirname, 'hgrc') 50 | config = ConfigParser.SafeConfigParser() 51 | try: 52 | config.read(repo_config) 53 | config.set('paths', 'default', url) 54 | config_file = open(repo_config, 'w') 55 | config.write(config_file) 56 | config_file.close() 57 | except (OSError, ConfigParser.NoSectionError): 58 | e = sys.exc_info()[1] 59 | logger.warn( 60 | 'Could not switch Mercurial repository to %s: %s' 61 | % (url, e)) 62 | else: 63 | call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest) 64 | 65 | def update(self, dest, rev_options): 66 | call_subprocess([self.cmd, 'pull', '-q'], cwd=dest) 67 | call_subprocess( 68 | [self.cmd, 'update', '-q'] + rev_options, cwd=dest) 69 | 70 | def obtain(self, dest): 71 | url, rev = self.get_url_rev() 72 | if rev: 73 | rev_options = [rev] 74 | rev_display = ' (to revision %s)' % rev 75 | else: 76 | rev_options = [] 77 | rev_display = '' 78 | if self.check_destination(dest, url, rev_options, rev_display): 79 | logger.notify('Cloning hg %s%s to %s' 80 | % (url, rev_display, display_path(dest))) 81 | call_subprocess([self.cmd, 'clone', '--noupdate', '-q', url, dest]) 82 | call_subprocess([self.cmd, 'update', '-q'] + rev_options, cwd=dest) 83 | 84 | def get_url(self, location): 85 | url = call_subprocess( 86 | [self.cmd, 'showconfig', 'paths.default'], 87 | show_stdout=False, cwd=location).strip() 88 | if self._is_local_repository(url): 89 | url = path_to_url2(url) 90 | return url.strip() 91 | 92 | def get_tag_revs(self, location): 93 | tags = call_subprocess( 94 | [self.cmd, 'tags'], show_stdout=False, cwd=location) 95 | tag_revs = [] 96 | for line in tags.splitlines(): 97 | tags_match = re.search(r'([\w\d\.-]+)\s*([\d]+):.*$', line) 98 | if tags_match: 99 | tag = tags_match.group(1) 100 | rev = tags_match.group(2) 101 | if "tip" != tag: 102 | tag_revs.append((rev.strip(), tag.strip())) 103 | return dict(tag_revs) 104 | 105 | def get_branch_revs(self, location): 106 | branches = call_subprocess( 107 | [self.cmd, 'branches'], show_stdout=False, cwd=location) 108 | branch_revs = [] 109 | for line in branches.splitlines(): 110 | branches_match = re.search(r'([\w\d\.-]+)\s*([\d]+):.*$', line) 111 | if branches_match: 112 | branch = branches_match.group(1) 113 | rev = branches_match.group(2) 114 | if "default" != branch: 115 | branch_revs.append((rev.strip(), branch.strip())) 116 | return dict(branch_revs) 117 | 118 | def get_revision(self, location): 119 | current_revision = call_subprocess( 120 | [self.cmd, 'parents', '--template={rev}'], 121 | show_stdout=False, cwd=location).strip() 122 | return current_revision 123 | 124 | def get_revision_hash(self, location): 125 | current_rev_hash = call_subprocess( 126 | [self.cmd, 'parents', '--template={node}'], 127 | show_stdout=False, cwd=location).strip() 128 | return current_rev_hash 129 | 130 | def get_src_requirement(self, dist, location, find_tags): 131 | repo = self.get_url(location) 132 | if not repo.lower().startswith('hg:'): 133 | repo = 'hg+' + repo 134 | egg_project_name = dist.egg_name().split('-', 1)[0] 135 | if not repo: 136 | return None 137 | current_rev = self.get_revision(location) 138 | current_rev_hash = self.get_revision_hash(location) 139 | tag_revs = self.get_tag_revs(location) 140 | branch_revs = self.get_branch_revs(location) 141 | if current_rev in tag_revs: 142 | # It's a tag 143 | full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev]) 144 | elif current_rev in branch_revs: 145 | # It's the tip of a branch 146 | full_egg_name = '%s-%s' % (egg_project_name, branch_revs[current_rev]) 147 | else: 148 | full_egg_name = '%s-dev' % egg_project_name 149 | return '%s@%s#egg=%s' % (repo, current_rev_hash, full_egg_name) 150 | 151 | vcs.register(Mercurial) 152 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/log.py: -------------------------------------------------------------------------------- 1 | """Logging 2 | """ 3 | 4 | import sys 5 | import logging 6 | 7 | import pip.backwardcompat 8 | 9 | 10 | class Logger(object): 11 | 12 | """ 13 | Logging object for use in command-line script. Allows ranges of 14 | levels, to avoid some redundancy of displayed information. 15 | """ 16 | 17 | VERBOSE_DEBUG = logging.DEBUG-1 18 | DEBUG = logging.DEBUG 19 | INFO = logging.INFO 20 | NOTIFY = (logging.INFO+logging.WARN)/2 21 | WARN = WARNING = logging.WARN 22 | ERROR = logging.ERROR 23 | FATAL = logging.FATAL 24 | 25 | LEVELS = [VERBOSE_DEBUG, DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL] 26 | 27 | def __init__(self): 28 | self.consumers = [] 29 | self.indent = 0 30 | self.explicit_levels = False 31 | self.in_progress = None 32 | self.in_progress_hanging = False 33 | 34 | def debug(self, msg, *args, **kw): 35 | self.log(self.DEBUG, msg, *args, **kw) 36 | 37 | def info(self, msg, *args, **kw): 38 | self.log(self.INFO, msg, *args, **kw) 39 | 40 | def notify(self, msg, *args, **kw): 41 | self.log(self.NOTIFY, msg, *args, **kw) 42 | 43 | def warn(self, msg, *args, **kw): 44 | self.log(self.WARN, msg, *args, **kw) 45 | 46 | def error(self, msg, *args, **kw): 47 | self.log(self.WARN, msg, *args, **kw) 48 | 49 | def fatal(self, msg, *args, **kw): 50 | self.log(self.FATAL, msg, *args, **kw) 51 | 52 | def log(self, level, msg, *args, **kw): 53 | if args: 54 | if kw: 55 | raise TypeError( 56 | "You may give positional or keyword arguments, not both") 57 | args = args or kw 58 | rendered = None 59 | for consumer_level, consumer in self.consumers: 60 | if self.level_matches(level, consumer_level): 61 | if (self.in_progress_hanging 62 | and consumer in (sys.stdout, sys.stderr)): 63 | self.in_progress_hanging = False 64 | sys.stdout.write('\n') 65 | sys.stdout.flush() 66 | if rendered is None: 67 | if args: 68 | rendered = msg % args 69 | else: 70 | rendered = msg 71 | rendered = ' '*self.indent + rendered 72 | if self.explicit_levels: 73 | ## FIXME: should this be a name, not a level number? 74 | rendered = '%02i %s' % (level, rendered) 75 | if hasattr(consumer, 'write'): 76 | rendered += '\n' 77 | pip.backwardcompat.fwrite(consumer, rendered) 78 | else: 79 | consumer(rendered) 80 | 81 | def _show_progress(self): 82 | """Should we display download progress?""" 83 | return (self.stdout_level_matches(self.NOTIFY) and sys.stdout.isatty()) 84 | 85 | def start_progress(self, msg): 86 | assert not self.in_progress, ( 87 | "Tried to start_progress(%r) while in_progress %r" 88 | % (msg, self.in_progress)) 89 | if self._show_progress(): 90 | sys.stdout.write(' '*self.indent + msg) 91 | sys.stdout.flush() 92 | self.in_progress_hanging = True 93 | else: 94 | self.in_progress_hanging = False 95 | self.in_progress = msg 96 | self.last_message = None 97 | 98 | def end_progress(self, msg='done.'): 99 | assert self.in_progress, ( 100 | "Tried to end_progress without start_progress") 101 | if self._show_progress(): 102 | if not self.in_progress_hanging: 103 | # Some message has been printed out since start_progress 104 | sys.stdout.write('...' + self.in_progress + msg + '\n') 105 | sys.stdout.flush() 106 | else: 107 | # These erase any messages shown with show_progress (besides .'s) 108 | logger.show_progress('') 109 | logger.show_progress('') 110 | sys.stdout.write(msg + '\n') 111 | sys.stdout.flush() 112 | self.in_progress = None 113 | self.in_progress_hanging = False 114 | 115 | def show_progress(self, message=None): 116 | """If we are in a progress scope, and no log messages have been 117 | shown, write out another '.'""" 118 | if self.in_progress_hanging: 119 | if message is None: 120 | sys.stdout.write('.') 121 | sys.stdout.flush() 122 | else: 123 | if self.last_message: 124 | padding = ' ' * max(0, len(self.last_message)-len(message)) 125 | else: 126 | padding = '' 127 | sys.stdout.write('\r%s%s%s%s' % (' '*self.indent, self.in_progress, message, padding)) 128 | sys.stdout.flush() 129 | self.last_message = message 130 | 131 | def stdout_level_matches(self, level): 132 | """Returns true if a message at this level will go to stdout""" 133 | return self.level_matches(level, self._stdout_level()) 134 | 135 | def _stdout_level(self): 136 | """Returns the level that stdout runs at""" 137 | for level, consumer in self.consumers: 138 | if consumer is sys.stdout: 139 | return level 140 | return self.FATAL 141 | 142 | def level_matches(self, level, consumer_level): 143 | """ 144 | >>> l = Logger() 145 | >>> l.level_matches(3, 4) 146 | False 147 | >>> l.level_matches(3, 2) 148 | True 149 | >>> l.level_matches(slice(None, 3), 3) 150 | False 151 | >>> l.level_matches(slice(None, 3), 2) 152 | True 153 | >>> l.level_matches(slice(1, 3), 1) 154 | True 155 | >>> l.level_matches(slice(2, 3), 1) 156 | False 157 | """ 158 | if isinstance(level, slice): 159 | start, stop = level.start, level.stop 160 | if start is not None and start > consumer_level: 161 | return False 162 | if stop is not None or stop <= consumer_level: 163 | return False 164 | return True 165 | else: 166 | return level >= consumer_level 167 | 168 | @classmethod 169 | def level_for_integer(cls, level): 170 | levels = cls.LEVELS 171 | if level < 0: 172 | return levels[0] 173 | if level >= len(levels): 174 | return levels[-1] 175 | return levels[level] 176 | 177 | def move_stdout_to_stderr(self): 178 | to_remove = [] 179 | to_add = [] 180 | for consumer_level, consumer in self.consumers: 181 | if consumer == sys.stdout: 182 | to_remove.append((consumer_level, consumer)) 183 | to_add.append((consumer_level, sys.stderr)) 184 | for item in to_remove: 185 | self.consumers.remove(item) 186 | self.consumers.extend(to_add) 187 | 188 | logger = Logger() 189 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py: -------------------------------------------------------------------------------- 1 | """Base Command class, and related routines""" 2 | 3 | import os 4 | from pkgutil import walk_packages 5 | import socket 6 | import sys 7 | import tempfile 8 | import traceback 9 | import time 10 | 11 | from pip import commands 12 | from pip.log import logger 13 | from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter 14 | from pip.download import urlopen 15 | from pip.exceptions import (BadCommand, InstallationError, UninstallationError, 16 | CommandError) 17 | from pip.backwardcompat import StringIO 18 | from pip.status_codes import SUCCESS, ERROR, UNKNOWN_ERROR, VIRTUALENV_NOT_FOUND 19 | from pip.util import get_prog 20 | 21 | 22 | __all__ = ['command_dict', 'Command', 'load_all_commands', 23 | 'load_command', 'command_names'] 24 | 25 | command_dict = {} 26 | 27 | # for backwards compatibiliy 28 | get_proxy = urlopen.get_proxy 29 | 30 | 31 | class Command(object): 32 | name = None 33 | usage = None 34 | hidden = False 35 | 36 | def __init__(self): 37 | assert self.name 38 | self.parser = ConfigOptionParser( 39 | usage=self.usage, 40 | prog='%s %s' % (get_prog(), self.name), 41 | version=parser.version, 42 | formatter=UpdatingDefaultsHelpFormatter(), 43 | name=self.name) 44 | for option in parser.option_list: 45 | if not option.dest or option.dest == 'help': 46 | # -h, --version, etc 47 | continue 48 | self.parser.add_option(option) 49 | command_dict[self.name] = self 50 | 51 | def merge_options(self, initial_options, options): 52 | # Make sure we have all global options carried over 53 | for attr in ['log', 'proxy', 'require_venv', 54 | 'log_explicit_levels', 'log_file', 55 | 'timeout', 'default_vcs', 56 | 'skip_requirements_regex', 57 | 'no_input', 'exists_action']: 58 | setattr(options, attr, getattr(initial_options, attr) or getattr(options, attr)) 59 | options.quiet += initial_options.quiet 60 | options.verbose += initial_options.verbose 61 | 62 | def setup_logging(self): 63 | pass 64 | 65 | def main(self, args, initial_options): 66 | options, args = self.parser.parse_args(args) 67 | self.merge_options(initial_options, options) 68 | 69 | level = 1 # Notify 70 | level += options.verbose 71 | level -= options.quiet 72 | level = logger.level_for_integer(4-level) 73 | complete_log = [] 74 | logger.consumers.extend( 75 | [(level, sys.stdout), 76 | (logger.DEBUG, complete_log.append)]) 77 | if options.log_explicit_levels: 78 | logger.explicit_levels = True 79 | 80 | self.setup_logging() 81 | 82 | if options.no_input: 83 | os.environ['PIP_NO_INPUT'] = '1' 84 | 85 | if options.exists_action: 86 | os.environ['PIP_EXISTS_ACTION'] = ''.join(options.exists_action) 87 | 88 | if options.require_venv: 89 | # If a venv is required check if it can really be found 90 | if not os.environ.get('VIRTUAL_ENV'): 91 | logger.fatal('Could not find an activated virtualenv (required).') 92 | sys.exit(VIRTUALENV_NOT_FOUND) 93 | 94 | if options.log: 95 | log_fp = open_logfile(options.log, 'a') 96 | logger.consumers.append((logger.DEBUG, log_fp)) 97 | else: 98 | log_fp = None 99 | 100 | socket.setdefaulttimeout(options.timeout or None) 101 | 102 | urlopen.setup(proxystr=options.proxy, prompting=not options.no_input) 103 | 104 | exit = SUCCESS 105 | store_log = False 106 | try: 107 | status = self.run(options, args) 108 | # FIXME: all commands should return an exit status 109 | # and when it is done, isinstance is not needed anymore 110 | if isinstance(status, int): 111 | exit = status 112 | except (InstallationError, UninstallationError): 113 | e = sys.exc_info()[1] 114 | logger.fatal(str(e)) 115 | logger.info('Exception information:\n%s' % format_exc()) 116 | store_log = True 117 | exit = ERROR 118 | except BadCommand: 119 | e = sys.exc_info()[1] 120 | logger.fatal(str(e)) 121 | logger.info('Exception information:\n%s' % format_exc()) 122 | store_log = True 123 | exit = ERROR 124 | except CommandError: 125 | e = sys.exc_info()[1] 126 | logger.fatal('ERROR: %s' % e) 127 | logger.info('Exception information:\n%s' % format_exc()) 128 | exit = ERROR 129 | except KeyboardInterrupt: 130 | logger.fatal('Operation cancelled by user') 131 | logger.info('Exception information:\n%s' % format_exc()) 132 | store_log = True 133 | exit = ERROR 134 | except: 135 | logger.fatal('Exception:\n%s' % format_exc()) 136 | store_log = True 137 | exit = UNKNOWN_ERROR 138 | if log_fp is not None: 139 | log_fp.close() 140 | if store_log: 141 | log_fn = options.log_file 142 | text = '\n'.join(complete_log) 143 | try: 144 | log_fp = open_logfile(log_fn, 'w') 145 | except IOError: 146 | temp = tempfile.NamedTemporaryFile(delete=False) 147 | log_fn = temp.name 148 | log_fp = open_logfile(log_fn, 'w') 149 | logger.fatal('Storing complete log in %s' % log_fn) 150 | log_fp.write(text) 151 | log_fp.close() 152 | return exit 153 | 154 | 155 | def format_exc(exc_info=None): 156 | if exc_info is None: 157 | exc_info = sys.exc_info() 158 | out = StringIO() 159 | traceback.print_exception(*exc_info, **dict(file=out)) 160 | return out.getvalue() 161 | 162 | 163 | def open_logfile(filename, mode='a'): 164 | """Open the named log file in append mode. 165 | 166 | If the file already exists, a separator will also be printed to 167 | the file to separate past activity from current activity. 168 | """ 169 | filename = os.path.expanduser(filename) 170 | filename = os.path.abspath(filename) 171 | dirname = os.path.dirname(filename) 172 | if not os.path.exists(dirname): 173 | os.makedirs(dirname) 174 | exists = os.path.exists(filename) 175 | 176 | log_fp = open(filename, mode) 177 | if exists: 178 | log_fp.write('%s\n' % ('-'*60)) 179 | log_fp.write('%s run on %s\n' % (sys.argv[0], time.strftime('%c'))) 180 | return log_fp 181 | 182 | 183 | def load_command(name): 184 | full_name = 'pip.commands.%s' % name 185 | if full_name in sys.modules: 186 | return 187 | try: 188 | __import__(full_name) 189 | except ImportError: 190 | pass 191 | 192 | 193 | def load_all_commands(): 194 | for name in command_names(): 195 | load_command(name) 196 | 197 | 198 | def command_names(): 199 | names = set((pkg[1] for pkg in walk_packages(path=commands.__path__))) 200 | return list(names) 201 | 202 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import optparse 4 | 5 | import sys 6 | import re 7 | import difflib 8 | 9 | from pip.basecommand import command_dict, load_command, load_all_commands, command_names 10 | from pip.baseparser import parser 11 | from pip.exceptions import InstallationError 12 | from pip.log import logger 13 | from pip.util import get_installed_distributions, get_prog 14 | from pip.vcs import git, mercurial, subversion, bazaar # noqa 15 | 16 | 17 | # The version as used in the setup.py and the docs conf.py 18 | __version__ = "1.2.1" 19 | 20 | 21 | def autocomplete(): 22 | """Command and option completion for the main option parser (and options) 23 | and its subcommands (and options). 24 | 25 | Enable by sourcing one of the completion shell scripts (bash or zsh). 26 | """ 27 | # Don't complete if user hasn't sourced bash_completion file. 28 | if 'PIP_AUTO_COMPLETE' not in os.environ: 29 | return 30 | cwords = os.environ['COMP_WORDS'].split()[1:] 31 | cword = int(os.environ['COMP_CWORD']) 32 | try: 33 | current = cwords[cword - 1] 34 | except IndexError: 35 | current = '' 36 | load_all_commands() 37 | subcommands = [cmd for cmd, cls in command_dict.items() if not cls.hidden] 38 | options = [] 39 | # subcommand 40 | try: 41 | subcommand_name = [w for w in cwords if w in subcommands][0] 42 | except IndexError: 43 | subcommand_name = None 44 | # subcommand options 45 | if subcommand_name: 46 | # special case: 'help' subcommand has no options 47 | if subcommand_name == 'help': 48 | sys.exit(1) 49 | # special case: list locally installed dists for uninstall command 50 | if subcommand_name == 'uninstall' and not current.startswith('-'): 51 | installed = [] 52 | lc = current.lower() 53 | for dist in get_installed_distributions(local_only=True): 54 | if dist.key.startswith(lc) and dist.key not in cwords[1:]: 55 | installed.append(dist.key) 56 | # if there are no dists installed, fall back to option completion 57 | if installed: 58 | for dist in installed: 59 | print(dist) 60 | sys.exit(1) 61 | subcommand = command_dict.get(subcommand_name) 62 | options += [(opt.get_opt_string(), opt.nargs) 63 | for opt in subcommand.parser.option_list 64 | if opt.help != optparse.SUPPRESS_HELP] 65 | # filter out previously specified options from available options 66 | prev_opts = [x.split('=')[0] for x in cwords[1:cword - 1]] 67 | options = [(x, v) for (x, v) in options if x not in prev_opts] 68 | # filter options by current input 69 | options = [(k, v) for k, v in options if k.startswith(current)] 70 | for option in options: 71 | opt_label = option[0] 72 | # append '=' to options which require args 73 | if option[1]: 74 | opt_label += '=' 75 | print(opt_label) 76 | else: 77 | # show options of main parser only when necessary 78 | if current.startswith('-') or current.startswith('--'): 79 | subcommands += [opt.get_opt_string() 80 | for opt in parser.option_list 81 | if opt.help != optparse.SUPPRESS_HELP] 82 | print(' '.join([x for x in subcommands if x.startswith(current)])) 83 | sys.exit(1) 84 | 85 | 86 | def main(initial_args=None): 87 | if initial_args is None: 88 | initial_args = sys.argv[1:] 89 | autocomplete() 90 | options, args = parser.parse_args(initial_args) 91 | if options.help and not args: 92 | args = ['help'] 93 | if not args: 94 | parser.error('You must give a command ' 95 | '(use "%s help" to see a list of commands)' % get_prog()) 96 | command = args[0].lower() 97 | load_command(command) 98 | if command not in command_dict: 99 | close_commands = difflib.get_close_matches(command, command_names()) 100 | if close_commands: 101 | guess = close_commands[0] 102 | if args[1:]: 103 | guess = "%s %s" % (guess, " ".join(args[1:])) 104 | else: 105 | guess = 'install %s' % command 106 | error_dict = {'arg': command, 'guess': guess, 107 | 'script': os.path.basename(sys.argv[0])} 108 | parser.error('No command by the name %(script)s %(arg)s\n ' 109 | '(maybe you meant "%(script)s %(guess)s")' % error_dict) 110 | command = command_dict[command] 111 | return command.main(args[1:], options) 112 | 113 | 114 | def bootstrap(): 115 | """ 116 | Bootstrapping function to be called from install-pip.py script. 117 | """ 118 | return main(['install', '--upgrade', 'pip']) 119 | 120 | ############################################################ 121 | ## Writing freeze files 122 | 123 | 124 | class FrozenRequirement(object): 125 | 126 | def __init__(self, name, req, editable, comments=()): 127 | self.name = name 128 | self.req = req 129 | self.editable = editable 130 | self.comments = comments 131 | 132 | _rev_re = re.compile(r'-r(\d+)$') 133 | _date_re = re.compile(r'-(20\d\d\d\d\d\d)$') 134 | 135 | @classmethod 136 | def from_dist(cls, dist, dependency_links, find_tags=False): 137 | location = os.path.normcase(os.path.abspath(dist.location)) 138 | comments = [] 139 | from pip.vcs import vcs, get_src_requirement 140 | if vcs.get_backend_name(location): 141 | editable = True 142 | try: 143 | req = get_src_requirement(dist, location, find_tags) 144 | except InstallationError: 145 | ex = sys.exc_info()[1] 146 | logger.warn("Error when trying to get requirement for VCS system %s, falling back to uneditable format" % ex) 147 | req = None 148 | if req is None: 149 | logger.warn('Could not determine repository location of %s' % location) 150 | comments.append('## !! Could not determine repository location') 151 | req = dist.as_requirement() 152 | editable = False 153 | else: 154 | editable = False 155 | req = dist.as_requirement() 156 | specs = req.specs 157 | assert len(specs) == 1 and specs[0][0] == '==' 158 | version = specs[0][1] 159 | ver_match = cls._rev_re.search(version) 160 | date_match = cls._date_re.search(version) 161 | if ver_match or date_match: 162 | svn_backend = vcs.get_backend('svn') 163 | if svn_backend: 164 | svn_location = svn_backend( 165 | ).get_location(dist, dependency_links) 166 | if not svn_location: 167 | logger.warn( 168 | 'Warning: cannot find svn location for %s' % req) 169 | comments.append('## FIXME: could not find svn URL in dependency_links for this package:') 170 | else: 171 | comments.append('# Installing as editable to satisfy requirement %s:' % req) 172 | if ver_match: 173 | rev = ver_match.group(1) 174 | else: 175 | rev = '{%s}' % date_match.group(1) 176 | editable = True 177 | req = '%s@%s#egg=%s' % (svn_location, rev, cls.egg_name(dist)) 178 | return cls(dist.project_name, req, editable, comments) 179 | 180 | @staticmethod 181 | def egg_name(dist): 182 | name = dist.egg_name() 183 | match = re.search(r'-py\d\.\d$', name) 184 | if match: 185 | name = name[:match.start()] 186 | return name 187 | 188 | def __str__(self): 189 | req = self.req 190 | if self.editable: 191 | req = '-e %s' % req 192 | return '\n'.join(list(self.comments) + [str(req)]) + '\n' 193 | 194 | 195 | if __name__ == '__main__': 196 | exit = main() 197 | if exit: 198 | sys.exit(exit) 199 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/__init__.py: -------------------------------------------------------------------------------- 1 | """Handles all VCS (version control) support""" 2 | 3 | import os 4 | import shutil 5 | 6 | from pip.backwardcompat import urlparse, urllib 7 | from pip.log import logger 8 | from pip.util import (display_path, backup_dir, find_command, 9 | ask, rmtree, ask_path_exists) 10 | 11 | 12 | __all__ = ['vcs', 'get_src_requirement'] 13 | 14 | 15 | class VcsSupport(object): 16 | _registry = {} 17 | schemes = ['ssh', 'git', 'hg', 'bzr', 'sftp', 'svn'] 18 | 19 | def __init__(self): 20 | # Register more schemes with urlparse for various version control systems 21 | urlparse.uses_netloc.extend(self.schemes) 22 | # Python >= 2.7.4, 3.3 doesn't have uses_fragment 23 | if getattr(urlparse, 'uses_fragment', None): 24 | urlparse.uses_fragment.extend(self.schemes) 25 | super(VcsSupport, self).__init__() 26 | 27 | def __iter__(self): 28 | return self._registry.__iter__() 29 | 30 | @property 31 | def backends(self): 32 | return list(self._registry.values()) 33 | 34 | @property 35 | def dirnames(self): 36 | return [backend.dirname for backend in self.backends] 37 | 38 | @property 39 | def all_schemes(self): 40 | schemes = [] 41 | for backend in self.backends: 42 | schemes.extend(backend.schemes) 43 | return schemes 44 | 45 | def register(self, cls): 46 | if not hasattr(cls, 'name'): 47 | logger.warn('Cannot register VCS %s' % cls.__name__) 48 | return 49 | if cls.name not in self._registry: 50 | self._registry[cls.name] = cls 51 | 52 | def unregister(self, cls=None, name=None): 53 | if name in self._registry: 54 | del self._registry[name] 55 | elif cls in self._registry.values(): 56 | del self._registry[cls.name] 57 | else: 58 | logger.warn('Cannot unregister because no class or name given') 59 | 60 | def get_backend_name(self, location): 61 | """ 62 | Return the name of the version control backend if found at given 63 | location, e.g. vcs.get_backend_name('/path/to/vcs/checkout') 64 | """ 65 | for vc_type in self._registry.values(): 66 | path = os.path.join(location, vc_type.dirname) 67 | if os.path.exists(path): 68 | return vc_type.name 69 | return None 70 | 71 | def get_backend(self, name): 72 | name = name.lower() 73 | if name in self._registry: 74 | return self._registry[name] 75 | 76 | def get_backend_from_location(self, location): 77 | vc_type = self.get_backend_name(location) 78 | if vc_type: 79 | return self.get_backend(vc_type) 80 | return None 81 | 82 | 83 | vcs = VcsSupport() 84 | 85 | 86 | class VersionControl(object): 87 | name = '' 88 | dirname = '' 89 | 90 | def __init__(self, url=None, *args, **kwargs): 91 | self.url = url 92 | self._cmd = None 93 | super(VersionControl, self).__init__(*args, **kwargs) 94 | 95 | def _filter(self, line): 96 | return (logger.INFO, line) 97 | 98 | def _is_local_repository(self, repo): 99 | """ 100 | posix absolute paths start with os.path.sep, 101 | win32 ones ones start with drive (like c:\\folder) 102 | """ 103 | drive, tail = os.path.splitdrive(repo) 104 | return repo.startswith(os.path.sep) or drive 105 | 106 | @property 107 | def cmd(self): 108 | if self._cmd is not None: 109 | return self._cmd 110 | command = find_command(self.name) 111 | logger.info('Found command %r at %r' % (self.name, command)) 112 | self._cmd = command 113 | return command 114 | 115 | def get_url_rev(self): 116 | """ 117 | Returns the correct repository URL and revision by parsing the given 118 | repository URL 119 | """ 120 | error_message= ( 121 | "Sorry, '%s' is a malformed VCS url. " 122 | "Ihe format is +://, " 123 | "e.g. svn+http://myrepo/svn/MyApp#egg=MyApp") 124 | assert '+' in self.url, error_message % self.url 125 | url = self.url.split('+', 1)[1] 126 | scheme, netloc, path, query, frag = urlparse.urlsplit(url) 127 | rev = None 128 | if '@' in path: 129 | path, rev = path.rsplit('@', 1) 130 | url = urlparse.urlunsplit((scheme, netloc, path, query, '')) 131 | return url, rev 132 | 133 | def get_info(self, location): 134 | """ 135 | Returns (url, revision), where both are strings 136 | """ 137 | assert not location.rstrip('/').endswith(self.dirname), 'Bad directory: %s' % location 138 | return self.get_url(location), self.get_revision(location) 139 | 140 | def normalize_url(self, url): 141 | """ 142 | Normalize a URL for comparison by unquoting it and removing any trailing slash. 143 | """ 144 | return urllib.unquote(url).rstrip('/') 145 | 146 | def compare_urls(self, url1, url2): 147 | """ 148 | Compare two repo URLs for identity, ignoring incidental differences. 149 | """ 150 | return (self.normalize_url(url1) == self.normalize_url(url2)) 151 | 152 | def parse_vcs_bundle_file(self, content): 153 | """ 154 | Takes the contents of the bundled text file that explains how to revert 155 | the stripped off version control data of the given package and returns 156 | the URL and revision of it. 157 | """ 158 | raise NotImplementedError 159 | 160 | def obtain(self, dest): 161 | """ 162 | Called when installing or updating an editable package, takes the 163 | source path of the checkout. 164 | """ 165 | raise NotImplementedError 166 | 167 | def switch(self, dest, url, rev_options): 168 | """ 169 | Switch the repo at ``dest`` to point to ``URL``. 170 | """ 171 | raise NotImplemented 172 | 173 | def update(self, dest, rev_options): 174 | """ 175 | Update an already-existing repo to the given ``rev_options``. 176 | """ 177 | raise NotImplementedError 178 | 179 | def check_destination(self, dest, url, rev_options, rev_display): 180 | """ 181 | Prepare a location to receive a checkout/clone. 182 | 183 | Return True if the location is ready for (and requires) a 184 | checkout/clone, False otherwise. 185 | """ 186 | checkout = True 187 | prompt = False 188 | if os.path.exists(dest): 189 | checkout = False 190 | if os.path.exists(os.path.join(dest, self.dirname)): 191 | existing_url = self.get_url(dest) 192 | if self.compare_urls(existing_url, url): 193 | logger.info('%s in %s exists, and has correct URL (%s)' % 194 | (self.repo_name.title(), display_path(dest), 195 | url)) 196 | logger.notify('Updating %s %s%s' % 197 | (display_path(dest), self.repo_name, 198 | rev_display)) 199 | self.update(dest, rev_options) 200 | else: 201 | logger.warn('%s %s in %s exists with URL %s' % 202 | (self.name, self.repo_name, 203 | display_path(dest), existing_url)) 204 | prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ', 205 | ('s', 'i', 'w', 'b')) 206 | else: 207 | logger.warn('Directory %s already exists, ' 208 | 'and is not a %s %s.' % 209 | (dest, self.name, self.repo_name)) 210 | prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b')) 211 | if prompt: 212 | logger.warn('The plan is to install the %s repository %s' % 213 | (self.name, url)) 214 | response = ask_path_exists('What to do? %s' % prompt[0], 215 | prompt[1]) 216 | 217 | if response == 's': 218 | logger.notify('Switching %s %s to %s%s' % 219 | (self.repo_name, display_path(dest), url, 220 | rev_display)) 221 | self.switch(dest, url, rev_options) 222 | elif response == 'i': 223 | # do nothing 224 | pass 225 | elif response == 'w': 226 | logger.warn('Deleting %s' % display_path(dest)) 227 | rmtree(dest) 228 | checkout = True 229 | elif response == 'b': 230 | dest_dir = backup_dir(dest) 231 | logger.warn('Backing up %s to %s' 232 | % (display_path(dest), dest_dir)) 233 | shutil.move(dest, dest_dir) 234 | checkout = True 235 | return checkout 236 | 237 | def unpack(self, location): 238 | if os.path.exists(location): 239 | rmtree(location) 240 | self.obtain(location) 241 | 242 | def get_src_requirement(self, dist, location, find_tags=False): 243 | raise NotImplementedError 244 | 245 | 246 | def get_src_requirement(dist, location, find_tags): 247 | version_control = vcs.get_backend_from_location(location) 248 | if version_control: 249 | return version_control().get_src_requirement(dist, location, find_tags) 250 | logger.warn('cannot determine version of editable source in %s (is not SVN checkout, Git clone, Mercurial clone or Bazaar branch)' % location) 251 | return dist.as_requirement() 252 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/git.py: -------------------------------------------------------------------------------- 1 | import tempfile 2 | import re 3 | import os.path 4 | from pip.util import call_subprocess 5 | from pip.util import display_path, rmtree 6 | from pip.vcs import vcs, VersionControl 7 | from pip.log import logger 8 | from pip.backwardcompat import url2pathname, urlparse 9 | urlsplit = urlparse.urlsplit 10 | urlunsplit = urlparse.urlunsplit 11 | 12 | 13 | class Git(VersionControl): 14 | name = 'git' 15 | dirname = '.git' 16 | repo_name = 'clone' 17 | schemes = ('git', 'git+http', 'git+https', 'git+ssh', 'git+git', 'git+file') 18 | bundle_file = 'git-clone.txt' 19 | guide = ('# This was a Git repo; to make it a repo again run:\n' 20 | 'git init\ngit remote add origin %(url)s -f\ngit checkout %(rev)s\n') 21 | 22 | def __init__(self, url=None, *args, **kwargs): 23 | 24 | # Works around an apparent Git bug 25 | # (see http://article.gmane.org/gmane.comp.version-control.git/146500) 26 | if url: 27 | scheme, netloc, path, query, fragment = urlsplit(url) 28 | if scheme.endswith('file'): 29 | initial_slashes = path[:-len(path.lstrip('/'))] 30 | newpath = initial_slashes + url2pathname(path).replace('\\', '/').lstrip('/') 31 | url = urlunsplit((scheme, netloc, newpath, query, fragment)) 32 | after_plus = scheme.find('+') + 1 33 | url = scheme[:after_plus] + urlunsplit((scheme[after_plus:], netloc, newpath, query, fragment)) 34 | 35 | super(Git, self).__init__(url, *args, **kwargs) 36 | 37 | def parse_vcs_bundle_file(self, content): 38 | url = rev = None 39 | for line in content.splitlines(): 40 | if not line.strip() or line.strip().startswith('#'): 41 | continue 42 | url_match = re.search(r'git\s*remote\s*add\s*origin(.*)\s*-f', line) 43 | if url_match: 44 | url = url_match.group(1).strip() 45 | rev_match = re.search(r'^git\s*checkout\s*-q\s*(.*)\s*', line) 46 | if rev_match: 47 | rev = rev_match.group(1).strip() 48 | if url and rev: 49 | return url, rev 50 | return None, None 51 | 52 | def export(self, location): 53 | """Export the Git repository at the url to the destination location""" 54 | temp_dir = tempfile.mkdtemp('-export', 'pip-') 55 | self.unpack(temp_dir) 56 | try: 57 | if not location.endswith('/'): 58 | location = location + '/' 59 | call_subprocess( 60 | [self.cmd, 'checkout-index', '-a', '-f', '--prefix', location], 61 | filter_stdout=self._filter, show_stdout=False, cwd=temp_dir) 62 | finally: 63 | rmtree(temp_dir) 64 | 65 | def check_rev_options(self, rev, dest, rev_options): 66 | """Check the revision options before checkout to compensate that tags 67 | and branches may need origin/ as a prefix. 68 | Returns the SHA1 of the branch or tag if found. 69 | """ 70 | revisions = self.get_tag_revs(dest) 71 | revisions.update(self.get_branch_revs(dest)) 72 | 73 | origin_rev = 'origin/%s' % rev 74 | if origin_rev in revisions: 75 | # remote branch 76 | return [revisions[origin_rev]] 77 | elif rev in revisions: 78 | # a local tag or branch name 79 | return [revisions[rev]] 80 | else: 81 | logger.warn("Could not find a tag or branch '%s', assuming commit." % rev) 82 | return rev_options 83 | 84 | def switch(self, dest, url, rev_options): 85 | call_subprocess( 86 | [self.cmd, 'config', 'remote.origin.url', url], cwd=dest) 87 | call_subprocess( 88 | [self.cmd, 'checkout', '-q'] + rev_options, cwd=dest) 89 | 90 | self.update_submodules(dest) 91 | 92 | def update(self, dest, rev_options): 93 | # First fetch changes from the default remote 94 | call_subprocess([self.cmd, 'fetch', '-q'], cwd=dest) 95 | # Then reset to wanted revision (maby even origin/master) 96 | if rev_options: 97 | rev_options = self.check_rev_options(rev_options[0], dest, rev_options) 98 | call_subprocess([self.cmd, 'reset', '--hard', '-q'] + rev_options, cwd=dest) 99 | #: update submodules 100 | self.update_submodules(dest) 101 | 102 | def obtain(self, dest): 103 | url, rev = self.get_url_rev() 104 | if rev: 105 | rev_options = [rev] 106 | rev_display = ' (to %s)' % rev 107 | else: 108 | rev_options = ['origin/master'] 109 | rev_display = '' 110 | if self.check_destination(dest, url, rev_options, rev_display): 111 | logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) 112 | call_subprocess([self.cmd, 'clone', '-q', url, dest]) 113 | #: repo may contain submodules 114 | self.update_submodules(dest) 115 | if rev: 116 | rev_options = self.check_rev_options(rev, dest, rev_options) 117 | # Only do a checkout if rev_options differs from HEAD 118 | if not self.get_revision(dest).startswith(rev_options[0]): 119 | call_subprocess([self.cmd, 'checkout', '-q'] + rev_options, cwd=dest) 120 | 121 | def get_url(self, location): 122 | url = call_subprocess( 123 | [self.cmd, 'config', 'remote.origin.url'], 124 | show_stdout=False, cwd=location) 125 | return url.strip() 126 | 127 | def get_revision(self, location): 128 | current_rev = call_subprocess( 129 | [self.cmd, 'rev-parse', 'HEAD'], show_stdout=False, cwd=location) 130 | return current_rev.strip() 131 | 132 | def get_tag_revs(self, location): 133 | tags = self._get_all_tag_names(location) 134 | tag_revs = {} 135 | for line in tags.splitlines(): 136 | tag = line.strip() 137 | rev = self._get_revision_from_rev_parse(tag, location) 138 | tag_revs[tag] = rev.strip() 139 | return tag_revs 140 | 141 | def get_branch_revs(self, location): 142 | branches = self._get_all_branch_names(location) 143 | branch_revs = {} 144 | for line in branches.splitlines(): 145 | if '(no branch)' in line: 146 | continue 147 | line = line.split('->')[0].strip() 148 | # actual branch case 149 | branch = "".join(b for b in line.split() if b != '*') 150 | rev = self._get_revision_from_rev_parse(branch, location) 151 | branch_revs[branch] = rev.strip() 152 | return branch_revs 153 | 154 | def get_src_requirement(self, dist, location, find_tags): 155 | repo = self.get_url(location) 156 | if not repo.lower().startswith('git:'): 157 | repo = 'git+' + repo 158 | egg_project_name = dist.egg_name().split('-', 1)[0] 159 | if not repo: 160 | return None 161 | current_rev = self.get_revision(location) 162 | tag_revs = self.get_tag_revs(location) 163 | branch_revs = self.get_branch_revs(location) 164 | 165 | if current_rev in tag_revs: 166 | # It's a tag 167 | full_egg_name = '%s-%s' % (egg_project_name, tag_revs[current_rev]) 168 | elif (current_rev in branch_revs and 169 | branch_revs[current_rev] != 'origin/master'): 170 | # It's the head of a branch 171 | full_egg_name = '%s-%s' % ( 172 | egg_project_name, 173 | branch_revs[current_rev].replace('origin/', '') 174 | ) 175 | else: 176 | full_egg_name = '%s-dev' % egg_project_name 177 | 178 | return '%s@%s#egg=%s' % (repo, current_rev, full_egg_name) 179 | 180 | def get_url_rev(self): 181 | """ 182 | Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. 183 | That's required because although they use SSH they sometimes doesn't 184 | work with a ssh:// scheme (e.g. Github). But we need a scheme for 185 | parsing. Hence we remove it again afterwards and return it as a stub. 186 | """ 187 | if not '://' in self.url: 188 | assert not 'file:' in self.url 189 | self.url = self.url.replace('git+', 'git+ssh://') 190 | url, rev = super(Git, self).get_url_rev() 191 | url = url.replace('ssh://', '') 192 | else: 193 | url, rev = super(Git, self).get_url_rev() 194 | 195 | return url, rev 196 | 197 | def _get_all_tag_names(self, location): 198 | return call_subprocess([self.cmd, 'tag', '-l'], 199 | show_stdout=False, 200 | raise_on_returncode=False, 201 | cwd=location) 202 | 203 | def _get_all_branch_names(self, location): 204 | remote_branches = call_subprocess([self.cmd, 'branch', '-r'], 205 | show_stdout=False, cwd=location) 206 | local_branches = call_subprocess([self.cmd, 'branch', '-l'], 207 | show_stdout=False, cwd=location) 208 | return remote_branches + local_branches 209 | 210 | def _get_revision_from_rev_parse(self, name, location): 211 | return call_subprocess([self.cmd, 'rev-parse', name], 212 | show_stdout=False, cwd=location) 213 | 214 | def update_submodules(self, location): 215 | if not os.path.exists(os.path.join(location, '.gitmodules')): 216 | return 217 | call_subprocess([self.cmd, 'submodule', 'init', '-q'], cwd=location) 218 | call_subprocess([self.cmd, 'submodule', 'update', '--recursive', '-q'], 219 | cwd=location) 220 | 221 | vcs.register(Git) 222 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/baseparser.py: -------------------------------------------------------------------------------- 1 | """Base option parser setup""" 2 | 3 | import sys 4 | import optparse 5 | import pkg_resources 6 | import os 7 | from distutils.util import strtobool 8 | from pip.backwardcompat import ConfigParser, string_types 9 | from pip.locations import default_config_file, default_log_file 10 | from pip.util import get_terminal_size, get_prog 11 | 12 | 13 | class PrettyHelpFormatter(optparse.IndentedHelpFormatter): 14 | """A prettier/less verbose help formatter for optparse.""" 15 | 16 | def __init__(self, *args, **kwargs): 17 | kwargs['max_help_position'] = 30 18 | kwargs['indent_increment'] = 1 19 | kwargs['width'] = get_terminal_size()[0] - 2 20 | optparse.IndentedHelpFormatter.__init__(self, *args, **kwargs) 21 | 22 | def format_option_strings(self, option): 23 | return self._format_option_strings(option, ' <%s>', ', ') 24 | 25 | def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '): 26 | """ 27 | Return a comma-separated list of option strings and metavars. 28 | 29 | :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') 30 | :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar 31 | :param optsep: separator 32 | """ 33 | opts = [] 34 | 35 | if option._short_opts: 36 | opts.append(option._short_opts[0]) 37 | if option._long_opts: 38 | opts.append(option._long_opts[0]) 39 | if len(opts) > 1: 40 | opts.insert(1, optsep) 41 | 42 | if option.takes_value(): 43 | metavar = option.metavar or option.dest.lower() 44 | opts.append(mvarfmt % metavar.upper()) 45 | 46 | return ''.join(opts) 47 | 48 | def format_heading(self, heading): 49 | if heading == 'Options': 50 | return '' 51 | return heading + ':\n' 52 | 53 | def format_usage(self, usage): 54 | """ 55 | ensure there is only one newline between usage and the first heading 56 | if there is no description 57 | """ 58 | msg = 'Usage: %s' % usage 59 | if self.parser.description: 60 | msg += '\n' 61 | return msg 62 | 63 | def format_description(self, description): 64 | # leave full control over description to us 65 | if description: 66 | return description 67 | else: 68 | return '' 69 | 70 | def format_epilog(self, epilog): 71 | # leave full control over epilog to us 72 | if epilog: 73 | return epilog 74 | else: 75 | return '' 76 | 77 | 78 | class UpdatingDefaultsHelpFormatter(PrettyHelpFormatter): 79 | """Custom help formatter for use in ConfigOptionParser that updates 80 | the defaults before expanding them, allowing them to show up correctly 81 | in the help listing""" 82 | 83 | def expand_default(self, option): 84 | if self.parser is not None: 85 | self.parser.update_defaults(self.parser.defaults) 86 | return optparse.IndentedHelpFormatter.expand_default(self, option) 87 | 88 | 89 | class ConfigOptionParser(optparse.OptionParser): 90 | """Custom option parser which updates its defaults by by checking the 91 | configuration files and environmental variables""" 92 | 93 | def __init__(self, *args, **kwargs): 94 | self.config = ConfigParser.RawConfigParser() 95 | self.name = kwargs.pop('name') 96 | self.files = self.get_config_files() 97 | self.config.read(self.files) 98 | assert self.name 99 | optparse.OptionParser.__init__(self, *args, **kwargs) 100 | 101 | def get_config_files(self): 102 | config_file = os.environ.get('PIP_CONFIG_FILE', False) 103 | if config_file and os.path.exists(config_file): 104 | return [config_file] 105 | return [default_config_file] 106 | 107 | def update_defaults(self, defaults): 108 | """Updates the given defaults with values from the config files and 109 | the environ. Does a little special handling for certain types of 110 | options (lists).""" 111 | # Then go and look for the other sources of configuration: 112 | config = {} 113 | # 1. config files 114 | for section in ('global', self.name): 115 | config.update(self.normalize_keys(self.get_config_section(section))) 116 | # 2. environmental variables 117 | config.update(self.normalize_keys(self.get_environ_vars())) 118 | # Then set the options with those values 119 | for key, val in config.items(): 120 | option = self.get_option(key) 121 | if option is not None: 122 | # ignore empty values 123 | if not val: 124 | continue 125 | # handle multiline configs 126 | if option.action == 'append': 127 | val = val.split() 128 | else: 129 | option.nargs = 1 130 | if option.action in ('store_true', 'store_false', 'count'): 131 | val = strtobool(val) 132 | try: 133 | val = option.convert_value(key, val) 134 | except optparse.OptionValueError: 135 | e = sys.exc_info()[1] 136 | print("An error occured during configuration: %s" % e) 137 | sys.exit(3) 138 | defaults[option.dest] = val 139 | return defaults 140 | 141 | def normalize_keys(self, items): 142 | """Return a config dictionary with normalized keys regardless of 143 | whether the keys were specified in environment variables or in config 144 | files""" 145 | normalized = {} 146 | for key, val in items: 147 | key = key.replace('_', '-') 148 | if not key.startswith('--'): 149 | key = '--%s' % key # only prefer long opts 150 | normalized[key] = val 151 | return normalized 152 | 153 | def get_config_section(self, name): 154 | """Get a section of a configuration""" 155 | if self.config.has_section(name): 156 | return self.config.items(name) 157 | return [] 158 | 159 | def get_environ_vars(self, prefix='PIP_'): 160 | """Returns a generator with all environmental vars with prefix PIP_""" 161 | for key, val in os.environ.items(): 162 | if key.startswith(prefix): 163 | yield (key.replace(prefix, '').lower(), val) 164 | 165 | def get_default_values(self): 166 | """Overridding to make updating the defaults after instantiation of 167 | the option parser possible, update_defaults() does the dirty work.""" 168 | if not self.process_default_values: 169 | # Old, pre-Optik 1.5 behaviour. 170 | return optparse.Values(self.defaults) 171 | 172 | defaults = self.update_defaults(self.defaults.copy()) # ours 173 | for option in self._get_all_options(): 174 | default = defaults.get(option.dest) 175 | if isinstance(default, string_types): 176 | opt_str = option.get_opt_string() 177 | defaults[option.dest] = option.check_value(opt_str, default) 178 | return optparse.Values(defaults) 179 | 180 | def error(self, msg): 181 | self.print_usage(sys.stderr) 182 | self.exit(2, "%s\n" % msg) 183 | 184 | 185 | try: 186 | pip_dist = pkg_resources.get_distribution('pip') 187 | version = '%s from %s (python %s)' % ( 188 | pip_dist, pip_dist.location, sys.version[:3]) 189 | except pkg_resources.DistributionNotFound: 190 | # when running pip.py without installing 191 | version = None 192 | 193 | 194 | parser = ConfigOptionParser( 195 | usage='%prog COMMAND [OPTIONS]', 196 | version=version, 197 | add_help_option=False, 198 | formatter=UpdatingDefaultsHelpFormatter(), 199 | name='global', 200 | prog=get_prog()) 201 | 202 | parser.add_option( 203 | '-h', '--help', 204 | dest='help', 205 | action='store_true', 206 | help='Show help') 207 | parser.add_option( 208 | # Run only if inside a virtualenv, bail if not. 209 | '--require-virtualenv', '--require-venv', 210 | dest='require_venv', 211 | action='store_true', 212 | default=False, 213 | help=optparse.SUPPRESS_HELP) 214 | 215 | parser.add_option( 216 | '-v', '--verbose', 217 | dest='verbose', 218 | action='count', 219 | default=0, 220 | help='Give more output') 221 | parser.add_option( 222 | '-q', '--quiet', 223 | dest='quiet', 224 | action='count', 225 | default=0, 226 | help='Give less output') 227 | parser.add_option( 228 | '--log', 229 | dest='log', 230 | metavar='FILENAME', 231 | help='Log file where a complete (maximum verbosity) record will be kept') 232 | parser.add_option( 233 | # Writes the log levels explicitely to the log' 234 | '--log-explicit-levels', 235 | dest='log_explicit_levels', 236 | action='store_true', 237 | default=False, 238 | help=optparse.SUPPRESS_HELP) 239 | parser.add_option( 240 | # The default log file 241 | '--local-log', '--log-file', 242 | dest='log_file', 243 | metavar='FILENAME', 244 | default=default_log_file, 245 | help=optparse.SUPPRESS_HELP) 246 | parser.add_option( 247 | # Don't ask for input 248 | '--no-input', 249 | dest='no_input', 250 | action='store_true', 251 | default=False, 252 | help=optparse.SUPPRESS_HELP) 253 | 254 | parser.add_option( 255 | '--proxy', 256 | dest='proxy', 257 | type='str', 258 | default='', 259 | help="Specify a proxy in the form user:passwd@proxy.server:port. " 260 | "Note that the user:password@ is optional and required only if you " 261 | "are behind an authenticated proxy. If you provide " 262 | "user@proxy.server:port then you will be prompted for a password.") 263 | parser.add_option( 264 | '--timeout', '--default-timeout', 265 | metavar='SECONDS', 266 | dest='timeout', 267 | type='float', 268 | default=15, 269 | help='Set the socket timeout (default %default seconds)') 270 | parser.add_option( 271 | # The default version control system for editables, e.g. 'svn' 272 | '--default-vcs', 273 | dest='default_vcs', 274 | type='str', 275 | default='', 276 | help=optparse.SUPPRESS_HELP) 277 | parser.add_option( 278 | # A regex to be used to skip requirements 279 | '--skip-requirements-regex', 280 | dest='skip_requirements_regex', 281 | type='str', 282 | default='', 283 | help=optparse.SUPPRESS_HELP) 284 | 285 | parser.add_option( 286 | # Option when path already exist 287 | '--exists-action', 288 | dest='exists_action', 289 | type='choice', 290 | choices=['s', 'i', 'w', 'b'], 291 | default=[], 292 | action='append', 293 | help="Default action when a path already exists. " 294 | "Use this option more than one time to specify " 295 | "another action if a certain option is not " 296 | "available. Choices: " 297 | "(s)witch, (i)gnore, (w)ipe, (b)ackup") 298 | 299 | parser.disable_interspersed_args() 300 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/vcs/subversion.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | from pip.backwardcompat import urlparse 4 | from pip import InstallationError 5 | from pip.index import Link 6 | from pip.util import rmtree, display_path, call_subprocess 7 | from pip.log import logger 8 | from pip.vcs import vcs, VersionControl 9 | 10 | _svn_xml_url_re = re.compile('url="([^"]+)"') 11 | _svn_rev_re = re.compile('committed-rev="(\d+)"') 12 | _svn_url_re = re.compile(r'URL: (.+)') 13 | _svn_revision_re = re.compile(r'Revision: (.+)') 14 | _svn_info_xml_rev_re = re.compile(r'\s*revision="(\d+)"') 15 | _svn_info_xml_url_re = re.compile(r'(.*)') 16 | 17 | 18 | class Subversion(VersionControl): 19 | name = 'svn' 20 | dirname = '.svn' 21 | repo_name = 'checkout' 22 | schemes = ('svn', 'svn+ssh', 'svn+http', 'svn+https', 'svn+svn') 23 | bundle_file = 'svn-checkout.txt' 24 | guide = ('# This was an svn checkout; to make it a checkout again run:\n' 25 | 'svn checkout --force -r %(rev)s %(url)s .\n') 26 | 27 | def get_info(self, location): 28 | """Returns (url, revision), where both are strings""" 29 | assert not location.rstrip('/').endswith(self.dirname), 'Bad directory: %s' % location 30 | output = call_subprocess( 31 | [self.cmd, 'info', location], show_stdout=False, extra_environ={'LANG': 'C'}) 32 | match = _svn_url_re.search(output) 33 | if not match: 34 | logger.warn('Cannot determine URL of svn checkout %s' % display_path(location)) 35 | logger.info('Output that cannot be parsed: \n%s' % output) 36 | return None, None 37 | url = match.group(1).strip() 38 | match = _svn_revision_re.search(output) 39 | if not match: 40 | logger.warn('Cannot determine revision of svn checkout %s' % display_path(location)) 41 | logger.info('Output that cannot be parsed: \n%s' % output) 42 | return url, None 43 | return url, match.group(1) 44 | 45 | def parse_vcs_bundle_file(self, content): 46 | for line in content.splitlines(): 47 | if not line.strip() or line.strip().startswith('#'): 48 | continue 49 | match = re.search(r'^-r\s*([^ ])?', line) 50 | if not match: 51 | return None, None 52 | rev = match.group(1) 53 | rest = line[match.end():].strip().split(None, 1)[0] 54 | return rest, rev 55 | return None, None 56 | 57 | def export(self, location): 58 | """Export the svn repository at the url to the destination location""" 59 | url, rev = self.get_url_rev() 60 | rev_options = get_rev_options(url, rev) 61 | logger.notify('Exporting svn repository %s to %s' % (url, location)) 62 | logger.indent += 2 63 | try: 64 | if os.path.exists(location): 65 | # Subversion doesn't like to check out over an existing directory 66 | # --force fixes this, but was only added in svn 1.5 67 | rmtree(location) 68 | call_subprocess( 69 | [self.cmd, 'export'] + rev_options + [url, location], 70 | filter_stdout=self._filter, show_stdout=False) 71 | finally: 72 | logger.indent -= 2 73 | 74 | def switch(self, dest, url, rev_options): 75 | call_subprocess( 76 | [self.cmd, 'switch'] + rev_options + [url, dest]) 77 | 78 | def update(self, dest, rev_options): 79 | call_subprocess( 80 | [self.cmd, 'update'] + rev_options + [dest]) 81 | 82 | def obtain(self, dest): 83 | url, rev = self.get_url_rev() 84 | rev_options = get_rev_options(url, rev) 85 | if rev: 86 | rev_display = ' (to revision %s)' % rev 87 | else: 88 | rev_display = '' 89 | if self.check_destination(dest, url, rev_options, rev_display): 90 | logger.notify('Checking out %s%s to %s' 91 | % (url, rev_display, display_path(dest))) 92 | call_subprocess( 93 | [self.cmd, 'checkout', '-q'] + rev_options + [url, dest]) 94 | 95 | def get_location(self, dist, dependency_links): 96 | for url in dependency_links: 97 | egg_fragment = Link(url).egg_fragment 98 | if not egg_fragment: 99 | continue 100 | if '-' in egg_fragment: 101 | ## FIXME: will this work when a package has - in the name? 102 | key = '-'.join(egg_fragment.split('-')[:-1]).lower() 103 | else: 104 | key = egg_fragment 105 | if key == dist.key: 106 | return url.split('#', 1)[0] 107 | return None 108 | 109 | def get_revision(self, location): 110 | """ 111 | Return the maximum revision for all files under a given location 112 | """ 113 | # Note: taken from setuptools.command.egg_info 114 | revision = 0 115 | 116 | for base, dirs, files in os.walk(location): 117 | if self.dirname not in dirs: 118 | dirs[:] = [] 119 | continue # no sense walking uncontrolled subdirs 120 | dirs.remove(self.dirname) 121 | entries_fn = os.path.join(base, self.dirname, 'entries') 122 | if not os.path.exists(entries_fn): 123 | ## FIXME: should we warn? 124 | continue 125 | 126 | dirurl, localrev = self._get_svn_url_rev(base) 127 | 128 | if base == location: 129 | base_url = dirurl+'/' # save the root url 130 | elif not dirurl or not dirurl.startswith(base_url): 131 | dirs[:] = [] 132 | continue # not part of the same svn tree, skip it 133 | revision = max(revision, localrev) 134 | return revision 135 | 136 | def get_url_rev(self): 137 | # hotfix the URL scheme after removing svn+ from svn+ssh:// readd it 138 | url, rev = super(Subversion, self).get_url_rev() 139 | if url.startswith('ssh://'): 140 | url = 'svn+' + url 141 | return url, rev 142 | 143 | def get_url(self, location): 144 | # In cases where the source is in a subdirectory, not alongside setup.py 145 | # we have to look up in the location until we find a real setup.py 146 | orig_location = location 147 | while not os.path.exists(os.path.join(location, 'setup.py')): 148 | last_location = location 149 | location = os.path.dirname(location) 150 | if location == last_location: 151 | # We've traversed up to the root of the filesystem without finding setup.py 152 | logger.warn("Could not find setup.py for directory %s (tried all parent directories)" 153 | % orig_location) 154 | return None 155 | 156 | return self._get_svn_url_rev(location)[0] 157 | 158 | def _get_svn_url_rev(self, location): 159 | f = open(os.path.join(location, self.dirname, 'entries')) 160 | data = f.read() 161 | f.close() 162 | if data.startswith('8') or data.startswith('9') or data.startswith('10'): 163 | data = list(map(str.splitlines, data.split('\n\x0c\n'))) 164 | del data[0][0] # get rid of the '8' 165 | url = data[0][3] 166 | revs = [int(d[9]) for d in data if len(d)>9 and d[9]]+[0] 167 | elif data.startswith('= 1.7 176 | xml = call_subprocess([self.cmd, 'info', '--xml', location], show_stdout=False) 177 | url = _svn_info_xml_url_re.search(xml).group(1) 178 | revs = [int(m.group(1)) for m in _svn_info_xml_rev_re.finditer(xml)] 179 | except InstallationError: 180 | url, revs = None, [] 181 | 182 | if revs: 183 | rev = max(revs) 184 | else: 185 | rev = 0 186 | 187 | return url, rev 188 | 189 | def get_tag_revs(self, svn_tag_url): 190 | stdout = call_subprocess( 191 | [self.cmd, 'ls', '-v', svn_tag_url], show_stdout=False) 192 | results = [] 193 | for line in stdout.splitlines(): 194 | parts = line.split() 195 | rev = int(parts[0]) 196 | tag = parts[-1].strip('/') 197 | results.append((tag, rev)) 198 | return results 199 | 200 | def find_tag_match(self, rev, tag_revs): 201 | best_match_rev = None 202 | best_tag = None 203 | for tag, tag_rev in tag_revs: 204 | if (tag_rev > rev and 205 | (best_match_rev is None or best_match_rev > tag_rev)): 206 | # FIXME: Is best_match > tag_rev really possible? 207 | # or is it a sign something is wacky? 208 | best_match_rev = tag_rev 209 | best_tag = tag 210 | return best_tag 211 | 212 | def get_src_requirement(self, dist, location, find_tags=False): 213 | repo = self.get_url(location) 214 | if repo is None: 215 | return None 216 | parts = repo.split('/') 217 | ## FIXME: why not project name? 218 | egg_project_name = dist.egg_name().split('-', 1)[0] 219 | rev = self.get_revision(location) 220 | if parts[-2] in ('tags', 'tag'): 221 | # It's a tag, perfect! 222 | full_egg_name = '%s-%s' % (egg_project_name, parts[-1]) 223 | elif parts[-2] in ('branches', 'branch'): 224 | # It's a branch :( 225 | full_egg_name = '%s-%s-r%s' % (dist.egg_name(), parts[-1], rev) 226 | elif parts[-1] == 'trunk': 227 | # Trunk :-/ 228 | full_egg_name = '%s-dev_r%s' % (dist.egg_name(), rev) 229 | if find_tags: 230 | tag_url = '/'.join(parts[:-1]) + '/tags' 231 | tag_revs = self.get_tag_revs(tag_url) 232 | match = self.find_tag_match(rev, tag_revs) 233 | if match: 234 | logger.notify('trunk checkout %s seems to be equivalent to tag %s' % match) 235 | repo = '%s/%s' % (tag_url, match) 236 | full_egg_name = '%s-%s' % (egg_project_name, match) 237 | else: 238 | # Don't know what it is 239 | logger.warn('svn URL does not fit normal structure (tags/branches/trunk): %s' % repo) 240 | full_egg_name = '%s-dev_r%s' % (egg_project_name, rev) 241 | return 'svn+%s@%s#egg=%s' % (repo, rev, full_egg_name) 242 | 243 | 244 | def get_rev_options(url, rev): 245 | if rev: 246 | rev_options = ['-r', rev] 247 | else: 248 | rev_options = [] 249 | 250 | r = urlparse.urlsplit(url) 251 | if hasattr(r, 'username'): 252 | # >= Python-2.5 253 | username, password = r.username, r.password 254 | else: 255 | netloc = r[1] 256 | if '@' in netloc: 257 | auth = netloc.split('@')[0] 258 | if ':' in auth: 259 | username, password = auth.split(':', 1) 260 | else: 261 | username, password = auth, None 262 | else: 263 | username, password = None, None 264 | 265 | if username: 266 | rev_options += ['--username', username] 267 | if password: 268 | rev_options += ['--password', password] 269 | return rev_options 270 | 271 | 272 | vcs.register(Subversion) 273 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import tempfile 4 | import shutil 5 | from pip.req import InstallRequirement, RequirementSet 6 | from pip.req import parse_requirements 7 | from pip.log import logger 8 | from pip.locations import build_prefix, src_prefix, virtualenv_no_global 9 | from pip.basecommand import Command 10 | from pip.index import PackageFinder 11 | from pip.exceptions import InstallationError, CommandError 12 | from pip.backwardcompat import home_lib 13 | 14 | 15 | class InstallCommand(Command): 16 | name = 'install' 17 | usage = '%prog [OPTIONS] PACKAGE_NAMES...' 18 | summary = 'Install packages' 19 | bundle = False 20 | 21 | def __init__(self): 22 | super(InstallCommand, self).__init__() 23 | self.parser.add_option( 24 | '-e', '--editable', 25 | dest='editables', 26 | action='append', 27 | default=[], 28 | metavar='VCS+REPOS_URL[@REV]#egg=PACKAGE', 29 | help='Install a package directly from a checkout. Source will be checked ' 30 | 'out into src/PACKAGE (lower-case) and installed in-place (using ' 31 | 'setup.py develop). You can run this on an existing directory/checkout (like ' 32 | 'pip install -e src/mycheckout). This option may be provided multiple times. ' 33 | 'Possible values for VCS are: svn, git, hg and bzr.') 34 | self.parser.add_option( 35 | '-r', '--requirement', 36 | dest='requirements', 37 | action='append', 38 | default=[], 39 | metavar='FILENAME', 40 | help='Install all the packages listed in the given requirements file. ' 41 | 'This option can be used multiple times.') 42 | self.parser.add_option( 43 | '-f', '--find-links', 44 | dest='find_links', 45 | action='append', 46 | default=[], 47 | metavar='URL', 48 | help='URL to look for packages at') 49 | self.parser.add_option( 50 | '-i', '--index-url', '--pypi-url', 51 | dest='index_url', 52 | metavar='URL', 53 | default='http://pypi.python.org/simple/', 54 | help='Base URL of Python Package Index (default %default)') 55 | self.parser.add_option( 56 | '--extra-index-url', 57 | dest='extra_index_urls', 58 | metavar='URL', 59 | action='append', 60 | default=[], 61 | help='Extra URLs of package indexes to use in addition to --index-url') 62 | self.parser.add_option( 63 | '--no-index', 64 | dest='no_index', 65 | action='store_true', 66 | default=False, 67 | help='Ignore package index (only looking at --find-links URLs instead)') 68 | self.parser.add_option( 69 | '-M', '--use-mirrors', 70 | dest='use_mirrors', 71 | action='store_true', 72 | default=False, 73 | help='Use the PyPI mirrors as a fallback in case the main index is down.') 74 | self.parser.add_option( 75 | '--mirrors', 76 | dest='mirrors', 77 | metavar='URL', 78 | action='append', 79 | default=[], 80 | help='Specific mirror URLs to query when --use-mirrors is used') 81 | 82 | self.parser.add_option( 83 | '-b', '--build', '--build-dir', '--build-directory', 84 | dest='build_dir', 85 | metavar='DIR', 86 | default=build_prefix, 87 | help='Unpack packages into DIR (default %default) and build from there') 88 | self.parser.add_option( 89 | '-t', '--target', 90 | dest='target_dir', 91 | metavar='DIR', 92 | default=None, 93 | help='Install packages into DIR.') 94 | self.parser.add_option( 95 | '-d', '--download', '--download-dir', '--download-directory', 96 | dest='download_dir', 97 | metavar='DIR', 98 | default=None, 99 | help='Download packages into DIR instead of installing them') 100 | self.parser.add_option( 101 | '--download-cache', 102 | dest='download_cache', 103 | metavar='DIR', 104 | default=None, 105 | help='Cache downloaded packages in DIR') 106 | self.parser.add_option( 107 | '--src', '--source', '--source-dir', '--source-directory', 108 | dest='src_dir', 109 | metavar='DIR', 110 | default=src_prefix, 111 | help='Check out --editable packages into DIR (default %default)') 112 | 113 | self.parser.add_option( 114 | '-U', '--upgrade', 115 | dest='upgrade', 116 | action='store_true', 117 | help='Upgrade all packages to the newest available version') 118 | self.parser.add_option( 119 | '--force-reinstall', 120 | dest='force_reinstall', 121 | action='store_true', 122 | help='When upgrading, reinstall all packages even if they are ' 123 | 'already up-to-date.') 124 | self.parser.add_option( 125 | '-I', '--ignore-installed', 126 | dest='ignore_installed', 127 | action='store_true', 128 | help='Ignore the installed packages (reinstalling instead)') 129 | self.parser.add_option( 130 | '--no-deps', '--no-dependencies', 131 | dest='ignore_dependencies', 132 | action='store_true', 133 | default=False, 134 | help='Ignore package dependencies') 135 | self.parser.add_option( 136 | '--no-install', 137 | dest='no_install', 138 | action='store_true', 139 | help="Download and unpack all packages, but don't actually install them") 140 | self.parser.add_option( 141 | '--no-download', 142 | dest='no_download', 143 | action="store_true", 144 | help="Don't download any packages, just install the ones already downloaded " 145 | "(completes an install run with --no-install)") 146 | 147 | self.parser.add_option( 148 | '--install-option', 149 | dest='install_options', 150 | action='append', 151 | help="Extra arguments to be supplied to the setup.py install " 152 | "command (use like --install-option=\"--install-scripts=/usr/local/bin\"). " 153 | "Use multiple --install-option options to pass multiple options to setup.py install. " 154 | "If you are using an option with a directory path, be sure to use absolute path.") 155 | 156 | self.parser.add_option( 157 | '--global-option', 158 | dest='global_options', 159 | action='append', 160 | help="Extra global options to be supplied to the setup.py " 161 | "call before the install command") 162 | 163 | self.parser.add_option( 164 | '--user', 165 | dest='use_user_site', 166 | action='store_true', 167 | help='Install to user-site') 168 | 169 | self.parser.add_option( 170 | '--egg', 171 | dest='as_egg', 172 | action='store_true', 173 | help="Install as self contained egg file, like easy_install does.") 174 | 175 | def _build_package_finder(self, options, index_urls): 176 | """ 177 | Create a package finder appropriate to this install command. 178 | This method is meant to be overridden by subclasses, not 179 | called directly. 180 | """ 181 | return PackageFinder(find_links=options.find_links, 182 | index_urls=index_urls, 183 | use_mirrors=options.use_mirrors, 184 | mirrors=options.mirrors) 185 | 186 | def run(self, options, args): 187 | if options.download_dir: 188 | options.no_install = True 189 | options.ignore_installed = True 190 | options.build_dir = os.path.abspath(options.build_dir) 191 | options.src_dir = os.path.abspath(options.src_dir) 192 | install_options = options.install_options or [] 193 | if options.use_user_site: 194 | if virtualenv_no_global(): 195 | raise InstallationError("Can not perform a '--user' install. User site-packages are not visible in this virtualenv.") 196 | install_options.append('--user') 197 | if options.target_dir: 198 | options.ignore_installed = True 199 | temp_target_dir = tempfile.mkdtemp() 200 | options.target_dir = os.path.abspath(options.target_dir) 201 | if os.path.exists(options.target_dir) and not os.path.isdir(options.target_dir): 202 | raise CommandError("Target path exists but is not a directory, will not continue.") 203 | install_options.append('--home=' + temp_target_dir) 204 | global_options = options.global_options or [] 205 | index_urls = [options.index_url] + options.extra_index_urls 206 | if options.no_index: 207 | logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) 208 | index_urls = [] 209 | 210 | finder = self._build_package_finder(options, index_urls) 211 | 212 | requirement_set = RequirementSet( 213 | build_dir=options.build_dir, 214 | src_dir=options.src_dir, 215 | download_dir=options.download_dir, 216 | download_cache=options.download_cache, 217 | upgrade=options.upgrade, 218 | as_egg=options.as_egg, 219 | ignore_installed=options.ignore_installed, 220 | ignore_dependencies=options.ignore_dependencies, 221 | force_reinstall=options.force_reinstall, 222 | use_user_site=options.use_user_site) 223 | for name in args: 224 | requirement_set.add_requirement( 225 | InstallRequirement.from_line(name, None)) 226 | for name in options.editables: 227 | requirement_set.add_requirement( 228 | InstallRequirement.from_editable(name, default_vcs=options.default_vcs)) 229 | for filename in options.requirements: 230 | for req in parse_requirements(filename, finder=finder, options=options): 231 | requirement_set.add_requirement(req) 232 | if not requirement_set.has_requirements: 233 | opts = {'name': self.name} 234 | if options.find_links: 235 | msg = ('You must give at least one requirement to %(name)s ' 236 | '(maybe you meant "pip %(name)s %(links)s"?)' % 237 | dict(opts, links=' '.join(options.find_links))) 238 | else: 239 | msg = ('You must give at least one requirement ' 240 | 'to %(name)s (see "pip help %(name)s")' % opts) 241 | logger.warn(msg) 242 | return 243 | 244 | if (options.use_user_site and 245 | sys.version_info < (2, 6)): 246 | raise InstallationError('--user is only supported in Python version 2.6 and newer') 247 | 248 | import setuptools 249 | if (options.use_user_site and 250 | requirement_set.has_editables and 251 | not getattr(setuptools, '_distribute', False)): 252 | 253 | raise InstallationError('--user --editable not supported with setuptools, use distribute') 254 | 255 | if not options.no_download: 256 | requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) 257 | else: 258 | requirement_set.locate_files() 259 | 260 | if not options.no_install and not self.bundle: 261 | requirement_set.install(install_options, global_options) 262 | installed = ' '.join([req.name for req in 263 | requirement_set.successfully_installed]) 264 | if installed: 265 | logger.notify('Successfully installed %s' % installed) 266 | elif not self.bundle: 267 | downloaded = ' '.join([req.name for req in 268 | requirement_set.successfully_downloaded]) 269 | if downloaded: 270 | logger.notify('Successfully downloaded %s' % downloaded) 271 | elif self.bundle: 272 | requirement_set.create_bundle(self.bundle_filename) 273 | logger.notify('Created bundle in %s' % self.bundle_filename) 274 | # Clean up 275 | if not options.no_install or options.download_dir: 276 | requirement_set.cleanup_files(bundle=self.bundle) 277 | if options.target_dir: 278 | if not os.path.exists(options.target_dir): 279 | os.makedirs(options.target_dir) 280 | lib_dir = home_lib(temp_target_dir) 281 | for item in os.listdir(lib_dir): 282 | shutil.move( 283 | os.path.join(lib_dir, item), 284 | os.path.join(options.target_dir, item) 285 | ) 286 | shutil.rmtree(temp_target_dir) 287 | return requirement_set 288 | 289 | 290 | InstallCommand() 291 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/zip.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | import fnmatch 4 | import os 5 | import shutil 6 | import zipfile 7 | from pip.util import display_path, backup_dir, rmtree 8 | from pip.log import logger 9 | from pip.exceptions import InstallationError 10 | from pip.basecommand import Command 11 | 12 | 13 | class ZipCommand(Command): 14 | name = 'zip' 15 | usage = '%prog [OPTIONS] PACKAGE_NAMES...' 16 | summary = 'Zip individual packages' 17 | 18 | def __init__(self): 19 | super(ZipCommand, self).__init__() 20 | if self.name == 'zip': 21 | self.parser.add_option( 22 | '--unzip', 23 | action='store_true', 24 | dest='unzip', 25 | help='Unzip (rather than zip) a package') 26 | else: 27 | self.parser.add_option( 28 | '--zip', 29 | action='store_false', 30 | dest='unzip', 31 | default=True, 32 | help='Zip (rather than unzip) a package') 33 | self.parser.add_option( 34 | '--no-pyc', 35 | action='store_true', 36 | dest='no_pyc', 37 | help='Do not include .pyc files in zip files (useful on Google App Engine)') 38 | self.parser.add_option( 39 | '-l', '--list', 40 | action='store_true', 41 | dest='list', 42 | help='List the packages available, and their zip status') 43 | self.parser.add_option( 44 | '--sort-files', 45 | action='store_true', 46 | dest='sort_files', 47 | help='With --list, sort packages according to how many files they contain') 48 | self.parser.add_option( 49 | '--path', 50 | action='append', 51 | dest='paths', 52 | help='Restrict operations to the given paths (may include wildcards)') 53 | self.parser.add_option( 54 | '-n', '--simulate', 55 | action='store_true', 56 | help='Do not actually perform the zip/unzip operation') 57 | 58 | def paths(self): 59 | """All the entries of sys.path, possibly restricted by --path""" 60 | if not self.select_paths: 61 | return sys.path 62 | result = [] 63 | match_any = set() 64 | for path in sys.path: 65 | path = os.path.normcase(os.path.abspath(path)) 66 | for match in self.select_paths: 67 | match = os.path.normcase(os.path.abspath(match)) 68 | if '*' in match: 69 | if re.search(fnmatch.translate(match+'*'), path): 70 | result.append(path) 71 | match_any.add(match) 72 | break 73 | else: 74 | if path.startswith(match): 75 | result.append(path) 76 | match_any.add(match) 77 | break 78 | else: 79 | logger.debug("Skipping path %s because it doesn't match %s" 80 | % (path, ', '.join(self.select_paths))) 81 | for match in self.select_paths: 82 | if match not in match_any and '*' not in match: 83 | result.append(match) 84 | logger.debug("Adding path %s because it doesn't match anything already on sys.path" 85 | % match) 86 | return result 87 | 88 | def run(self, options, args): 89 | self.select_paths = options.paths 90 | self.simulate = options.simulate 91 | if options.list: 92 | return self.list(options, args) 93 | if not args: 94 | raise InstallationError( 95 | 'You must give at least one package to zip or unzip') 96 | packages = [] 97 | for arg in args: 98 | module_name, filename = self.find_package(arg) 99 | if options.unzip and os.path.isdir(filename): 100 | raise InstallationError( 101 | 'The module %s (in %s) is not a zip file; cannot be unzipped' 102 | % (module_name, filename)) 103 | elif not options.unzip and not os.path.isdir(filename): 104 | raise InstallationError( 105 | 'The module %s (in %s) is not a directory; cannot be zipped' 106 | % (module_name, filename)) 107 | packages.append((module_name, filename)) 108 | last_status = None 109 | for module_name, filename in packages: 110 | if options.unzip: 111 | last_status = self.unzip_package(module_name, filename) 112 | else: 113 | last_status = self.zip_package(module_name, filename, options.no_pyc) 114 | return last_status 115 | 116 | def unzip_package(self, module_name, filename): 117 | zip_filename = os.path.dirname(filename) 118 | if not os.path.isfile(zip_filename) and zipfile.is_zipfile(zip_filename): 119 | raise InstallationError( 120 | 'Module %s (in %s) isn\'t located in a zip file in %s' 121 | % (module_name, filename, zip_filename)) 122 | package_path = os.path.dirname(zip_filename) 123 | if not package_path in self.paths(): 124 | logger.warn( 125 | 'Unpacking %s into %s, but %s is not on sys.path' 126 | % (display_path(zip_filename), display_path(package_path), 127 | display_path(package_path))) 128 | logger.notify('Unzipping %s (in %s)' % (module_name, display_path(zip_filename))) 129 | if self.simulate: 130 | logger.notify('Skipping remaining operations because of --simulate') 131 | return 132 | logger.indent += 2 133 | try: 134 | ## FIXME: this should be undoable: 135 | zip = zipfile.ZipFile(zip_filename) 136 | to_save = [] 137 | for name in zip.namelist(): 138 | if name.startswith(module_name + os.path.sep): 139 | content = zip.read(name) 140 | dest = os.path.join(package_path, name) 141 | if not os.path.exists(os.path.dirname(dest)): 142 | os.makedirs(os.path.dirname(dest)) 143 | if not content and dest.endswith(os.path.sep): 144 | if not os.path.exists(dest): 145 | os.makedirs(dest) 146 | else: 147 | f = open(dest, 'wb') 148 | f.write(content) 149 | f.close() 150 | else: 151 | to_save.append((name, zip.read(name))) 152 | zip.close() 153 | if not to_save: 154 | logger.info('Removing now-empty zip file %s' % display_path(zip_filename)) 155 | os.unlink(zip_filename) 156 | self.remove_filename_from_pth(zip_filename) 157 | else: 158 | logger.info('Removing entries in %s/ from zip file %s' % (module_name, display_path(zip_filename))) 159 | zip = zipfile.ZipFile(zip_filename, 'w') 160 | for name, content in to_save: 161 | zip.writestr(name, content) 162 | zip.close() 163 | finally: 164 | logger.indent -= 2 165 | 166 | def zip_package(self, module_name, filename, no_pyc): 167 | orig_filename = filename 168 | logger.notify('Zip %s (in %s)' % (module_name, display_path(filename))) 169 | logger.indent += 2 170 | if filename.endswith('.egg'): 171 | dest_filename = filename 172 | else: 173 | dest_filename = filename + '.zip' 174 | try: 175 | ## FIXME: I think this needs to be undoable: 176 | if filename == dest_filename: 177 | filename = backup_dir(orig_filename) 178 | logger.notify('Moving %s aside to %s' % (orig_filename, filename)) 179 | if not self.simulate: 180 | shutil.move(orig_filename, filename) 181 | try: 182 | logger.info('Creating zip file in %s' % display_path(dest_filename)) 183 | if not self.simulate: 184 | zip = zipfile.ZipFile(dest_filename, 'w') 185 | zip.writestr(module_name + '/', '') 186 | for dirpath, dirnames, filenames in os.walk(filename): 187 | if no_pyc: 188 | filenames = [f for f in filenames 189 | if not f.lower().endswith('.pyc')] 190 | for fns, is_dir in [(dirnames, True), (filenames, False)]: 191 | for fn in fns: 192 | full = os.path.join(dirpath, fn) 193 | dest = os.path.join(module_name, dirpath[len(filename):].lstrip(os.path.sep), fn) 194 | if is_dir: 195 | zip.writestr(dest+'/', '') 196 | else: 197 | zip.write(full, dest) 198 | zip.close() 199 | logger.info('Removing old directory %s' % display_path(filename)) 200 | if not self.simulate: 201 | rmtree(filename) 202 | except: 203 | ## FIXME: need to do an undo here 204 | raise 205 | ## FIXME: should also be undone: 206 | self.add_filename_to_pth(dest_filename) 207 | finally: 208 | logger.indent -= 2 209 | 210 | def remove_filename_from_pth(self, filename): 211 | for pth in self.pth_files(): 212 | f = open(pth, 'r') 213 | lines = f.readlines() 214 | f.close() 215 | new_lines = [ 216 | l for l in lines if l.strip() != filename] 217 | if lines != new_lines: 218 | logger.info('Removing reference to %s from .pth file %s' 219 | % (display_path(filename), display_path(pth))) 220 | if not [line for line in new_lines if line]: 221 | logger.info('%s file would be empty: deleting' % display_path(pth)) 222 | if not self.simulate: 223 | os.unlink(pth) 224 | else: 225 | if not self.simulate: 226 | f = open(pth, 'wb') 227 | f.writelines(new_lines) 228 | f.close() 229 | return 230 | logger.warn('Cannot find a reference to %s in any .pth file' % display_path(filename)) 231 | 232 | def add_filename_to_pth(self, filename): 233 | path = os.path.dirname(filename) 234 | dest = filename + '.pth' 235 | if path not in self.paths(): 236 | logger.warn('Adding .pth file %s, but it is not on sys.path' % display_path(dest)) 237 | if not self.simulate: 238 | if os.path.exists(dest): 239 | f = open(dest) 240 | lines = f.readlines() 241 | f.close() 242 | if lines and not lines[-1].endswith('\n'): 243 | lines[-1] += '\n' 244 | lines.append(filename+'\n') 245 | else: 246 | lines = [filename + '\n'] 247 | f = open(dest, 'wb') 248 | f.writelines(lines) 249 | f.close() 250 | 251 | def pth_files(self): 252 | for path in self.paths(): 253 | if not os.path.exists(path) or not os.path.isdir(path): 254 | continue 255 | for filename in os.listdir(path): 256 | if filename.endswith('.pth'): 257 | yield os.path.join(path, filename) 258 | 259 | def find_package(self, package): 260 | for path in self.paths(): 261 | full = os.path.join(path, package) 262 | if os.path.exists(full): 263 | return package, full 264 | if not os.path.isdir(path) and zipfile.is_zipfile(path): 265 | zip = zipfile.ZipFile(path, 'r') 266 | try: 267 | zip.read(os.path.join(package, '__init__.py')) 268 | except KeyError: 269 | pass 270 | else: 271 | zip.close() 272 | return package, full 273 | zip.close() 274 | ## FIXME: need special error for package.py case: 275 | raise InstallationError( 276 | 'No package with the name %s found' % package) 277 | 278 | def list(self, options, args): 279 | if args: 280 | raise InstallationError( 281 | 'You cannot give an argument with --list') 282 | for path in sorted(self.paths()): 283 | if not os.path.exists(path): 284 | continue 285 | basename = os.path.basename(path.rstrip(os.path.sep)) 286 | if os.path.isfile(path) and zipfile.is_zipfile(path): 287 | if os.path.dirname(path) not in self.paths(): 288 | logger.notify('Zipped egg: %s' % display_path(path)) 289 | continue 290 | if (basename != 'site-packages' and basename != 'dist-packages' 291 | and not path.replace('\\', '/').endswith('lib/python')): 292 | continue 293 | logger.notify('In %s:' % display_path(path)) 294 | logger.indent += 2 295 | zipped = [] 296 | unzipped = [] 297 | try: 298 | for filename in sorted(os.listdir(path)): 299 | ext = os.path.splitext(filename)[1].lower() 300 | if ext in ('.pth', '.egg-info', '.egg-link'): 301 | continue 302 | if ext == '.py': 303 | logger.info('Not displaying %s: not a package' % display_path(filename)) 304 | continue 305 | full = os.path.join(path, filename) 306 | if os.path.isdir(full): 307 | unzipped.append((filename, self.count_package(full))) 308 | elif zipfile.is_zipfile(full): 309 | zipped.append(filename) 310 | else: 311 | logger.info('Unknown file: %s' % display_path(filename)) 312 | if zipped: 313 | logger.notify('Zipped packages:') 314 | logger.indent += 2 315 | try: 316 | for filename in zipped: 317 | logger.notify(filename) 318 | finally: 319 | logger.indent -= 2 320 | else: 321 | logger.notify('No zipped packages.') 322 | if unzipped: 323 | if options.sort_files: 324 | unzipped.sort(key=lambda x: -x[1]) 325 | logger.notify('Unzipped packages:') 326 | logger.indent += 2 327 | try: 328 | for filename, count in unzipped: 329 | logger.notify('%s (%i files)' % (filename, count)) 330 | finally: 331 | logger.indent -= 2 332 | else: 333 | logger.notify('No unzipped packages.') 334 | finally: 335 | logger.indent -= 2 336 | 337 | def count_package(self, path): 338 | total = 0 339 | for dirpath, dirnames, filenames in os.walk(path): 340 | filenames = [f for f in filenames 341 | if not f.lower().endswith('.pyc')] 342 | total += len(filenames) 343 | return total 344 | 345 | 346 | ZipCommand() 347 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg/pip/download.py: -------------------------------------------------------------------------------- 1 | import cgi 2 | import getpass 3 | import hashlib 4 | import mimetypes 5 | import os 6 | import re 7 | import shutil 8 | import sys 9 | import tempfile 10 | from pip.backwardcompat import (xmlrpclib, urllib, urllib2, 11 | urlparse, string_types) 12 | from pip.exceptions import InstallationError 13 | from pip.util import (splitext, rmtree, format_size, display_path, 14 | backup_dir, ask_path_exists, unpack_file, 15 | create_download_cache_folder, cache_download) 16 | from pip.vcs import vcs 17 | from pip.log import logger 18 | 19 | 20 | __all__ = ['xmlrpclib_transport', 'get_file_content', 'urlopen', 21 | 'is_url', 'url_to_path', 'path_to_url', 'path_to_url2', 22 | 'geturl', 'is_archive_file', 'unpack_vcs_link', 23 | 'unpack_file_url', 'is_vcs_url', 'is_file_url', 'unpack_http_url'] 24 | 25 | 26 | xmlrpclib_transport = xmlrpclib.Transport() 27 | 28 | 29 | def get_file_content(url, comes_from=None): 30 | """Gets the content of a file; it may be a filename, file: URL, or 31 | http: URL. Returns (location, content)""" 32 | match = _scheme_re.search(url) 33 | if match: 34 | scheme = match.group(1).lower() 35 | if (scheme == 'file' and comes_from 36 | and comes_from.startswith('http')): 37 | raise InstallationError( 38 | 'Requirements file %s references URL %s, which is local' 39 | % (comes_from, url)) 40 | if scheme == 'file': 41 | path = url.split(':', 1)[1] 42 | path = path.replace('\\', '/') 43 | match = _url_slash_drive_re.match(path) 44 | if match: 45 | path = match.group(1) + ':' + path.split('|', 1)[1] 46 | path = urllib.unquote(path) 47 | if path.startswith('/'): 48 | path = '/' + path.lstrip('/') 49 | url = path 50 | else: 51 | ## FIXME: catch some errors 52 | resp = urlopen(url) 53 | return geturl(resp), resp.read() 54 | try: 55 | f = open(url) 56 | content = f.read() 57 | except IOError: 58 | e = sys.exc_info()[1] 59 | raise InstallationError('Could not open requirements file: %s' % str(e)) 60 | else: 61 | f.close() 62 | return url, content 63 | 64 | 65 | _scheme_re = re.compile(r'^(http|https|file):', re.I) 66 | _url_slash_drive_re = re.compile(r'/*([a-z])\|', re.I) 67 | 68 | 69 | class URLOpener(object): 70 | """ 71 | pip's own URL helper that adds HTTP auth and proxy support 72 | """ 73 | def __init__(self): 74 | self.passman = urllib2.HTTPPasswordMgrWithDefaultRealm() 75 | 76 | def __call__(self, url): 77 | """ 78 | If the given url contains auth info or if a normal request gets a 401 79 | response, an attempt is made to fetch the resource using basic HTTP 80 | auth. 81 | 82 | """ 83 | url, username, password = self.extract_credentials(url) 84 | if username is None: 85 | try: 86 | response = urllib2.urlopen(self.get_request(url)) 87 | except urllib2.HTTPError: 88 | e = sys.exc_info()[1] 89 | if e.code != 401: 90 | raise 91 | response = self.get_response(url) 92 | else: 93 | response = self.get_response(url, username, password) 94 | return response 95 | 96 | def get_request(self, url): 97 | """ 98 | Wraps the URL to retrieve to protects against "creative" 99 | interpretation of the RFC: http://bugs.python.org/issue8732 100 | """ 101 | if isinstance(url, string_types): 102 | url = urllib2.Request(url, headers={'Accept-encoding': 'identity'}) 103 | return url 104 | 105 | def get_response(self, url, username=None, password=None): 106 | """ 107 | does the dirty work of actually getting the rsponse object using urllib2 108 | and its HTTP auth builtins. 109 | """ 110 | scheme, netloc, path, query, frag = urlparse.urlsplit(url) 111 | req = self.get_request(url) 112 | 113 | stored_username, stored_password = self.passman.find_user_password(None, netloc) 114 | # see if we have a password stored 115 | if stored_username is None: 116 | if username is None and self.prompting: 117 | username = urllib.quote(raw_input('User for %s: ' % netloc)) 118 | password = urllib.quote(getpass.getpass('Password: ')) 119 | if username and password: 120 | self.passman.add_password(None, netloc, username, password) 121 | stored_username, stored_password = self.passman.find_user_password(None, netloc) 122 | authhandler = urllib2.HTTPBasicAuthHandler(self.passman) 123 | opener = urllib2.build_opener(authhandler) 124 | # FIXME: should catch a 401 and offer to let the user reenter credentials 125 | return opener.open(req) 126 | 127 | def setup(self, proxystr='', prompting=True): 128 | """ 129 | Sets the proxy handler given the option passed on the command 130 | line. If an empty string is passed it looks at the HTTP_PROXY 131 | environment variable. 132 | """ 133 | self.prompting = prompting 134 | proxy = self.get_proxy(proxystr) 135 | if proxy: 136 | proxy_support = urllib2.ProxyHandler({"http": proxy, "ftp": proxy, "https": proxy}) 137 | opener = urllib2.build_opener(proxy_support, urllib2.CacheFTPHandler) 138 | urllib2.install_opener(opener) 139 | 140 | def parse_credentials(self, netloc): 141 | if "@" in netloc: 142 | userinfo = netloc.rsplit("@", 1)[0] 143 | if ":" in userinfo: 144 | return userinfo.split(":", 1) 145 | return userinfo, None 146 | return None, None 147 | 148 | def extract_credentials(self, url): 149 | """ 150 | Extracts user/password from a url. 151 | 152 | Returns a tuple: 153 | (url-without-auth, username, password) 154 | """ 155 | if isinstance(url, urllib2.Request): 156 | result = urlparse.urlsplit(url.get_full_url()) 157 | else: 158 | result = urlparse.urlsplit(url) 159 | scheme, netloc, path, query, frag = result 160 | 161 | username, password = self.parse_credentials(netloc) 162 | if username is None: 163 | return url, None, None 164 | elif password is None and self.prompting: 165 | # remove the auth credentials from the url part 166 | netloc = netloc.replace('%s@' % username, '', 1) 167 | # prompt for the password 168 | prompt = 'Password for %s@%s: ' % (username, netloc) 169 | password = urllib.quote(getpass.getpass(prompt)) 170 | else: 171 | # remove the auth credentials from the url part 172 | netloc = netloc.replace('%s:%s@' % (username, password), '', 1) 173 | 174 | target_url = urlparse.urlunsplit((scheme, netloc, path, query, frag)) 175 | return target_url, username, password 176 | 177 | def get_proxy(self, proxystr=''): 178 | """ 179 | Get the proxy given the option passed on the command line. 180 | If an empty string is passed it looks at the HTTP_PROXY 181 | environment variable. 182 | """ 183 | if not proxystr: 184 | proxystr = os.environ.get('HTTP_PROXY', '') 185 | if proxystr: 186 | if '@' in proxystr: 187 | user_password, server_port = proxystr.split('@', 1) 188 | if ':' in user_password: 189 | user, password = user_password.split(':', 1) 190 | else: 191 | user = user_password 192 | prompt = 'Password for %s@%s: ' % (user, server_port) 193 | password = urllib.quote(getpass.getpass(prompt)) 194 | return '%s:%s@%s' % (user, password, server_port) 195 | else: 196 | return proxystr 197 | else: 198 | return None 199 | 200 | urlopen = URLOpener() 201 | 202 | 203 | def is_url(name): 204 | """Returns true if the name looks like a URL""" 205 | if ':' not in name: 206 | return False 207 | scheme = name.split(':', 1)[0].lower() 208 | return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes 209 | 210 | 211 | def url_to_path(url): 212 | """ 213 | Convert a file: URL to a path. 214 | """ 215 | assert url.startswith('file:'), ( 216 | "You can only turn file: urls into filenames (not %r)" % url) 217 | path = url[len('file:'):].lstrip('/') 218 | path = urllib.unquote(path) 219 | if _url_drive_re.match(path): 220 | path = path[0] + ':' + path[2:] 221 | else: 222 | path = '/' + path 223 | return path 224 | 225 | 226 | _drive_re = re.compile('^([a-z]):', re.I) 227 | _url_drive_re = re.compile('^([a-z])[:|]', re.I) 228 | 229 | 230 | def path_to_url(path): 231 | """ 232 | Convert a path to a file: URL. The path will be made absolute. 233 | """ 234 | path = os.path.normcase(os.path.abspath(path)) 235 | if _drive_re.match(path): 236 | path = path[0] + '|' + path[2:] 237 | url = urllib.quote(path) 238 | url = url.replace(os.path.sep, '/') 239 | url = url.lstrip('/') 240 | return 'file:///' + url 241 | 242 | 243 | def path_to_url2(path): 244 | """ 245 | Convert a path to a file: URL. The path will be made absolute and have 246 | quoted path parts. 247 | """ 248 | path = os.path.normpath(os.path.abspath(path)) 249 | drive, path = os.path.splitdrive(path) 250 | filepath = path.split(os.path.sep) 251 | url = '/'.join([urllib.quote(part) for part in filepath]) 252 | if not drive: 253 | url = url.lstrip('/') 254 | return 'file:///' + drive + url 255 | 256 | 257 | def geturl(urllib2_resp): 258 | """ 259 | Use instead of urllib.addinfourl.geturl(), which appears to have 260 | some issues with dropping the double slash for certain schemes 261 | (e.g. file://). This implementation is probably over-eager, as it 262 | always restores '://' if it is missing, and it appears some url 263 | schemata aren't always followed by '//' after the colon, but as 264 | far as I know pip doesn't need any of those. 265 | The URI RFC can be found at: http://tools.ietf.org/html/rfc1630 266 | 267 | This function assumes that 268 | scheme:/foo/bar 269 | is the same as 270 | scheme:///foo/bar 271 | """ 272 | url = urllib2_resp.geturl() 273 | scheme, rest = url.split(':', 1) 274 | if rest.startswith('//'): 275 | return url 276 | else: 277 | # FIXME: write a good test to cover it 278 | return '%s://%s' % (scheme, rest) 279 | 280 | 281 | def is_archive_file(name): 282 | """Return True if `name` is a considered as an archive file.""" 283 | archives = ('.zip', '.tar.gz', '.tar.bz2', '.tgz', '.tar', '.pybundle') 284 | ext = splitext(name)[1].lower() 285 | if ext in archives: 286 | return True 287 | return False 288 | 289 | 290 | def unpack_vcs_link(link, location, only_download=False): 291 | vcs_backend = _get_used_vcs_backend(link) 292 | if only_download: 293 | vcs_backend.export(location) 294 | else: 295 | vcs_backend.unpack(location) 296 | 297 | 298 | def unpack_file_url(link, location): 299 | source = url_to_path(link.url) 300 | content_type = mimetypes.guess_type(source)[0] 301 | if os.path.isdir(source): 302 | # delete the location since shutil will create it again :( 303 | if os.path.isdir(location): 304 | rmtree(location) 305 | shutil.copytree(source, location) 306 | else: 307 | unpack_file(source, location, content_type, link) 308 | 309 | 310 | def _get_used_vcs_backend(link): 311 | for backend in vcs.backends: 312 | if link.scheme in backend.schemes: 313 | vcs_backend = backend(link.url) 314 | return vcs_backend 315 | 316 | 317 | def is_vcs_url(link): 318 | return bool(_get_used_vcs_backend(link)) 319 | 320 | 321 | def is_file_url(link): 322 | return link.url.lower().startswith('file:') 323 | 324 | 325 | def _check_hash(download_hash, link): 326 | if download_hash.digest_size != hashlib.new(link.hash_name).digest_size: 327 | logger.fatal("Hash digest size of the package %d (%s) doesn't match the expected hash name %s!" 328 | % (download_hash.digest_size, link, link.hash_name)) 329 | raise InstallationError('Hash name mismatch for package %s' % link) 330 | if download_hash.hexdigest() != link.hash: 331 | logger.fatal("Hash of the package %s (%s) doesn't match the expected hash %s!" 332 | % (link, download_hash, link.hash)) 333 | raise InstallationError('Bad %s hash for package %s' % (link.hash_name, link)) 334 | 335 | 336 | def _get_hash_from_file(target_file, link): 337 | try: 338 | download_hash = hashlib.new(link.hash_name) 339 | except (ValueError, TypeError): 340 | logger.warn("Unsupported hash name %s for package %s" % (link.hash_name, link)) 341 | return None 342 | 343 | fp = open(target_file, 'rb') 344 | while True: 345 | chunk = fp.read(4096) 346 | if not chunk: 347 | break 348 | download_hash.update(chunk) 349 | fp.close() 350 | return download_hash 351 | 352 | 353 | def _download_url(resp, link, temp_location): 354 | fp = open(temp_location, 'wb') 355 | download_hash = None 356 | if link.hash and link.hash_name: 357 | try: 358 | download_hash = hashlib.new(link.hash_name) 359 | except ValueError: 360 | logger.warn("Unsupported hash name %s for package %s" % (link.hash_name, link)) 361 | try: 362 | total_length = int(resp.info()['content-length']) 363 | except (ValueError, KeyError, TypeError): 364 | total_length = 0 365 | downloaded = 0 366 | show_progress = total_length > 40*1000 or not total_length 367 | show_url = link.show_url 368 | try: 369 | if show_progress: 370 | ## FIXME: the URL can get really long in this message: 371 | if total_length: 372 | logger.start_progress('Downloading %s (%s): ' % (show_url, format_size(total_length))) 373 | else: 374 | logger.start_progress('Downloading %s (unknown size): ' % show_url) 375 | else: 376 | logger.notify('Downloading %s' % show_url) 377 | logger.debug('Downloading from URL %s' % link) 378 | 379 | while True: 380 | chunk = resp.read(4096) 381 | if not chunk: 382 | break 383 | downloaded += len(chunk) 384 | if show_progress: 385 | if not total_length: 386 | logger.show_progress('%s' % format_size(downloaded)) 387 | else: 388 | logger.show_progress('%3i%% %s' % (100*downloaded/total_length, format_size(downloaded))) 389 | if download_hash is not None: 390 | download_hash.update(chunk) 391 | fp.write(chunk) 392 | fp.close() 393 | finally: 394 | if show_progress: 395 | logger.end_progress('%s downloaded' % format_size(downloaded)) 396 | return download_hash 397 | 398 | 399 | def _copy_file(filename, location, content_type, link): 400 | copy = True 401 | download_location = os.path.join(location, link.filename) 402 | if os.path.exists(download_location): 403 | response = ask_path_exists( 404 | 'The file %s exists. (i)gnore, (w)ipe, (b)ackup ' % 405 | display_path(download_location), ('i', 'w', 'b')) 406 | if response == 'i': 407 | copy = False 408 | elif response == 'w': 409 | logger.warn('Deleting %s' % display_path(download_location)) 410 | os.remove(download_location) 411 | elif response == 'b': 412 | dest_file = backup_dir(download_location) 413 | logger.warn('Backing up %s to %s' 414 | % (display_path(download_location), display_path(dest_file))) 415 | shutil.move(download_location, dest_file) 416 | if copy: 417 | shutil.copy(filename, download_location) 418 | logger.indent -= 2 419 | logger.notify('Saved %s' % display_path(download_location)) 420 | 421 | 422 | def unpack_http_url(link, location, download_cache, download_dir=None): 423 | temp_dir = tempfile.mkdtemp('-unpack', 'pip-') 424 | target_url = link.url.split('#', 1)[0] 425 | target_file = None 426 | download_hash = None 427 | if download_cache: 428 | target_file = os.path.join(download_cache, 429 | urllib.quote(target_url, '')) 430 | if not os.path.isdir(download_cache): 431 | create_download_cache_folder(download_cache) 432 | if (target_file 433 | and os.path.exists(target_file) 434 | and os.path.exists(target_file + '.content-type')): 435 | fp = open(target_file+'.content-type') 436 | content_type = fp.read().strip() 437 | fp.close() 438 | if link.hash and link.hash_name: 439 | download_hash = _get_hash_from_file(target_file, link) 440 | temp_location = target_file 441 | logger.notify('Using download cache from %s' % target_file) 442 | else: 443 | resp = _get_response_from_url(target_url, link) 444 | content_type = resp.info()['content-type'] 445 | filename = link.filename # fallback 446 | # Have a look at the Content-Disposition header for a better guess 447 | content_disposition = resp.info().get('content-disposition') 448 | if content_disposition: 449 | type, params = cgi.parse_header(content_disposition) 450 | # We use ``or`` here because we don't want to use an "empty" value 451 | # from the filename param. 452 | filename = params.get('filename') or filename 453 | ext = splitext(filename)[1] 454 | if not ext: 455 | ext = mimetypes.guess_extension(content_type) 456 | if ext: 457 | filename += ext 458 | if not ext and link.url != geturl(resp): 459 | ext = os.path.splitext(geturl(resp))[1] 460 | if ext: 461 | filename += ext 462 | temp_location = os.path.join(temp_dir, filename) 463 | download_hash = _download_url(resp, link, temp_location) 464 | if link.hash and link.hash_name: 465 | _check_hash(download_hash, link) 466 | if download_dir: 467 | _copy_file(temp_location, download_dir, content_type, link) 468 | unpack_file(temp_location, location, content_type, link) 469 | if target_file and target_file != temp_location: 470 | cache_download(target_file, temp_location, content_type) 471 | if target_file is None: 472 | os.unlink(temp_location) 473 | os.rmdir(temp_dir) 474 | 475 | 476 | def _get_response_from_url(target_url, link): 477 | try: 478 | resp = urlopen(target_url) 479 | except urllib2.HTTPError: 480 | e = sys.exc_info()[1] 481 | logger.fatal("HTTP error %s while getting %s" % (e.code, link)) 482 | raise 483 | except IOError: 484 | e = sys.exc_info()[1] 485 | # Typically an FTP error 486 | logger.fatal("Error %s while getting %s" % (e, link)) 487 | raise 488 | return resp 489 | 490 | 491 | class Urllib2HeadRequest(urllib2.Request): 492 | def get_method(self): 493 | return "HEAD" 494 | -------------------------------------------------------------------------------- /venv/lib/python2.7/site-packages/pep8-1.4.5-py2.7.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: pep8 3 | Version: 1.4.5 4 | Summary: Python style guide checker 5 | Home-page: http://pep8.readthedocs.org/ 6 | Author: Johann C. Rocholl 7 | Author-email: johann@rocholl.net 8 | License: Expat license 9 | Description: pep8 - Python style guide checker 10 | ================================= 11 | 12 | pep8 is a tool to check your Python code against some of the style 13 | conventions in `PEP 8`_. 14 | 15 | .. _PEP 8: http://www.python.org/dev/peps/pep-0008/ 16 | 17 | 18 | Features 19 | -------- 20 | 21 | * Plugin architecture: Adding new checks is easy. 22 | 23 | * Parseable output: Jump to error location in your editor. 24 | 25 | * Small: Just one Python file, requires only stdlib. You can use just 26 | the pep8.py file for this purpose. 27 | 28 | * Comes with a comprehensive test suite. 29 | 30 | Installation 31 | ------------ 32 | 33 | You can install, upgrade, uninstall pep8.py with these commands:: 34 | 35 | $ pip install pep8 36 | $ pip install --upgrade pep8 37 | $ pip uninstall pep8 38 | 39 | There's also a package for Debian/Ubuntu, but it's not always the 40 | latest version. 41 | 42 | Example usage and output 43 | ------------------------ 44 | 45 | :: 46 | 47 | $ pep8 --first optparse.py 48 | optparse.py:69:11: E401 multiple imports on one line 49 | optparse.py:77:1: E302 expected 2 blank lines, found 1 50 | optparse.py:88:5: E301 expected 1 blank line, found 0 51 | optparse.py:222:34: W602 deprecated form of raising exception 52 | optparse.py:347:31: E211 whitespace before '(' 53 | optparse.py:357:17: E201 whitespace after '{' 54 | optparse.py:472:29: E221 multiple spaces before operator 55 | optparse.py:544:21: W601 .has_key() is deprecated, use 'in' 56 | 57 | You can also make pep8.py show the source code for each error, and 58 | even the relevant text from PEP 8:: 59 | 60 | $ pep8 --show-source --show-pep8 testsuite/E40.py 61 | testsuite/E40.py:2:10: E401 multiple imports on one line 62 | import os, sys 63 | ^ 64 | Imports should usually be on separate lines. 65 | 66 | Okay: import os\nimport sys 67 | E401: import sys, os 68 | 69 | 70 | Or you can display how often each error was found:: 71 | 72 | $ pep8 --statistics -qq Python-2.5/Lib 73 | 232 E201 whitespace after '[' 74 | 599 E202 whitespace before ')' 75 | 631 E203 whitespace before ',' 76 | 842 E211 whitespace before '(' 77 | 2531 E221 multiple spaces before operator 78 | 4473 E301 expected 1 blank line, found 0 79 | 4006 E302 expected 2 blank lines, found 1 80 | 165 E303 too many blank lines (4) 81 | 325 E401 multiple imports on one line 82 | 3615 E501 line too long (82 characters) 83 | 612 W601 .has_key() is deprecated, use 'in' 84 | 1188 W602 deprecated form of raising exception 85 | 86 | Links 87 | ----- 88 | 89 | .. image:: https://api.travis-ci.org/jcrocholl/pep8.png?branch=master 90 | :target: https://travis-ci.org/jcrocholl/pep8 91 | :alt: Build status 92 | 93 | * `Read the documentation `_ 94 | 95 | * `Fork me on GitHub `_ 96 | 97 | 98 | Changelog 99 | ========= 100 | 101 | 102 | 1.4.5 (2013-03-06) 103 | ------------------ 104 | 105 | * When no path is specified, do not try to read from stdin. The feature 106 | was added in 1.4.3, but it is not supported on Windows. Use ``-`` 107 | filename argument to read from stdin. This usage is supported 108 | since 1.3.4. (Issue #170) 109 | 110 | * Do not require ``setuptools`` in setup.py. It works around an issue 111 | with ``pip`` and Python 3. (Issue #172) 112 | 113 | * Add ``__pycache__`` to the ignore list. 114 | 115 | * Change misleading message for E251. (Issue #171) 116 | 117 | * Do not report false E302 when the source file has a coding cookie or a 118 | comment on the first line. (Issue #174) 119 | 120 | * Reorganize the tests and add tests for the API and for the command line 121 | usage and options. (Issues #161 and #162) 122 | 123 | * Ignore all checks which are not explicitly selected when ``select`` is 124 | passed to the ``StyleGuide`` constructor. 125 | 126 | 127 | 1.4.4 (2013-02-24) 128 | ------------------ 129 | 130 | * Report E227 or E228 instead of E225 for whitespace around bitwise, shift 131 | or modulo operators. (Issue #166) 132 | 133 | * Change the message for E226 to make clear that it is about arithmetic 134 | operators. 135 | 136 | * Fix a false positive E128 for continuation line indentation with tabs. 137 | 138 | * Fix regression with the ``--diff`` option. (Issue #169) 139 | 140 | * Fix the ``TestReport`` class to print the unexpected warnings and 141 | errors. 142 | 143 | 144 | 1.4.3 (2013-02-22) 145 | ------------------ 146 | 147 | * Hide the ``--doctest`` and ``--testsuite`` options when installed. 148 | 149 | * Fix crash with AST checkers when the syntax is invalid. (Issue #160) 150 | 151 | * Read from standard input if no path is specified. 152 | 153 | * Initiate a graceful shutdown on ``Control+C``. 154 | 155 | * Allow to change the ``checker_class`` for the ``StyleGuide``. 156 | 157 | 158 | 1.4.2 (2013-02-10) 159 | ------------------ 160 | 161 | * Support AST checkers provided by third-party applications. 162 | 163 | * Register new checkers with ``register_check(func_or_cls, codes)``. 164 | 165 | * Allow to construct a ``StyleGuide`` with a custom parser. 166 | 167 | * Accept visual indentation without parenthesis after the ``if`` 168 | statement. (Issue #151) 169 | 170 | * Fix UnboundLocalError when using ``# noqa`` with continued lines. 171 | (Issue #158) 172 | 173 | * Re-order the lines for the ``StandardReport``. 174 | 175 | * Expand tabs when checking E12 continuation lines. (Issue #155) 176 | 177 | * Refactor the testing class ``TestReport`` and the specific test 178 | functions into a separate test module. 179 | 180 | 181 | 1.4.1 (2013-01-18) 182 | ------------------ 183 | 184 | * Allow sphinx.ext.autodoc syntax for comments. (Issue #110) 185 | 186 | * Report E703 instead of E702 for the trailing semicolon. (Issue #117) 187 | 188 | * Honor ``# noqa`` in addition to ``# nopep8``. (Issue #149) 189 | 190 | * Expose the ``OptionParser`` factory for better extensibility. 191 | 192 | 193 | 1.4 (2012-12-22) 194 | ---------------- 195 | 196 | * Report E226 instead of E225 for optional whitespace around common 197 | operators (``*``, ``**``, ``/``, ``+`` and ``-``). This new error 198 | code is ignored in the default configuration because PEP 8 recommends 199 | to "use your own judgement". (Issue #96) 200 | 201 | * Lines with a ``# nopep8`` at the end will not issue errors on line 202 | length E501 or continuation line indentation E12*. (Issue #27) 203 | 204 | * Fix AssertionError when the source file contains an invalid line 205 | ending ``"\r\r\n"``. (Issue #119) 206 | 207 | * Read the ``[pep8]`` section of ``tox.ini`` or ``setup.cfg`` if present. 208 | (Issue #93 and #141) 209 | 210 | * Add the Sphinx-based documentation, and publish it 211 | on http://pep8.readthedocs.org/. (Issue #105) 212 | 213 | 214 | 1.3.4 (2012-12-18) 215 | ------------------ 216 | 217 | * Fix false positive E124 and E128 with comments. (Issue #100) 218 | 219 | * Fix error on stdin when running with bpython. (Issue #101) 220 | 221 | * Fix false positive E401. (Issue #104) 222 | 223 | * Report E231 for nested dictionary in list. (Issue #142) 224 | 225 | * Catch E271 at the beginning of the line. (Issue #133) 226 | 227 | * Fix false positive E126 for multi-line comments. (Issue #138) 228 | 229 | * Fix false positive E221 when operator is preceded by a comma. (Issue #135) 230 | 231 | * Fix ``--diff`` failing on one-line hunk. (Issue #137) 232 | 233 | * Fix the ``--exclude`` switch for directory paths. (Issue #111) 234 | 235 | * Use ``-`` filename to read from standard input. (Issue #128) 236 | 237 | 238 | 1.3.3 (2012-06-27) 239 | ------------------ 240 | 241 | * Fix regression with continuation line checker. (Issue #98) 242 | 243 | 244 | 1.3.2 (2012-06-26) 245 | ------------------ 246 | 247 | * Revert to the previous behaviour for ``--show-pep8``: 248 | do not imply ``--first``. (Issue #89) 249 | 250 | * Add E902 for IO errors. (Issue #87) 251 | 252 | * Fix false positive for E121, and missed E124. (Issue #92) 253 | 254 | * Set a sensible default path for config file on Windows. (Issue #95) 255 | 256 | * Allow ``verbose`` in the configuration file. (Issue #91) 257 | 258 | * Show the enforced ``max-line-length`` in the error message. (Issue #86) 259 | 260 | 261 | 1.3.1 (2012-06-18) 262 | ------------------ 263 | 264 | * Explain which configuration options are expected. Accept and recommend 265 | the options names with hyphen instead of underscore. (Issue #82) 266 | 267 | * Do not read the user configuration when used as a module 268 | (except if ``config_file=True`` is passed to the ``StyleGuide`` constructor). 269 | 270 | * Fix wrong or missing cases for the E12 series. 271 | 272 | * Fix cases where E122 was missed. (Issue #81) 273 | 274 | 275 | 1.3 (2012-06-15) 276 | ---------------- 277 | 278 | .. warning:: 279 | The internal API is backwards incompatible. 280 | 281 | * Remove global configuration and refactor the library around 282 | a ``StyleGuide`` class; add the ability to configure various 283 | reporters. (Issue #35 and #66) 284 | 285 | * Read user configuration from ``~/.config/pep8`` 286 | and local configuration from ``./.pep8``. (Issue #22) 287 | 288 | * Fix E502 for backslash embedded in multi-line string. (Issue #68) 289 | 290 | * Fix E225 for Python 3 iterable unpacking (PEP 3132). (Issue #72) 291 | 292 | * Enable the new checkers from the E12 series in the default 293 | configuration. 294 | 295 | * Suggest less error-prone alternatives for E712 errors. 296 | 297 | * Rewrite checkers to run faster (E22, E251, E27). 298 | 299 | * Fixed a crash when parsed code is invalid (too many 300 | closing brackets). 301 | 302 | * Fix E127 and E128 for continuation line indentation. (Issue #74) 303 | 304 | * New option ``--format`` to customize the error format. (Issue #23) 305 | 306 | * New option ``--diff`` to check only modified code. The unified 307 | diff is read from STDIN. Example: ``hg diff | pep8 --diff`` 308 | (Issue #39) 309 | 310 | * Correctly report the count of failures and set the exit code to 1 311 | when the ``--doctest`` or the ``--testsuite`` fails. 312 | 313 | * Correctly detect the encoding in Python 3. (Issue #69) 314 | 315 | * Drop support for Python 2.3, 2.4 and 3.0. (Issue #78) 316 | 317 | 318 | 1.2 (2012-06-01) 319 | ---------------- 320 | 321 | * Add E121 through E128 for continuation line indentation. These 322 | checks are disabled by default. If you want to force all checks, 323 | use switch ``--select=E,W``. Patch by Sam Vilain. (Issue #64) 324 | 325 | * Add E721 for direct type comparisons. (Issue #47) 326 | 327 | * Add E711 and E712 for comparisons to singletons. (Issue #46) 328 | 329 | * Fix spurious E225 and E701 for function annotations. (Issue #29) 330 | 331 | * Add E502 for explicit line join between brackets. 332 | 333 | * Fix E901 when printing source with ``--show-source``. 334 | 335 | * Report all errors for each checker, instead of reporting only the 336 | first occurence for each line. 337 | 338 | * Option ``--show-pep8`` implies ``--first``. 339 | 340 | 341 | 1.1 (2012-05-24) 342 | ---------------- 343 | 344 | * Add E901 for syntax errors. (Issues #63 and #30) 345 | 346 | * Add E271, E272, E273 and E274 for extraneous whitespace around 347 | keywords. (Issue #57) 348 | 349 | * Add ``tox.ini`` configuration file for tests. (Issue #61) 350 | 351 | * Add ``.travis.yml`` configuration file for continuous integration. 352 | (Issue #62) 353 | 354 | 355 | 1.0.1 (2012-04-06) 356 | ------------------ 357 | 358 | * Fix inconsistent version numbers. 359 | 360 | 361 | 1.0 (2012-04-04) 362 | ---------------- 363 | 364 | * Fix W602 ``raise`` to handle multi-char names. (Issue #53) 365 | 366 | 367 | 0.7.0 (2012-03-26) 368 | ------------------ 369 | 370 | * Now ``--first`` prints only the first occurence of each error. 371 | The ``--repeat`` flag becomes obsolete because it is the default 372 | behaviour. (Issue #6) 373 | 374 | * Allow to specify ``--max-line-length``. (Issue #36) 375 | 376 | * Make the shebang more flexible. (Issue #26) 377 | 378 | * Add testsuite to the bundle. (Issue #25) 379 | 380 | * Fixes for Jython. (Issue #49) 381 | 382 | * Add PyPI classifiers. (Issue #43) 383 | 384 | * Fix the ``--exclude`` option. (Issue #48) 385 | 386 | * Fix W602, accept ``raise`` with 3 arguments. (Issue #34) 387 | 388 | * Correctly select all tests if ``DEFAULT_IGNORE == ''``. 389 | 390 | 391 | 0.6.1 (2010-10-03) 392 | ------------------ 393 | 394 | * Fix inconsistent version numbers. (Issue #21) 395 | 396 | 397 | 0.6.0 (2010-09-19) 398 | ------------------ 399 | 400 | * Test suite reorganized and enhanced in order to check more failures 401 | with fewer test files. Read the ``run_tests`` docstring for details 402 | about the syntax. 403 | 404 | * Fix E225: accept ``print >>sys.stderr, "..."`` syntax. 405 | 406 | * Fix E501 for lines containing multibyte encoded characters. (Issue #7) 407 | 408 | * Fix E221, E222, E223, E224 not detected in some cases. (Issue #16) 409 | 410 | * Fix E211 to reject ``v = dic['a'] ['b']``. (Issue #17) 411 | 412 | * Exit code is always 1 if any error or warning is found. (Issue #10) 413 | 414 | * ``--ignore`` checks are now really ignored, especially in 415 | conjunction with ``--count``. (Issue #8) 416 | 417 | * Blank lines with spaces yield W293 instead of W291: some developers 418 | want to ignore this warning and indent the blank lines to paste their 419 | code easily in the Python interpreter. 420 | 421 | * Fix E301: do not require a blank line before an indented block. (Issue #14) 422 | 423 | * Fix E203 to accept NumPy slice notation ``a[0, :]``. (Issue #13) 424 | 425 | * Performance improvements. 426 | 427 | * Fix decoding and checking non-UTF8 files in Python 3. 428 | 429 | * Fix E225: reject ``True+False`` when running on Python 3. 430 | 431 | * Fix an exception when the line starts with an operator. 432 | 433 | * Allow a new line before closing ``)``, ``}`` or ``]``. (Issue #5) 434 | 435 | 436 | 0.5.0 (2010-02-17) 437 | ------------------ 438 | 439 | * Changed the ``--count`` switch to print to sys.stderr and set 440 | exit code to 1 if any error or warning is found. 441 | 442 | * E241 and E242 are removed from the standard checks. If you want to 443 | include these checks, use switch ``--select=E,W``. (Issue #4) 444 | 445 | * Blank line is not mandatory before the first class method or nested 446 | function definition, even if there's a docstring. (Issue #1) 447 | 448 | * Add the switch ``--version``. 449 | 450 | * Fix decoding errors with Python 3. (Issue #13 [1]_) 451 | 452 | * Add ``--select`` option which is mirror of ``--ignore``. 453 | 454 | * Add checks E261 and E262 for spaces before inline comments. 455 | 456 | * New check W604 warns about deprecated usage of backticks. 457 | 458 | * New check W603 warns about the deprecated operator ``<>``. 459 | 460 | * Performance improvement, due to rewriting of E225. 461 | 462 | * E225 now accepts: 463 | 464 | - no whitespace after unary operator or similar. (Issue #9 [1]_) 465 | 466 | - lambda function with argument unpacking or keyword defaults. 467 | 468 | * Reserve "2 blank lines" for module-level logical blocks. (E303) 469 | 470 | * Allow multi-line comments. (E302, issue #10 [1]_) 471 | 472 | 473 | 0.4.2 (2009-10-22) 474 | ------------------ 475 | 476 | * Decorators on classes and class methods are OK now. 477 | 478 | 479 | 0.4 (2009-10-20) 480 | ---------------- 481 | 482 | * Support for all versions of Python from 2.3 to 3.1. 483 | 484 | * New and greatly expanded self tests. 485 | 486 | * Added ``--count`` option to print the total number of errors and warnings. 487 | 488 | * Further improvements to the handling of comments and blank lines. 489 | (Issue #1 [1]_ and others changes.) 490 | 491 | * Check all py files in directory when passed a directory (Issue 492 | #2 [1]_). This also prevents an exception when traversing directories 493 | with non ``*.py`` files. 494 | 495 | * E231 should allow commas to be followed by ``)``. (Issue #3 [1]_) 496 | 497 | * Spaces are no longer required around the equals sign for keyword 498 | arguments or default parameter values. 499 | 500 | 501 | .. [1] These issues refer to the `previous issue tracker`__. 502 | .. __: http://github.com/cburroughs/pep8.py/issues 503 | 504 | 505 | 0.3.1 (2009-09-14) 506 | ------------------ 507 | 508 | * Fixes for comments: do not count them when checking for blank lines between 509 | items. 510 | 511 | * Added setup.py for pypi upload and easy_installability. 512 | 513 | 514 | 0.2 (2007-10-16) 515 | ---------------- 516 | 517 | * Loads of fixes and improvements. 518 | 519 | 520 | 0.1 (2006-10-01) 521 | ---------------- 522 | 523 | * First release. 524 | 525 | Keywords: pep8 526 | Platform: UNKNOWN 527 | Classifier: Development Status :: 5 - Production/Stable 528 | Classifier: Environment :: Console 529 | Classifier: Intended Audience :: Developers 530 | Classifier: License :: OSI Approved :: MIT License 531 | Classifier: Operating System :: OS Independent 532 | Classifier: Programming Language :: Python 533 | Classifier: Programming Language :: Python :: 2 534 | Classifier: Programming Language :: Python :: 3 535 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 536 | --------------------------------------------------------------------------------