فهرست منبع

remove old code

Yentl Van Tendeloo 8 سال پیش
والد
کامیت
395ac6112c
1فایلهای تغییر یافته به همراه1 افزوده شده و 94 حذف شده
  1. 1 94
      wrappers/modelverse.py

+ 1 - 94
wrappers/modelverse.py

@@ -6,10 +6,9 @@ import time
 import threading
 import uuid
 
+import socket2event
 from sccd.runtime.statecharts_core import Event
 
-COMPILER_PATH = "interface/HUTN"
-
 MODE_UNCONNECTED = 0
 MODE_UNAUTHORIZED = 1
 MODE_MODELLING = 2
@@ -18,12 +17,6 @@ MODE_DIALOG = 4
 MODE_MANUAL = 5
 MODE_SERVICE = 6
 
-# Bind to the compiler (might have to update path manually!)
-sys.path.append(COMPILER_PATH)
-from hutn_compiler.compiler import main as do_compile
-
-import socket2event
-
 # Exceptions
 class ModelverseException(Exception):
     pass
@@ -180,40 +173,6 @@ def _input_raw(value, taskname):
     # Ugly json encoding of primitives
     ctrl_input.addInput(Event("HTTP_input", "request_in", [urllib.urlencode({"op": "set_input", "taskname": taskname, "value": value}), None]))
 
-def _compile_AL(code):
-    # Compile an action language file and send the compiled code
-    code_fragments = code.split("\n")
-    code_fragments = [i for i in code_fragments if i.strip() != ""]
-    code_fragments = [i.replace("    ", "\t") for i in code_fragments]
-    initial_tabs = min([len(i) - len(i.lstrip("\t")) for i in code_fragments])
-    code_fragments = [i[initial_tabs:] for i in code_fragments]
-    code_fragments.append("")
-    code = "\n".join(code_fragments)
-
-    with open(".code.alc", "w") as f:
-        f.write(code)
-        f.flush()
-
-    compiled = do_compile(".code.alc", COMPILER_PATH + "/grammars/actionlanguage.g", "CS")
-    return compiled
-
-def _compile_model(code):
-    # Compile a model and send the compiled graph
-    # First change multiple spaces to a tab
-    code_fragments = code.split("\n")
-    code_fragments = [i for i in code_fragments if i.strip() != ""]
-    code_fragments = [i.replace("    ", "\t") for i in code_fragments]
-    initial_tabs = min([len(i) - len(i.lstrip("\t")) for i in code_fragments])
-    code_fragments = [i[initial_tabs:] for i in code_fragments]
-    code_fragments.append("")
-    code = "\n".join(code_fragments)
-
-    with open(".model.mvc", "w") as f:
-        f.write(code)
-        f.flush()
-
-    return do_compile(".model.mvc", COMPILER_PATH + "/grammars/modelling.g", "M")
-
 def _output(expected=None, task=None):
     if task is None:
         task = taskname
@@ -413,17 +372,6 @@ def model_add(model_name, metamodel_name, model_code=""):
     """Instantiate a new model."""
     _goto_mode(MODE_MODELLING)
 
-    # Do this before creating the model, as otherwise compilation errors would make us inconsistent
-    """
-    if model_code is not None:
-        try:
-            compiled = _compile_model(model_code)
-        except Exception as e:
-            raise CompilationError(e)
-    else:
-        compiled = [0]
-    """
-
     _input(["model_add", metamodel_name, model_name])
     _handle_output("Waiting for model constructors...")
     _input(model_code)
@@ -435,15 +383,6 @@ def model_add(model_name, metamodel_name, model_code=""):
 def upload_code(code):
     _input(code)
 
-    """
-    try:
-        compiled = _compile_AL(code)
-    except Exception as e:
-        raise CompilationError(e)
-
-    _input(compiled)
-    """
-
 def model_delete(model_name):
     """Delete an existing model."""
     _goto_mode(MODE_MODELLING)
@@ -485,16 +424,6 @@ def model_overwrite(model_name, new_model="", metamodel_name=None):
     """Upload a new model and overwrite an existing model."""
     _goto_mode(MODE_MODIFY, model_name)
 
-    """
-    if new_model is not None:
-        try:
-            compiled = _compile_model(new_model)
-        except Exception as e:
-            raise CompilationError(e)
-    else:
-        compiled = [0]
-    """
-
     _input("upload")
     _handle_output("Waiting for model constructors...")
     _input(new_model)
@@ -537,13 +466,6 @@ def transformation_add_MT(source_metamodels, target_metamodels, operation_name,
     global mode
     _goto_mode(MODE_MODELLING)
 
-    """
-    try:
-        compiled = _compile_model(code)
-    except Exception as e:
-        raise CompilationError(e)
-    """
-
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_MT"] + mv_dict_rep + [operation_name])
 
@@ -565,13 +487,6 @@ def transformation_add_AL(source_metamodels, target_metamodels, operation_name,
     global mode
     _goto_mode(MODE_MODELLING)
 
-    """
-    try:
-        compiled = _compile_AL(code)
-    except Exception as e:
-        raise CompilationError(e)
-    """
-
     mv_dict_rep = _dict_to_list(source_metamodels) + [""] + _dict_to_list(target_metamodels) + [""]
     _input(["transformation_add_AL"] + mv_dict_rep + [operation_name])
 
@@ -584,7 +499,6 @@ def transformation_add_AL(source_metamodels, target_metamodels, operation_name,
         mode = MODE_MODELLING
 
     _handle_output("Waiting for code constructors...")
-    #_input(compiled)
     _input(code)
     _output("Success")
 
@@ -922,18 +836,11 @@ def attr_assign(model_name, ID, attr, value):
 def attr_assign_code(model_name, ID, attr, code):
     """Assign a piece of Action Language code to the attribute"""
     _check_type(code)
-    """
-    try:
-        compiled = _compile_AL(code)
-    except Exception as e:
-        raise CompilationError(e)
-    """
 
     _goto_mode(MODE_MODIFY, model_name)
 
     _input(["attr_add_code", ID, attr])
     _handle_output("Waiting for code constructors...")
-    #_input(compiled)
     _input(code)
     _output("Success")