From: eap Date: Fri, 6 May 2005 06:39:48 +0000 (+0000) Subject: Bug IPAL8742 (Add comments into generated files of DumpPython). Add static GetDumpStu... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3549a5f1344df67679b9b13dd60b06b18769f24a;p=modules%2Fkernel.git Bug IPAL8742 (Add comments into generated files of DumpPython). Add static GetDumpStudyComment() Bug IPAL8749. Return false if any of scripts is invalid --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 9a64f6c27..6e0899ff8 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1269,13 +1269,15 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, TCollection_AsciiString aBatchModeScript = "salome"; //Output to the main Study script required Python modules import, set sys.path and add a creation of the study. + fp << GetDumpStudyComment().ToCString() << endl << endl; fp << "import sys" << endl; fp << "import " << aBatchModeScript << "\n" << endl; - fp << "sys.path.append(\'" << thePath << "\')\n" << endl; + fp << "sys.path.insert( 0, \'" << thePath << "\')\n" << endl; Handle(TColStd_HSequenceOfAsciiString) aSeqOfFileNames = new TColStd_HSequenceOfAsciiString; //Iterate all components and create the componponents specific scripts. + bool isOk = true; int aLength = aSeq.Length(); for(int i = 1; i <= aLength; i++) { @@ -1315,6 +1317,8 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, bool isValidScript; long aStreamLength = 0; unsigned char* aStream = aDriver->DumpPython(this, isPublished, isValidScript, aStreamLength); + if ( !isValidScript ) + isOk = false; //Create a file that will contain the component specific script fstream fp2; @@ -1355,7 +1359,21 @@ bool SALOMEDSImpl_Study::DumpStudy(const TCollection_AsciiString& thePath, } fp.close(); - return true; + return isOk; +} + +//======================================================================= +//function : GetDumpStudyComment +//purpose : return a header comment for a DumpStudy script +//======================================================================= + +TCollection_AsciiString SALOMEDSImpl_Study::GetDumpStudyComment(const char* theComponentName) +{ + TCollection_AsciiString txt + ("### This file is generated by SALOME automatically by dump python funcitonality"); + if ( theComponentName ) + txt += TCollection_AsciiString(" of ") + (char*) theComponentName + " component"; + return txt; } void dumpSO(const Handle(SALOMEDSImpl_SObject)& theSO,