Skip to content

Commit 2405949

Browse files
committed
fixed the quotes issue
1 parent 8e4ed84 commit 2405949

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/data/examples/examples.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Test_0:
22
id: CHANGE:001
33
type: NodeRename
4-
old_value: '''nuclear envelope'''
5-
new_value: '''foo bar'''
4+
old_value: nuclear envelope
5+
new_value: foo bar
66
about_node: GO:0005635
77
about_node_representation: curie
88
command_with_curie: rename GO:0005635 from 'nuclear envelope' to 'foo bar'
@@ -11,8 +11,8 @@ Test_0:
1111
Test_1:
1212
id: CHANGE:001
1313
type: NodeRename
14-
old_value: '''nucleus'''
15-
new_value: '''bar'''
14+
old_value: nucleus
15+
new_value: bar
1616
about_node: GO:0005634
1717
about_node_representation: curie
1818
command_with_curie: rename GO:0005634 from 'nucleus' to 'bar'

src/kgcl_schema/grammar/parser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,16 +595,25 @@ def parse_rename(tree, id):
595595
)
596596

597597

598+
599+
598600
def extract(tree, data):
599601
"""Extract node."""
600602
node = get_next(tree.find_data(data))
603+
# Define this list at the module level if it's static and doesn't change per function call
604+
quote_strip_param_substring = ["_label", "name"]
601605
if node is not None:
602606
node_token = next(get_tokens(node))
607+
608+
if any(substring in data for substring in quote_strip_param_substring):
609+
node_token = node_token.strip("'\"")
610+
603611
return node_token
604612
else:
605613
return None
606614

607615

616+
608617
def get_tokens(tree):
609618
"""Get tokens."""
610619
return tree.scan_values(lambda v: isinstance(v, Token))

tests/cases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
f"rename {NUCLEAR_ENVELOPE_URI} from 'nuclear envelope' to 'foo bar'",
6666
NodeRename(
6767
id=UID,
68-
old_value="'nuclear envelope'",
69-
new_value="'foo bar'",
68+
old_value="nuclear envelope",
69+
new_value="foo bar",
7070
about_node="GO:0005635",
7171
about_node_representation="curie",
7272
),
@@ -77,8 +77,8 @@
7777
f"rename {NUCLEUS_URI} from 'nucleus' to 'bar'",
7878
NodeRename(
7979
id=UID,
80-
old_value="'nucleus'",
81-
new_value="'bar'",
80+
old_value="nucleus",
81+
new_value="bar",
8282
about_node=NUCLEUS,
8383
about_node_representation="curie",
8484
),
@@ -89,8 +89,8 @@
8989
# f"""rename {NUCLEUS} from 'nucleus' to 'bobby " tables'""",
9090
# f"""rename {NUCLEUS_URI} from 'nucleus' to 'bobby " tables'""",
9191
# NodeRename(id=UID,
92-
# old_value="'nucleus'",
93-
# new_value="'bar'",
92+
# old_value="nucleus",
93+
# new_value="bar",
9494
# about_node=NUCLEUS,
9595
# about_node_representation='curie'),
9696
# None

0 commit comments

Comments
 (0)