changeset 2:37560eebb5ce draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_ncbi_taxonomy_sqlite/ commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
author iuc
date Sun, 22 Nov 2020 12:52:03 +0000
parents 54a0869d0051
children f9650b178bfd
files data_manager/data_manager_ncbi_taxonomy_sqlite.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/data_manager/data_manager_ncbi_taxonomy_sqlite.py	Wed Jul 22 11:54:58 2020 -0400
+++ b/data_manager/data_manager_ncbi_taxonomy_sqlite.py	Sun Nov 22 12:52:03 2020 +0000
@@ -55,7 +55,8 @@
     )
     args = parser.parse_args()
 
-    config = json.load(open(args.galaxy_datamanager_filename))
+    with open(args.galaxy_datamanager_filename) as fh:
+        config = json.load(fh)
     output_directory = config.get("output_data", [{}])[0].get("extra_files_path", None)
     if output_directory is None:
         output_directory = args.output_directory
@@ -64,10 +65,7 @@
         os.makedirs(output_directory)
 
     data_manager_dict = {}
-    data_manager_dict["data_tables"] = json.load(
-        open(args.galaxy_datamanager_filename)
-    ).get("data_tables", {})
-    data_manager_dict["data_tables"] = data_manager_dict.get("data_tables", {})
+    data_manager_dict["data_tables"] = config.get("data_tables", {})
     data_manager_dict["data_tables"][DATA_TABLE_NAME] = data_manager_dict[
         "data_tables"
     ].get(DATA_TABLE_NAME, [])
@@ -75,5 +73,5 @@
     data = build_sqlite(args.taxonomy_dir, output_directory, args.name, args.description)
 
     data_manager_dict["data_tables"][DATA_TABLE_NAME].extend(data)
-    print(json.dumps(data_manager_dict))
-    json.dump(data_manager_dict, open(args.galaxy_datamanager_filename, "w"))
+    with open(args.galaxy_datamanager_filename, "w") as fh:
+        json.dump(data_manager_dict, fh, sort_keys=True)