diff alveo_item_list_importer.py @ 14:a38315ecf593 draft

planemo upload for repository https://github.com/Alveo/alveo-galaxy-tools commit b5b26e9118f2ad8af109d606746b39a5588f0511-dirty
author stevecassidy
date Wed, 01 Nov 2017 01:18:15 -0400
parents 56fda3d161f0
children
line wrap: on
line diff
--- a/alveo_item_list_importer.py	Wed Feb 01 22:34:24 2017 -0500
+++ b/alveo_item_list_importer.py	Wed Nov 01 01:18:15 2017 -0400
@@ -1,22 +1,15 @@
 from __future__ import print_function
-import json
 import argparse
-import pyalveo
 import sys
-
-API_URL = 'https://app.alveo.edu.au' # TODO: export constants to a separate module
+from util import get_item_lists
 
 
 def parser():
-    parser = argparse.ArgumentParser(description="Retrieves Alveo Item Lists")
-    parser.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key")
-    parser.add_argument('--output', required=True, action="store", type=str, help="Path to output file")
-    return parser.parse_args()
+    p = argparse.ArgumentParser(description="Retrieves Alveo Item Lists")
+    p.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key")
+    p.add_argument('--output', required=True, action="store", type=str, help="Path to output file")
+    return p.parse_args()
 
-# TODO: export common function to helper module
-def get_item_lists(api_key):
-    client = pyalveo.Client(api_key=api_key, api_url=API_URL, use_cache=False)
-    return client.get_item_lists()
 
 def write_table(item_lists, filename):
     with open(filename, 'w') as outfile:
@@ -24,6 +17,7 @@
             for item_list in list_set:
                 outfile.write("%s (%d)\t%s\n" % (item_list['name'], item_list['num_items'], item_list['item_list_url']))
 
+
 def main():
     args = parser()
     try: