Mercurial > repos > iuc > data_manager_qiime_database_downloader
changeset 3:cc18f0f3514c draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_qiime_database_downloader commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author | iuc |
---|---|
date | Sun, 22 Nov 2020 12:53:09 +0000 |
parents | cbe065fbd038 |
children | c4dba88e85ef |
files | data_manager/data_manager_qiime_download.py |
diffstat | 1 files changed, 10 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/data_manager/data_manager_qiime_download.py Mon Oct 23 13:26:03 2017 -0400 +++ b/data_manager/data_manager_qiime_download.py Sun Nov 22 12:53:09 2020 +0000 @@ -69,7 +69,8 @@ to create it if necessary. """ - params = json.loads(open(jsonfile).read()) + with open(jsonfile) as fh: + params = json.load(fh) return (params['param_dict'], params['output_data'][0]['extra_files_path']) @@ -81,7 +82,7 @@ # >>> add_data_table(d,'my_data') # >>> add_data_table_entry(dict(dbkey='hg19',value='human')) # >>> add_data_table_entry(dict(dbkey='mm9',value='mouse')) -# >>> print str(json.dumps(d)) +# >>> print(json.dumps(d)) def create_data_tables_dict(): """Return a dictionary for storing data table information @@ -126,7 +127,8 @@ """ """ try: - ftp.retrbinary("RETR " + filename, open(filename, 'wb').write) + with open(filename, 'wb') as fh: + ftp.retrbinary("RETR " + filename, fh.write) except Exception: print("Error") @@ -180,14 +182,12 @@ """ archive_content_path = "tmp" if ext == "tar.gz" or ext == "tgz": - tar = tarfile.open(filepath) - tar.extractall(path=archive_content_path) - tar.close() + with tarfile.open(filepath) as tar: + tar.extractall(path=archive_content_path) archive_content_path = find_archive_content_path(archive_content_path) elif ext == "zip": - zip_ref = zipfile.ZipFile(filepath, 'r') - zip_ref.extractall(archive_content_path) - zip_ref.close() + with zipfile.ZipFile(filepath, 'r') as zip_ref: + zip_ref.extractall(archive_content_path) archive_content_path = find_archive_content_path(archive_content_path) return archive_content_path @@ -372,7 +372,6 @@ # Write output JSON print("Outputting JSON") - print(str(json.dumps(data_tables))) with open(jsonfile, 'w') as out: - json.dump(data_tables, out) + json.dump(data_tables, out, sort_keys=True) print("Done.")