Skip to content

Commit

Permalink
FF-320 #comment Added connection for user specific items to be fetched
Browse files Browse the repository at this point in the history
  • Loading branch information
KorayKirli committed Nov 1, 2016
1 parent d38eb0d commit d5989d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions wranglertools/fdnDCIC.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,13 @@ def switch_fields(list_names, sheet):
"Publication": "publication", "Vendor": "vendor"}


def fetch_all_items(sheet, field_list):
def fetch_all_items(sheet, field_list, connection):
"""For a given sheet, get all released items"""
all_items = []
if sheet in fetch_items.keys():
obj = fetch_items[sheet]
HEADERS = {'accept': 'application/json'}
URL = "http://data.4dnucleome.org/search/?type={}&frame=object&limit=all&format=json".format(obj)
response = requests.get(URL, headers=HEADERS)
items_list = response.json()['@graph']
obj_id = "search/?type=" + fetch_items[sheet]
get_FDN(obj_id, connection)
items_list = get_FDN(obj_id, connection)['@graph']
for item in items_list:
item_info = []
for field in field_list:
Expand All @@ -254,7 +252,7 @@ def fetch_all_items(sheet, field_list):
return


def order_FDN(input_xls):
def order_FDN(input_xls, connection):
"""Order and filter created xls file."""
ReadFile = input_xls
OutputFile = input_xls[:-4]+'_ordered.xls'
Expand Down Expand Up @@ -286,7 +284,7 @@ def order_FDN(input_xls):
# reorder some items based on reorder list
useful = switch_fields(useful, sheet)
# fetch all items for common objects
all_items = fetch_all_items(sheet, useful)
all_items = fetch_all_items(sheet, useful, connection)
# create a new sheet and write the data
new_sheet = book_w.add_sheet(sheet)
for write_row_index, write_item in enumerate(useful):
Expand Down
2 changes: 1 addition & 1 deletion wranglertools/get_field_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def main():
file_name = args.outfile
create_xls(fields, file_name)
if args.order:
fdnDCIC.order_FDN(file_name)
fdnDCIC.order_FDN(file_name, connection)

if __name__ == '__main__':
main()

0 comments on commit d5989d6

Please sign in to comment.