Browse Source

Continue Python3 porting.

Bentley James Oakes 3 years ago
parent
commit
31bd1ef06e

+ 0 - 0
interface/HUTN/__init__.py


+ 2 - 0
interface/HUTN/hutn_compiler/compiler.py

@@ -27,6 +27,8 @@ def md5digest(data):
     hasher = hashlib.md5()
     try:
         data = data.encode('utf-8')
+    except UnicodeDecodeError:
+        pass
     except AttributeError:
         pass
 

+ 0 - 0
interface/__init__.py


+ 1 - 1
kernel/modelverse_kernel/generated.py

@@ -27,7 +27,7 @@ class ModelverseKernel(object):
 			if reply is not None:
 				return self.generators[taskname][operation].send(reply)
 			else:
-				return self.generators[taskname][operation].next()
+				return next(self.generators[taskname][operation])
 		except StopIteration:
 			# Done, so remove the generator
 			del self.generators[taskname][operation]

+ 1 - 1
kernel/modelverse_kernel/legacy.py

@@ -37,7 +37,7 @@ class ModelverseKernel(object):
             if reply is not None:
                 return self.generators[taskname][operation].send(reply)
             else:
-                return self.generators[taskname][operation].next()
+                return next(self.generators[taskname][operation])
         except StopIteration:
             # Done, so remove the generator
             del self.generators[taskname][operation]

+ 17 - 4
kernel/modelverse_kernel/primitives.py

@@ -1,5 +1,6 @@
 import time as python_time
 import json
+import sys
 
 class PrimitiveFinished(Exception):
     """Exception to indicate the result value of a primitive, as a return cannot be used."""
@@ -180,8 +181,14 @@ def list_insert(a, b, c, **remainder):
     a_outgoing, c_value = yield [("RO", [a]), ("RV", [c])]
     links = yield [("RD", [a, i]) for i in range(c_value, len(a_outgoing))] + \
                   [("RDE", [a, i]) for i in range(c_value, len(a_outgoing))]
-    values = links[:len(links)/2]
-    edges = links[len(links)/2:]
+
+    if sys.version_info[0] < 3:
+        values = links[:len(links)/2]
+        edges = links[len(links)/2:]
+    else:
+        values = links[:len(links) // 2]
+        edges = links[len(links) // 2:]
+
     yield [("CD", [a, c_value, b])] + \
           [("CD", [a, c_value + 1 + index, value]) for index, value in enumerate(values)] + \
           [("DE", [i]) for i in edges]
@@ -192,8 +199,14 @@ def list_delete(a, b, **remainder):
     a_outgoing, b_value = yield [("RO", [a]), ("RV", [b])]
     links = yield [("RD", [a, i]) for i in range(b_value, len(a_outgoing))] + \
                   [("RDE", [a, i]) for i in range(b_value, len(a_outgoing))]
-    values = links[:len(links)/2]
-    edges = links[len(links)/2:]
+
+    if sys.version_info[0] < 3:
+        values = links[:len(links) / 2]
+        edges = links[len(links) / 2:]
+    else:
+        values = links[:len(links) // 2]
+        edges = links[len(links) // 2:]
+
     yield [("CD", [a, b_value + index, value]) for index, value in enumerate(values[1:])] + \
           [("DE", [i]) for i in edges]
     raise PrimitiveFinished(a)