Fixed bug with edge and storage parameters in contact and coil not loaded in file saved with older version
authorLaurent Bessard
Thu, 05 Dec 2013 20:03:27 +0100
changeset 1381 8b0a7eceb76d
parent 1380 10ac2b18437b
child 1382 675a6229fc60
Fixed bug with edge and storage parameters in contact and coil not loaded in file saved with older version
editors/Viewer.py
--- a/editors/Viewer.py	Thu Dec 05 18:08:31 2013 +0100
+++ b/editors/Viewer.py	Thu Dec 05 20:03:27 2013 +0100
@@ -105,6 +105,7 @@
                                     specific_values.connectors)
     return powerRailCreationFunction
 
+NEGATED_VALUE = lambda x: x if x is not None else False
 MODIFIER_VALUE = lambda x: x if x is not None else 'none'
 
 CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE,
@@ -112,7 +113,7 @@
                  (False, "falling"): CONTACT_FALLING}
 
 def contactCreationFunction(viewer, id, specific_values):
-    contact_type = CONTACT_TYPES.get((specific_values.negated, 
+    contact_type = CONTACT_TYPES.get((NEGATED_VALUE(specific_values.negated), 
                                       MODIFIER_VALUE(specific_values.edge)),
                                      CONTACT_NORMAL)
     return LD_Contact(viewer, contact_type, specific_values.name, id)
@@ -124,7 +125,7 @@
               (False, "falling", "none"): COIL_FALLING}
 
 def coilCreationFunction(viewer, id, specific_values):
-    coil_type = COIL_TYPES.get((specific_values.negated, 
+    coil_type = COIL_TYPES.get((NEGATED_VALUE(specific_values.negated), 
                                 MODIFIER_VALUE(specific_values.edge),
                                 MODIFIER_VALUE(specific_values.storage)),
                                COIL_NORMAL)