Skip to content

Commit

Permalink
fix looks_like_yaml_or_cwl_with_class
Browse files Browse the repository at this point in the history
the string `class: ...` might appear on the first line
hence the leading `\n` was wrong

I guess its better to use `^` and `$` and add the MULTILINE flag
  • Loading branch information
bernt-matthias committed Jan 29, 2023
1 parent bff1a04 commit 767891f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/tool_util/loader_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def looks_like_a_data_manager_xml(path):

def as_dict_if_looks_like_yaml_or_cwl_with_class(path, classes):
"""
get a dict from yaml file if it contains `class: CLASS`, where CLASS is
get a dict from yaml file if it contains a line `class: CLASS`, where CLASS is
any string given in CLASSES. must appear in the first 5k and also load
properly in total.
"""
Expand All @@ -199,7 +199,7 @@ def as_dict_if_looks_like_yaml_or_cwl_with_class(path, classes):
start_contents = f.read(5 * 1024)
except UnicodeDecodeError:
return False, None
if re.search(rf"\nclass:\s+({'|'.join(classes)})\s*\n", start_contents) is None:
if re.search(rf"^class:\s+{'|'.join(classes)}\s*$", start_contents, re.MULTILINE) is None:
return False, None

with open(path) as f:
Expand Down

0 comments on commit 767891f

Please sign in to comment.