summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-01-08 10:32:56 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2015-01-08 10:32:56 +0000
commitbad7aca19f7068cb91df848d9387bb80c83ff198 (patch)
treec80e11c1c3bb7d3afc64b4f64255d5d609a35fe0
parent12ec2e4efe868d990076ed8b4e7376c3e808b38e (diff)
downloadimport-bad7aca19f7068cb91df848d9387bb80c83ff198.tar.gz
Pass argv into main of each extension
This allows us to more simply modify argv before running the extensions
-rw-r--r--baserockimport/exts/importer_python_common.py2
-rwxr-xr-xbaserockimport/exts/python.find_deps12
-rwxr-xr-xbaserockimport/exts/python.to_lorry8
3 files changed, 11 insertions, 11 deletions
diff --git a/baserockimport/exts/importer_python_common.py b/baserockimport/exts/importer_python_common.py
index b2e7c51..8327678 100644
--- a/baserockimport/exts/importer_python_common.py
+++ b/baserockimport/exts/importer_python_common.py
@@ -96,4 +96,4 @@ class PythonExtension(ImportExtension):
def process_args(self, _):
import __main__
- __main__.main()
+ __main__.main(sys.argv)
diff --git a/baserockimport/exts/python.find_deps b/baserockimport/exts/python.find_deps
index b9791ef..792405b 100755
--- a/baserockimport/exts/python.find_deps
+++ b/baserockimport/exts/python.find_deps
@@ -327,14 +327,14 @@ def find_runtime_deps(source, name, version=None, use_requirements_file=False):
return runtime_deps
-def main():
- if len(sys.argv) not in [3, 4]:
- print('usage: %s PACKAGE_SOURCE_DIR NAME [VERSION]' % sys.argv[0])
+def main(argv):
+ if len(argv) not in [3, 4]:
+ print('usage: %s PACKAGE_SOURCE_DIR NAME [VERSION]' % argv[0])
sys.exit(1)
- logging.debug('%s: sys.argv[1:]: %s' % (sys.argv[0], sys.argv[1:]))
- source, name = sys.argv[1:3]
- version = sys.argv[3] if len(sys.argv) == 4 else None
+ logging.debug('%s: argv[1:]: %s' % (argv[0], argv[1:]))
+ source, name = argv[1:3]
+ version = argv[3] if len(argv) == 4 else None
client = xmlrpclib.ServerProxy(PYPI_URL)
new_name = name_or_closest(client, name)
diff --git a/baserockimport/exts/python.to_lorry b/baserockimport/exts/python.to_lorry
index accc9dc..f54e341 100755
--- a/baserockimport/exts/python.to_lorry
+++ b/baserockimport/exts/python.to_lorry
@@ -187,17 +187,17 @@ def str_repo_lorry(package_name, repo_type, url):
return json.dumps({name: {'type': repo_type, 'url': url}},
indent=4, sort_keys=True)
-def main():
- if len(sys.argv) != 2:
+def main(argv):
+ if len(argv) != 2:
# TODO explain the format of python requirements
# warn the user that they probably want to quote their arg
# > < will be interpreted as redirection by the shell
- print('usage: %s requirement' % sys.argv[0], file=sys.stderr)
+ print('usage: %s requirement' % argv[0], file=sys.stderr)
sys.exit(1)
client = xmlrpclib.ServerProxy(PYPI_URL)
- req = pkg_resources.parse_requirements(sys.argv[1]).next()
+ req = pkg_resources.parse_requirements(argv[1]).next()
new_proj_name = name_or_closest(client, req.project_name)