# HG changeset patch # User iuc # Date 1650013968 0 # Node ID 29c738066906636828aa841e425d91554b5a6f5c # Parent 6e24e79d3d69cbeb1ac491a2a4f79344be275e0d "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_pangolearn commit b12eb7c784ce8e0f9b775530e710e47088711f76" diff -r 6e24e79d3d69 -r 29c738066906 data_manager/pangolearn_dm.py --- a/data_manager/pangolearn_dm.py Tue Apr 05 18:40:07 2022 +0000 +++ b/data_manager/pangolearn_dm.py Fri Apr 15 09:12:48 2022 +0000 @@ -51,7 +51,7 @@ return ret -def download_and_unpack(url, output_directory): +def download_and_unpack(url, output_directory, v3datatree=True): response = requests.get(url) if response.status_code == 200: tmp_filename = url.split("/")[-1] @@ -60,14 +60,47 @@ tmpfile.close() shutil.copy(tmp_filename, "/tmp") tf = tarfile.open(tmp_filename) - pl_path = tf.next().name + pl_path = os.path.join(output_directory, tf.next().name) tf.extractall(output_directory) os.unlink(tmp_filename) + pangolearn_unpacked_dir = os.path.join(pl_path, "pangoLEARN") + if v3datatree: + # pangolin v3 expects a datadir with the entire pangoLEARN + # subfolder in it. + # In addition, it will only use the data if the __init__.py file + # contained within that subfolder declares a __version__ that is + # newer than the version installed with pangolin. + pangolearn_dir = os.path.join( + output_directory, tmp_filename, "pangoLEARN" + ) + os.mkdir(os.path.dirname(pangolearn_dir)) + # rewrite the __init__.py file and make the __version__ string + # appear newer than anything that might come with pangolin by + # prepending a "v" to it. + pangolearn_init = open( + os.path.join(pangolearn_unpacked_dir, "__init__.py") + ).readlines() + with open( + os.path.join(pangolearn_unpacked_dir, "__init__.py"), "w" + ) as o: + for line in pangolearn_init: + if line.startswith('__version__ = "'): + line = line.replace( + '__version__ = "', '__version__ = "v' + ) + o.write(line) + else: + # Earlier versions of pangolin expect a datadir with just the + # contents of the downloaded pangoLEARN subfolder in it and don't + # care about the declared version in __init__.py. + pangolearn_dir = os.path.join( + output_directory, tmp_filename + ) os.rename( - output_directory + "/" + pl_path + "/" + "pangoLEARN", - output_directory + "/" + tmp_filename, + pangolearn_unpacked_dir, + pangolearn_dir ) - shutil.rmtree(output_directory + "/" + pl_path) + shutil.rmtree(pl_path) return tmp_filename else: response.raise_for_status() @@ -132,7 +165,6 @@ if release["tag_name"] not in existing_release_tags ] for release in releases_to_download: - fname = download_and_unpack(release["tarball_url"], output_directory) if args.pangolearn_format_version is not None: version = args.pangolearn_format_version else: @@ -141,6 +173,11 @@ version = '3.0' else: version = '1.0' + fname = download_and_unpack( + release["tarball_url"], + output_directory, + v3datatree=version == '3.0' + ) data_manager_dict["data_tables"][args.datatable_name].append( dict( value=release["tag_name"], diff -r 6e24e79d3d69 -r 29c738066906 data_manager/pangolearn_dm.xml --- a/data_manager/pangolearn_dm.xml Tue Apr 05 18:40:07 2022 +0000 +++ b/data_manager/pangolearn_dm.xml Fri Apr 15 09:12:48 2022 +0000 @@ -1,4 +1,4 @@ - + python requests