Commit 79d2a8ed authored by Jiahang Chen's avatar Jiahang Chen
Browse files

fix python built-in var conflict

parent b860b27a
Pipeline #458960 passed with stages
in 51 seconds
""" This module implements a factory for managing and creating Digital Twins according to Forest Modeling Language 4.0."""
from ml.app_logger import APP_LOGGER
from import remove_namespace
from import remove_namespace, check_var_conflict
from ml.ditto_feature import ditto_feature
from ml.thing import Thing
from ml.ml40.roles.servives.service import Service
......@@ -308,7 +308,7 @@ def build_feature(feature):
elif key == "subFeatures":
build_sub_features(feature_instance, feature)
setattr(feature_instance, key, feature[key])
setattr(feature_instance, check_var_conflict(key), feature[key])
return feature_instance
......@@ -4,7 +4,8 @@
import os
BUILT_IN = ["from", "str", "dict", "list", "bool", "float", "int", "tuple",
"def", "return", "for", "if", "class", "try", "except"]
class BColors:
"""colors for the console log"""
......@@ -156,3 +157,16 @@ def remove_namespace(input_str):
return input_str.replace("fml40::", "").replace("ml40::", "")
def check_var_conflict(var):
check if the input is built-in variable
:param var: python var
:return: modified variable, if the input is a input variable.
if var in BUILT_IN:
return "_{}".format(var)
return var
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment