diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-10-08 12:33:24 +0100 |
---|---|---|
committer | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2014-11-04 12:40:53 +0000 |
commit | e03ebb6dc1a774efd82e229ec24be42ecb9c27cd (patch) | |
tree | da2ecf8f8bd76c0c5a2f51da6468689672199f0a | |
parent | 027b60b8b2076af0414cfe09eb55f6c23a81e73e (diff) | |
download | import-e03ebb6dc1a774efd82e229ec24be42ecb9c27cd.tar.gz |
Generate tarball lorry
-rwxr-xr-x | import/pip.to_lorry | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/import/pip.to_lorry b/import/pip.to_lorry index 67dca8b..54a4871 100755 --- a/import/pip.to_lorry +++ b/import/pip.to_lorry @@ -53,25 +53,41 @@ def make_lorry(name, url): } }''' % (name, url) +def ask_user(client, xs, fn): + for n, x in enumerate(xs): + print('%s: %s' % (n, fn(x))) + + s = raw_input('--> ') + choice = int(s) if s.isdigit() else xsNone + choice = choice - 1 if choice <= len(xs) else None + + if choice == None: + print("Invalid choice, exiting", file=sys.stderr) + sys.exit(1) + + return choice + def generate_lorry_from_tarball(package_name): client = xmlrpclib.ServerProxy(PYPI_URL) releases = client.package_releases(package_name) print('releases: ', releases) - for n, release in enumerate(releases): - print('%s: %s (%s)' % (n, client.release_data(package_name, - release)['name'], release)) + def f(release): + return client.release_data(package_name, release)['name'] + ' ' + release - s = raw_input('--> ') - choice = int(s) if s.isdigit() else None - choice = choice if choice < len(releases) else None + release_version = releases[ask_user(client, releases, f) + if len(releases) > 1 else 0] - if choice == None: - print("Invalid choice, exiting", file=sys.stderr) - sys.exit(1) + print("Convert release with version", release_version) + + urls = client.release_urls(package_name, release_version) - release = releases[choice] - print('Will use ', choice) + def g(url): + return url['url'] + + url = urls[ask_user(client, urls, g) if len(urls) > 1 else 0]['url'] + + return make_lorry(package_name, url) if len(sys.argv) != 2: print('usage: %s python_package' % sys.argv[0], file=sys.stderr) @@ -87,9 +103,4 @@ if 'home_page' in info: # lorry this thing print('not implemented yet: lorry from ', info['home_page']) else: - # tarball time - print("not a repo, it's tarball time!") - - # urls or releases??? - - generate_lorry_from_tarball(package_name)
\ No newline at end of file + print(generate_lorry_from_tarball(package_name)) |