Skip to content

Commit

Permalink
Refactor complex method for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Oct 18, 2024
1 parent b131e0d commit 767084e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/galaxy/tools/parameters/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def is_batch(value):
ExpandedT = Tuple[List[ToolStateJobInstanceT], Optional[matching.MatchingCollections]]


def expand_flat_parameters_to_nested(incoming_copy: ToolRequestT) -> Dict[str, Any]:
nested_dict: Dict[str, Any] = {}
for incoming_key, incoming_value in incoming_copy.items():
if not incoming_key.startswith("__"):
process_key(incoming_key, incoming_value=incoming_value, d=nested_dict)
return nested_dict


def expand_meta_parameters(trans, tool, incoming: ToolRequestT) -> ExpandedT:
"""
Take in a dictionary of raw incoming parameters and expand to a list
Expand All @@ -176,11 +184,7 @@ def expand_meta_parameters(trans, tool, incoming: ToolRequestT) -> ExpandedT:
# order matters, so the following reorders incoming
# according to tool.inputs (which is ordered).
incoming_copy = incoming.copy()
nested_dict: Dict[str, Any] = {}
for incoming_key, incoming_value in incoming_copy.items():
if not incoming_key.startswith("__"):
process_key(incoming_key, incoming_value=incoming_value, d=nested_dict)

nested_dict = expand_flat_parameters_to_nested(incoming_copy)
reordered_incoming = {}

def visitor(input, value, prefix, prefixed_name, prefixed_label, error, **kwargs):
Expand Down

0 comments on commit 767084e

Please sign in to comment.