Commit 0ab436be authored by Franziska Koehn's avatar Franziska Koehn
Browse files

method for querying for additional data

parent 1ff0ca2e
......@@ -164,6 +164,28 @@ def disconnect_xnat_server():
get_xnat_server_connection.cache = None
except:
return
def query_for_additional_data(rest, result, host, user, passw):
import re
def subfunc(f):
key = f.group(0).strip("{}")
r = result[key]
return r
ret = re.sub('\{\w+\}', subfunc, rest)
central = get_xnat_server_connection(host=host, user=user, passw=passw)
exp = central.select(ret)
new_fields = exp.xpath("//xnat:field")
new_result = result.copy()
for f in new_fields:
fieldname = f.get("name")
value = exp.xpath("//xnat:field[@name='"+fieldname+"']/child::text()")
new_result[fieldname] = ''.join(value).replace("\n","")
return new_result
def search_for(host, root_element, constraints, search_fields, user, passw):
"""
Does a search for given values. raises xsa -Exceptions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment