From 9552a9ed45b425fb6e865a184fa021fcfbb70c06 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Wed, 9 May 2018 15:41:31 +0200 Subject: [PATCH] added extract_attr to return any attribute --- src/python/PyBis/pybis/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/python/PyBis/pybis/utils.py b/src/python/PyBis/pybis/utils.py index 02cf3d7401e..6f78cf181e2 100644 --- a/src/python/PyBis/pybis/utils.py +++ b/src/python/PyBis/pybis/utils.py @@ -18,7 +18,7 @@ def parse_jackson(input_json): interesting=['tags', 'registrator', 'modifier', 'owner', 'type', 'parents', 'children', 'containers', 'properties', 'experiment', 'sample', 'project', 'space', 'propertyType', 'entityType', 'propertyType', 'propertyAssignment', - 'externalDms', 'roleAssignments', 'user', 'authorizationGroup' + 'externalDms', 'roleAssignments', 'user', 'authorizationGroup', 'vocabulary' ] found = {} def build_cache(graph): @@ -152,6 +152,15 @@ def extract_deletion(obj): return del_objs +def extract_attr(attr): + def attr(obj): + if isinstance(obj, dict): + return obj.get(attr, '') + else: + return str(obj) + return attr + + def extract_identifier(ident): if not isinstance(ident, dict): return str(ident) -- GitLab