diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2012-09-05 21:10:29 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-09-05 21:10:29 -0400 |
commit | 932ea7cc2b1ef4eba5d8c1ee46c64cce529e3207 (patch) | |
tree | 1e720e0467f45df1864ab97b89d09da1c0a194f5 | |
parent | 7796c53510033888e2602454d52ab20df4919ee2 (diff) | |
download | external_python_setuptools-932ea7cc2b1ef4eba5d8c1ee46c64cce529e3207.tar.gz external_python_setuptools-932ea7cc2b1ef4eba5d8c1ee46c64cce529e3207.tar.bz2 external_python_setuptools-932ea7cc2b1ef4eba5d8c1ee46c64cce529e3207.zip |
Extract argument parsing as a separate function
--HG--
branch : distribute
extra : rebase_source : d2143d4dd1332558689b6b90770c013bce3a7e37
-rw-r--r-- | distribute_setup.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/distribute_setup.py b/distribute_setup.py index eca355ce..95ba23c5 100644 --- a/distribute_setup.py +++ b/distribute_setup.py @@ -20,6 +20,7 @@ import fnmatch import tempfile import tarfile import optparse + from distutils import log try: @@ -496,19 +497,22 @@ def _extractall(self, path=".", members=None): self._dbg(1, "tarfile: %s" % e) -def _build_install_args(user_install): +def _build_install_args(options): + """ + Build the arguments to 'python setup.py install' on the distribute package + """ install_args = [] - if user_install: + if options.user_install: if sys.version_info < (2, 6): log.warn("--user requires Python 2.6 or later") raise SystemExit(1) - else: - install_args.append('--user') + install_args.append('--user') return install_args - -def main(version=DEFAULT_VERSION): - """Install or upgrade setuptools and EasyInstall""" +def _parse_args(): + """ + Parse the command line for options + """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, @@ -518,9 +522,14 @@ def main(version=DEFAULT_VERSION): default=DEFAULT_URL, help='alternative URL from where to download the distribute package') options, args = parser.parse_args() - tarball = download_setuptools(download_base=options.download_base) - _install(tarball, _build_install_args(options.user_install)) + # positional arguments are ignored + return options +def main(version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + options = _parse_args() + tarball = download_setuptools(download_base=options.download_base) + _install(tarball, _build_install_args(options)) if __name__ == '__main__': main() |