Skip to content

Commit

Permalink
Fixing bugs for non annotated tools
Browse files Browse the repository at this point in the history
  • Loading branch information
r78v10a07 committed Jul 29, 2020
1 parent 3c0a8eb commit 356e7ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def readme():
'': 'src',
},
data_files=[('', ['README.md'])],
version='0.0.3',
version='0.0.4',
description='Tools to synchronize bioconda packages and versions with Biocontainer images',
long_description=readme(),
long_description_content_type='text/markdown',
Expand Down
10 changes: 7 additions & 3 deletions src/bioconda2biocontainer/biocontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def filter_by_container_registry(container_type, registry_host, i):
container_type == i['image_type']:
return True
if not registry_host and container_type and \
'image_type' in i and \
container_type == i['image_type']:
return True
if registry_host and not container_type and \
Expand All @@ -43,8 +44,8 @@ def filter_by_container_registry(container_type, registry_host, i):
return False


def find_latest_image(package_name, package_version, all, sort_by_size,
sort_by_download, container_type, registry_host):
def find_latest_image(package_name, package_version, all=False, sort_by_size=False,
sort_by_download=False, container_type=None, registry_host=None):
data = request_url_to_dict('{0}/{1}/versions/{1}-{2}'.format(
base_url, package_name, package_version))
if type(data) == dict or type(data) == list:
Expand All @@ -63,5 +64,8 @@ def find_latest_image(package_name, package_version, all, sort_by_size,
versions = sorted(versions, key=lambda i: i['updated'], reverse=True)
if all:
return versions
return versions[0]
if versions:
return versions[0]
else:
return None
return data
17 changes: 13 additions & 4 deletions src/bioconda2biocontainer/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,23 @@ def find_latest_image_main(package_name, package_version, json, all, sort_by_siz
elif all:
print('image\tupdated\tsize\tdownloads\tcontainer_type')
for i in images:
image_name = '' if 'image_name' not in i else i['image_name']
image_type = '' if 'image_type' not in i else i['image_type']
updated = '' if 'updated' not in i else i['updated']
size = '' if 'size' not in i else i['size']
downloads = '' if 'downloads' not in i else i['downloads']
print('{}\t{}\t{}\t{}\t{}'.format(
i['image_name'], i['updated'],
i['size'], i['downloads'],
i['image_type']))
image_name, updated,
size, downloads,
image_type))
elif type(images) == dict:
print(images['image_name'])
else:
print('No version {} available for package {}'.format(package_version, package_name))
if container_type:
print('No version {} available for package {} with container type {}'.format(
package_version, package_name, container_type))
else:
print('No version {} available for package {}'.format(package_version, package_name))
print('Searching available versions for package {}'.format(package_name))
find_tool(package_name, False)

Expand Down

0 comments on commit 356e7ea

Please sign in to comment.