# HG changeset patch # User stevecassidy # Date 1479326463 18000 # Node ID 2f4907372748cdf1c5f453b1bcc8a46a9d192d86 # Parent 4d84952bdcb8d2a95c1d39dd64285b32040a8c31 planemo upload commit 7b5663b41b2dc11f9e375b8f386bc31855800bcf-dirty diff -r 4d84952bdcb8 -r 2f4907372748 alveo_api_key.xml --- a/alveo_api_key.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_api_key.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,4 +1,4 @@ - + for use with Alveo tools @@ -14,7 +14,7 @@ - + diff -r 4d84952bdcb8 -r 2f4907372748 alveo_get_item_data.xml --- a/alveo_get_item_data.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_get_item_data.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,4 +1,4 @@ - + Downloads files from the items in an Galaxy list of items @@ -10,8 +10,8 @@ - - + + diff -r 4d84952bdcb8 -r 2f4907372748 alveo_get_item_list.xml --- a/alveo_get_item_list.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_get_item_list.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,4 +1,4 @@ - + Retrieves Item URLs from an Alveo Item List @@ -10,7 +10,7 @@ - + @@ -25,7 +25,7 @@ - + diff -r 4d84952bdcb8 -r 2f4907372748 alveo_get_primary_text.py --- a/alveo_get_primary_text.py Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_get_primary_text.py Wed Nov 16 15:01:03 2016 -0500 @@ -5,13 +5,15 @@ import sys import os from fnmatch import fnmatch +import csv + API_URL = 'https://app.alveo.edu.au' # TODO: export constants to a separate module def parser(): parser = argparse.ArgumentParser(description="Downloads documents in an Alveo Item List") parser.add_argument('--api_key', required=True, action="store", type=str, help="Alveo API key") - parser.add_argument('--item_list_url', required=True, action="store", type=str, help="Item List to download") + parser.add_argument('--item_list', required=True, action="store", type=str, help="File containing list of item URLs") parser.add_argument('--output_path', required=True, action="store", type=str, help="Path to output file") return parser.parse_args() @@ -28,6 +30,7 @@ fname = FNPAT % {'designation': fname, 'ext': ext} return fname + import pprint def download_documents(item_list, output_path): """ @@ -56,13 +59,31 @@ return downloaded +def read_item_list(filename, client): + """Read an item list from a file + which should be a tabular formatted file + with one column header ItemURL. + Return an instance of ItemGroup""" + + with open(filename) as fd: + csvreader = csv.DictReader(fd, dialect='excel-tab') + if 'ItemURL' not in csvreader.fieldnames: + return None + itemurls = [] + for row in csvreader: + itemurls.append(row['ItemURL']) + + itemlist = pyalveo.ItemGroup(itemurls, client) + + return itemlist + def main(): args = parser() try: api_key = open(args.api_key, 'r').read().strip() - item_list = get_item_list(api_key, args.item_list_url) + client = pyalveo.Client(api_url=API_URL, api_key=api_key, use_cache=False) + item_list = read_item_list(args.item_list, client) downloaded = download_documents(item_list, args.output_path) - # write out a list of downloaded files as a result? except pyalveo.APIError as e: print("ERROR: " + str(e), file=sys.stderr) sys.exit(1) diff -r 4d84952bdcb8 -r 2f4907372748 alveo_get_primary_text.xml --- a/alveo_get_primary_text.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_get_primary_text.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,4 +1,4 @@ - + Downloads primary text from the items in an Alveo Item List @@ -10,15 +10,8 @@ - - - - - - - - - + + diff -r 4d84952bdcb8 -r 2f4907372748 alveo_item_list_importer.xml --- a/alveo_item_list_importer.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/alveo_item_list_importer.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,5 +1,5 @@ - - Retrieves item list metadata. + + Retrieves the list of Item List URLs from Alveo. pyalveo @@ -11,7 +11,7 @@ - + @@ -20,8 +20,9 @@ - Import Item Lists from Alveo. This imports the lists, but does not download the individual items. - That task is performed by the *Get Files from Alveo* tool. + Import Item Lists from Alveo so that you can pass an item list + to a subsequent tool. This only retrieves the list of item list names + and URLs that are available to a user, not the item lists themselves. diff -r 4d84952bdcb8 -r 2f4907372748 austalk-select-hVd-words.xml --- a/austalk-select-hVd-words.xml Wed Oct 12 22:08:02 2016 -0400 +++ b/austalk-select-hVd-words.xml Wed Nov 16 15:01:03 2016 -0500 @@ -1,4 +1,4 @@ - + for a single speaker @@ -10,8 +10,8 @@ - - + + @@ -22,7 +22,7 @@ - +