Skip to content

Commit

Permalink
fixed the quotes issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Mar 22, 2024
1 parent 8e4ed84 commit 2405949
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/data/examples/examples.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Test_0:
id: CHANGE:001
type: NodeRename
old_value: '''nuclear envelope'''
new_value: '''foo bar'''
old_value: nuclear envelope
new_value: foo bar
about_node: GO:0005635
about_node_representation: curie
command_with_curie: rename GO:0005635 from 'nuclear envelope' to 'foo bar'
Expand All @@ -11,8 +11,8 @@ Test_0:
Test_1:
id: CHANGE:001
type: NodeRename
old_value: '''nucleus'''
new_value: '''bar'''
old_value: nucleus
new_value: bar
about_node: GO:0005634
about_node_representation: curie
command_with_curie: rename GO:0005634 from 'nucleus' to 'bar'
Expand Down
9 changes: 9 additions & 0 deletions src/kgcl_schema/grammar/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,25 @@ def parse_rename(tree, id):
)




def extract(tree, data):
"""Extract node."""
node = get_next(tree.find_data(data))
# Define this list at the module level if it's static and doesn't change per function call
quote_strip_param_substring = ["_label", "name"]
if node is not None:
node_token = next(get_tokens(node))

if any(substring in data for substring in quote_strip_param_substring):
node_token = node_token.strip("'\"")

return node_token
else:
return None



def get_tokens(tree):
"""Get tokens."""
return tree.scan_values(lambda v: isinstance(v, Token))
Expand Down
12 changes: 6 additions & 6 deletions tests/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
f"rename {NUCLEAR_ENVELOPE_URI} from 'nuclear envelope' to 'foo bar'",
NodeRename(
id=UID,
old_value="'nuclear envelope'",
new_value="'foo bar'",
old_value="nuclear envelope",
new_value="foo bar",
about_node="GO:0005635",
about_node_representation="curie",
),
Expand All @@ -77,8 +77,8 @@
f"rename {NUCLEUS_URI} from 'nucleus' to 'bar'",
NodeRename(
id=UID,
old_value="'nucleus'",
new_value="'bar'",
old_value="nucleus",
new_value="bar",
about_node=NUCLEUS,
about_node_representation="curie",
),
Expand All @@ -89,8 +89,8 @@
# f"""rename {NUCLEUS} from 'nucleus' to 'bobby " tables'""",
# f"""rename {NUCLEUS_URI} from 'nucleus' to 'bobby " tables'""",
# NodeRename(id=UID,
# old_value="'nucleus'",
# new_value="'bar'",
# old_value="nucleus",
# new_value="bar",
# about_node=NUCLEUS,
# about_node_representation='curie'),
# None
Expand Down

0 comments on commit 2405949

Please sign in to comment.