From: adam Date: Tue, 20 Jul 2010 13:12:13 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: end_translate_resources_09Jul10~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bf459c25c0f2adb40f2b46713d967c960b28c86;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/SalomeApp/Makefile.am b/src/SalomeApp/Makefile.am index 9c94a2680..e7e3b5365 100755 --- a/src/SalomeApp/Makefile.am +++ b/src/SalomeApp/Makefile.am @@ -98,6 +98,8 @@ nodist_libSalomeApp_la_SOURCES = $(MOC_FILES) # python modules salomepython_PYTHON = salome_pluginsmanager.py +dist_salomescript_DATA = addvars2notebook.py + dist_salomeres_DATA = \ resources/SalomeApp.ini \ resources/SalomeApp.xml diff --git a/src/SalomeApp/addvars2notebook.py b/src/SalomeApp/addvars2notebook.py new file mode 100644 index 000000000..6f2375543 --- /dev/null +++ b/src/SalomeApp/addvars2notebook.py @@ -0,0 +1,67 @@ + +import os +import os.path + +def addvars2notebook(filename): + # + vars_and_values = [] + contents = [] + # + directory = os.path.dirname(filename) + base = os.path.basename(filename) + prefix = base[:-3] # remove ".py" + prefix = prefix + '_' + from os import listdir + l = listdir(directory) + for f in l: + if f.find(prefix) != 0: continue + if f[-3:] != ".py": continue + module = f[len(prefix):-3] + try: + mod = __import__("addvars2notebook_%s"%(module)) + except ImportError: + continue + try: + func = mod.addvars2notebook + except AttributeError: + continue + fff = os.path.join(directory, f) + content = func(fff, vars_and_values) + contents.append([fff, content]) + pass + # + if vars_and_values: + stream = open(filename) + content = stream.read() + stream.close() + fields = content.split("import iparameters") + if len(fields) == 2: + begin = fields[0] + if begin.find("## NoteBook E.A.") >= 0: + begin = begin.split("## NoteBook E.A.")[0] + pass + end = "import iparameters" + fields[1] + content = begin + content += "## NoteBook E.A.\n" + for var, value in vars_and_values: + content += "notebook.set(%s,%s)\n"%(var.__repr__(), value) + pass + content += end + stream = open(filename, "w") + stream.write(content) + stream.close() + # + for fff, content in contents: + stream = open(fff, "w") + stream.write(content) + stream.close() + pass + pass + pass + # + return + +if __name__ == "__main__": + import sys + addvars2notebook(sys.argv[1]) + pass