From e9dc68f0a61caeda26f5183d3db9e3ec4944d030 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 23 Feb 2013 14:09:53 -0600 Subject: [PATCH] Add ability to pass sub-blocks of XML to macros and corresponding ability to render those (via the new tag) from macros. --- lib/galaxy/tools/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index db32ab835bc..6ecb0006535 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -726,7 +726,16 @@ class ToolBox( object ): parent_map = dict((c, p) for p in element.getiterator() for c in p) for expand_el in element.findall('.//expand'): macro_name = expand_el.get('macro') - macro_def = macros[macro_name] + macro_def = deepcopy(macros[macro_name]) # deepcopy needed? + + yield_els = [yield_el for macro_def_el in macro_def for yield_el in macro_def_el.findall('.//yield')] + + expand_el_children = expand_el.getchildren() + macro_def_parent_map = \ + dict((c, p) for macro_def_el in macro_def for p in macro_def_el.getiterator() for c in p) + + for yield_el in yield_els: + self._xml_replace(yield_el, expand_el_children, macro_def_parent_map) # Recursively expand contained macros. self._expand_macros(macro_def, macros)