52981: Dump python on MESH module does't work

This commit is contained in:
eap 2015-12-01 16:28:08 +03:00
parent 7d08ac8481
commit a023eb1307

View File

@ -1179,9 +1179,11 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
if ( importGeom && isMultiFile ) if ( importGeom && isMultiFile )
{ {
initPart += ("\n## import GEOM dump file ## \n" initPart += ("\n## import GEOM dump file ## \n"
"import string, os, sys, re\n" "import string, os, sys, re, inspect\n"
"sys.path.insert( 0, os.path.dirname(__file__) )\n" "thisFile = inspect.getfile( inspect.currentframe() )\n"
"exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",__name__)+\" import *\")\n"); "thisModule = os.path.splitext( os.path.basename( thisFile ))[0]\n"
"sys.path.insert( 0, os.path.dirname( thisFile ))\n"
"exec(\"from \"+re.sub(\"SMESH$\",\"GEOM\",thisModule)+\" import *\")\n\n");
} }
// import python files corresponding to plugins if they are used in anUpdatedScript // import python files corresponding to plugins if they are used in anUpdatedScript
{ {
@ -1207,7 +1209,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
initPart += importStr + "\n"; initPart += importStr + "\n";
} }
if( isMultiFile ) if ( isMultiFile )
initPart += "def RebuildData(theStudy):"; initPart += "def RebuildData(theStudy):";
initPart += "\n"; initPart += "\n";
@ -1271,8 +1273,18 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart; anUpdatedScript += removeObjPart + '\n' + setNamePart + '\n' + visualPropertiesPart;
if( isMultiFile ) if ( isMultiFile )
anUpdatedScript += "\n\tpass"; {
anUpdatedScript +=
"\n\tpass"
"\n"
"\nif __name__ == '__main__':"
"\n\tSMESH_RebuildData = RebuildData"
"\n\texec('import '+re.sub('SMESH$','GEOM',thisModule)+' as GEOM_dump')"
"\n\tGEOM_dump.RebuildData( salome.myStudy )"
"\n\texec('from '+re.sub('SMESH$','GEOM',thisModule)+' import * ')"
"\n\tSMESH_RebuildData( salome.myStudy )";
}
anUpdatedScript += "\n"; anUpdatedScript += "\n";
// no need now as we use 'tab' and 'nt' variables depending on isMultiFile // no need now as we use 'tab' and 'nt' variables depending on isMultiFile