From db798648e9f6c2c246c81fd839f6c984d1957620 Mon Sep 17 00:00:00 2001 From: Dario Del Piano Date: Wed, 5 Sep 2018 17:03:25 +0100 Subject: [PATCH 1/2] fixed renaming function for the components that allow it, now it can handle also empty strings --- netpyne_ui/netpyne_geppetto.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/netpyne_ui/netpyne_geppetto.py b/netpyne_ui/netpyne_geppetto.py index 79455999..2353be9e 100644 --- a/netpyne_ui/netpyne_geppetto.py +++ b/netpyne_ui/netpyne_geppetto.py @@ -12,7 +12,7 @@ import threading import time import traceback - +import re from netpyne import specs, sim, analysis, utils from netpyne.metadata import metadata, api @@ -208,11 +208,14 @@ def rename(self, path, oldValue,newValue): command = 'sim.rename('+path+',"'+oldValue+'","'+newValue+'")' logging.debug('renaming '+command) eval(command) - for model, synched_component in list(GeppettoJupyterGUISync.synched_models.items()): - if model != '' and oldValue in model: + if model != '' and oldValue in model and path in model: # + logging.debug("Rename funct model is " + model) GeppettoJupyterGUISync.synched_models.pop(model) - newModel = model.replace(oldValue,newValue) + # innerStruct = model.replace(path, '') + newModel = re.sub("(['])(?:(?=(\\?))\2.)*?\1", lambda x:x.group(0).replace(oldValue,newValue, 1), model) + # newModel = path + structReplaced + logging.debug("Rename funct newModel is " + newModel) GeppettoJupyterGUISync.synched_models[newModel]=synched_component def getPlotSettings(self, plot): From 781074d5df06aa5dcfcba0b4f1b626a45ad36a11 Mon Sep 17 00:00:00 2001 From: Dario Del Piano Date: Wed, 5 Sep 2018 17:04:26 +0100 Subject: [PATCH 2/2] clean up --- netpyne_ui/netpyne_geppetto.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/netpyne_ui/netpyne_geppetto.py b/netpyne_ui/netpyne_geppetto.py index 2353be9e..64d18452 100644 --- a/netpyne_ui/netpyne_geppetto.py +++ b/netpyne_ui/netpyne_geppetto.py @@ -212,9 +212,7 @@ def rename(self, path, oldValue,newValue): if model != '' and oldValue in model and path in model: # logging.debug("Rename funct model is " + model) GeppettoJupyterGUISync.synched_models.pop(model) - # innerStruct = model.replace(path, '') newModel = re.sub("(['])(?:(?=(\\?))\2.)*?\1", lambda x:x.group(0).replace(oldValue,newValue, 1), model) - # newModel = path + structReplaced logging.debug("Rename funct newModel is " + newModel) GeppettoJupyterGUISync.synched_models[newModel]=synched_component