Skip to content

Commit b4bab49

Browse files
committed
remove the remapping of "scope" to "model_scope"
1 parent 3e6615d commit b4bab49

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

pipeline/translator.py

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,26 @@
2020
"9": "nine",
2121
}
2222

23-
name_map = {
24-
"scope": "model_scope", # this is because 'scope' is a keyword in fairgraph
25-
# we could rename the 'scope' keyword to 'stage'
26-
# but we would have the same problem, as there is
27-
# a property named 'stage'
28-
# Suggested resolution: rename the property "scope" in openMINDS
29-
# to "modelScope" or "hasScope"
30-
}
31-
3223

3324
def generate_python_name(json_name, allow_multiple=False):
34-
if json_name in name_map:
35-
python_name = name_map[json_name]
36-
else:
37-
python_name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", json_name.strip())
38-
python_name = re.sub("([a-z0-9])([A-Z])", r"\1_\2", python_name).lower()
39-
replacements = [
40-
("-", "_"),
41-
(".", "_"),
42-
("'", "_prime_"),
43-
("+", "plus"),
44-
("#", "sharp"),
45-
(",", "comma"),
46-
("(", ""),
47-
(")", ""),
48-
]
49-
for before, after in replacements:
50-
python_name = python_name.replace(before, after)
51-
if python_name[0] in number_names: # Python variables can't start with a number
52-
python_name = number_names[python_name[0]] + python_name[1:]
53-
if not python_name.isidentifier():
54-
raise NameError(f"Cannot generate a valid Python name from '{json_name}'")
25+
python_name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", json_name.strip())
26+
python_name = re.sub("([a-z0-9])([A-Z])", r"\1_\2", python_name).lower()
27+
replacements = [
28+
("-", "_"),
29+
(".", "_"),
30+
("'", "_prime_"),
31+
("+", "plus"),
32+
("#", "sharp"),
33+
(",", "comma"),
34+
("(", ""),
35+
(")", ""),
36+
]
37+
for before, after in replacements:
38+
python_name = python_name.replace(before, after)
39+
if python_name[0] in number_names: # Python variables can't start with a number
40+
python_name = number_names[python_name[0]] + python_name[1:]
41+
if not python_name.isidentifier():
42+
raise NameError(f"Cannot generate a valid Python name from '{json_name}'")
5543
return python_name
5644

5745

0 commit comments

Comments
 (0)