changeset 16:3eabece82abb draft

Uploaded 20170601
author fabio
date Thu, 01 Jun 2017 13:07:22 -0400
parents 78bd202e8687
children 1224f3d9b5c7
files ._gdcwebapp.xml ._json_data_source_mod.py gdcwebapp.xml json_data_source_mod.py
diffstat 4 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
Binary file ._gdcwebapp.xml has changed
Binary file ._json_data_source_mod.py has changed
--- a/gdcwebapp.xml	Tue May 30 15:56:33 2017 -0400
+++ b/gdcwebapp.xml	Thu Jun 01 13:07:22 2017 -0400
@@ -21,7 +21,7 @@
     <outputs>
         <data name="output1" format="auto" label="${tool.name} Output Data" hidden="True" />
         <collection name="list_output" type="list:list" label="${tool.name} Output Collection">
-            <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_(?P&lt;identifier_1&gt;[^_]+)" ext="auto" visible="False" directory="tmp" />
+            <discover_datasets pattern="(?P&lt;identifier_0&gt;[^_]+)_(?P&lt;identifier_1&gt;[^_]+)_(?P&lt;ext&gt;[^_]+)_(?P&lt;dbkey&gt;[^_]+)" ext="auto" visible="False" directory="tmp" />
         </collection>
     </outputs>
     <options sanitize="False" refresh="True" />
--- a/json_data_source_mod.py	Tue May 30 15:56:33 2017 -0400
+++ b/json_data_source_mod.py	Thu Jun 01 13:07:22 2017 -0400
@@ -105,7 +105,7 @@
     return "%s\n" % json.dumps( meta_dict )
 
 
-def walk_on_archive(target_output_filename, check_ext, archive_name, appdata_path):
+def walk_on_archive(target_output_filename, check_ext, archive_name, appdata_path, db_key="?"):
     archive_name = archive_name.replace("_", "-").replace(".", "-")
     with tarfile.open( target_output_filename, check_ext ) as tf:
         for entry in tf:
@@ -114,12 +114,12 @@
                 # reserve the underscore for the collection searator
                 filename = os.path.basename( entry.name ).replace("_", "-")
                 extension = splitext( filename )[1]
-                # pattern: (?P&lt;identifier_0&gt;[^_]+)_(?P&lt;identifier_1&gt;[^_]+)
+                # pattern: (?P<identifier_0>[^_]+)_(?P<identifier_1>[^_]+)_(?P<ext>[^_]+)_(?P<dbkey>[^_]+)
                 if (len(extension) > 0):
-                    filename = (filename[0:len(filename)-(len(extension)+1)]).replace(".", "-") + "." + extension
+                    filename = (filename[0:len(filename)-(len(extension)+1)]).replace(".", "-") + "_" + extension
                 else:
                     extension = "auto"
-                filename_with_collection_prefix = archive_name + "_" + filename
+                filename_with_collection_prefix = archive_name + "_" + filename + "_" + db_key
                 target_entry_output_filename = os.path.join(appdata_path, filename_with_collection_prefix)
                 store_file_from_archive( fileobj, target_entry_output_filename )
     return True
@@ -175,7 +175,14 @@
 
     """ the following code handles archives and decompress them in a collection """
     if ( isArchive ):
-        walk_on_archive(target_output_path, check_ext, filename, appdata_path)
+        db_key = "?"
+        archive_metadata = query_item.get( 'metadata', None )
+        if archive_metadata is not None:
+            try:
+                db_key = archive_metadata.get( 'db_key' )
+            except:
+                pass
+        walk_on_archive(target_output_path, check_ext, filename, appdata_path, db_key)
 
     return True