Browse Source

Merge branch 'master' into testing

Yentl Van Tendeloo 5 years ago
parent
commit
3cd3b2177c
2 changed files with 5 additions and 10 deletions
  1. 2 4
      bootstrap/bootstrap.py
  2. 3 6
      state/modelverse_state/main.py

+ 2 - 4
bootstrap/bootstrap.py

@@ -182,10 +182,9 @@ def bootstrap():
                 total_alc = []
                 binding_alc = 'Void function initialize_MMs():\n\tinitialize_SCD("models/SimpleClassDiagrams")\n'
 
-                bootstrap_models = sorted(glob.glob("bootstrap/*.mvc"))
+                bootstrap_models = sorted([i.replace("\\", "/") for i in glob.glob("bootstrap/*.mvc")])
                 for bootstrap_model in bootstrap_models:
                     # Compile the subfile
-                    bootstrap_model = bootstrap_model.replace("\\", "/")
                     model_name = bootstrap_model.rsplit(".mvc", 1)[0].rsplit("/", 1)[1]
                     print("[MVC] %s" % model_name)
                     alc = compile_code_MO(bootstrap_model, model_name)
@@ -202,11 +201,10 @@ def bootstrap():
                     mm.write(new_metamodels_alc)
 
                 # Compile all files and add to structure manually
-                bootstrap_files = sorted(glob.glob("bootstrap/*.alc") + glob.glob("bootstrap/.*.alc"))
+                bootstrap_files = sorted([i.replace("\\", "/") for i in (glob.glob("bootstrap/*.alc") + glob.glob("bootstrap/.*.alc"))])
                 all_code = ""
                 for bootstrap_file in bootstrap_files:
                     # Compile the subfile
-                    bootstrap_file = bootstrap_file.replace("\\", "/")
                     print("[ALC] %s" % bootstrap_file)
                     all_code += "".join([i.replace(" = ?\n", "\n") for i in open(bootstrap_file, 'r').readlines() if not i.startswith("include ")])
                     f.write(compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, main=bootstrap_file==main_file), both=False)

+ 3 - 6
state/modelverse_state/main.py

@@ -3,16 +3,13 @@ from collections import defaultdict
 import os
 import gzip
 import time
-
-
+import marshal
 
 # Work around Python 2 where a 'big integer' automatically becomes a long
 if sys.version > '3': # pragma: no cover
-    import pickle as pickle
     integer_types = (int,)
     primitive_types = (int, float, str, bool)
 else: # pragma: no cover
-    import cPickle as pickle
     integer_types = (int, long)
     primitive_types = (int, long, float, str, bool, unicode)
 complex_primitives = frozenset(["if", "while", "assign", "call", "break", "continue", "return","resolve","access", "constant", "input", "output", "declare", "global", "none"])
@@ -60,7 +57,7 @@ class ModelverseState(object):
         try:
             if os.path.getmtime(picklefile) > os.path.getmtime(filename):
                 # Pickle is more recent than bootstrap file, so we can use it
-                self.root, self.free_id, self.nodes, self.edges, self.values, self.cache, self.cache_node = pickle.load(open(picklefile, 'rb'))
+                self.root, self.free_id, self.nodes, self.edges, self.values, self.cache, self.cache_node = marshal.load(open(picklefile, 'rb'))
                 for name in self.edges:
                     source, destination = self.edges[name]
                     self.outgoing.setdefault(source, set()).add(name)
@@ -123,7 +120,7 @@ class ModelverseState(object):
 
             # Creation successful, now also create a pickle
             with open(picklefile, 'wb') as f:
-                pickle.dump((symbols["root"], self.free_id, self.nodes, self.edges, self.values, self.cache, self.cache_node), f, pickle.HIGHEST_PROTOCOL)
+                marshal.dump((symbols["root"], self.free_id, self.nodes, self.edges, self.values, self.cache, self.cache_node), f)
 
             return symbols["root"]