Salome HOME
PAL9165. emit message only if no valid ImportExport file found
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IInsertOperations.cxx
index 520eba58fd4392c6b5242fd1fab6188487f222c4..11ec04762fdd77179271e04d7e5948dd8cf28853 100644 (file)
@@ -12,6 +12,7 @@ using namespace std;
 #include <TDF_Tool.hxx>
 
 #include "GEOM_Function.hxx"
+#include "GEOM_PythonDump.hxx"
 
 #include "GEOMImpl_CopyDriver.hxx"
 #include "GEOMImpl_ExportDriver.hxx"
@@ -90,13 +91,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) the
   }
 
   //Make a Python command
-  TCollection_AsciiString anEntry, aDescr;
-  TDF_Tool::Entry(aCopy->GetEntry(), anEntry);
-  aDescr += (anEntry+" = IInsertOperations.MakeCopy(");
-  TDF_Tool::Entry(theOriginal->GetEntry(), anEntry);
-  aDescr += (anEntry+")");
-
-  aFunction->SetDescription(aDescr);
+  GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeCopy(" << theOriginal << ")";
 
   SetErrorCode(OK);
   return aCopy;
@@ -154,14 +149,8 @@ void GEOMImpl_IInsertOperations::Export
   }
 
   //Make a Python command
-  TCollection_AsciiString anEntry, aDescr;
-  aDescr = "IInsertOperations.Export(";
-  TDF_Tool::Entry(theOriginal->GetEntry(), anEntry);
-  aDescr += (anEntry + ", ");
-  aDescr += (TCollection_AsciiString(aFileName) + ", ");
-  aDescr += (TCollection_AsciiString(aFormatName) + ")");
-
-  aFunction->SetDescription(aDescr);
+  GEOM::TPythonDump(aFunction) << "geompy.Export(" << theOriginal
+    << ", \"" << theFileName << "\", \"" << theFormatName << "\")";
 
   SetErrorCode(OK);
 }
@@ -216,13 +205,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
   }
 
   //Make a Python command
-  TCollection_AsciiString anEntry, aDescr;
-  TDF_Tool::Entry(result->GetEntry(), anEntry);
-  aDescr += (anEntry + " = IInsertOperations.Import(");
-  aDescr += (TCollection_AsciiString(aFileName) + ", ");
-  aDescr += (TCollection_AsciiString(aFormatName) + ")");
-
-  aFunction->SetDescription(aDescr);
+  GEOM::TPythonDump(aFunction) << result << " = geompy.Import(\""
+    << theFileName << "\", \"" << theFormatName << "\")";
 
   SetErrorCode(OK);
   return result;
@@ -383,11 +367,14 @@ Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
 #else
     aUserResDir += "/.salome/resources";
 #endif
-    myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_True);
-  }
+    myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_False);
 
-  if (myResMgr->Find("Import") || myResMgr->Find("Export"))
-    return Standard_True;
+    if (!myResMgr->Find("Import") && !myResMgr->Find("Export")) {
+      // instead of complains in Resource_Manager
+      INFOS("No valid file \"ImportExport\" found in " << aResDir.ToCString() <<
+            " and in " << aUserResDir.ToCString() );
+    }
+  }
 
-  return Standard_False;
+  return ( myResMgr->Find("Import") || myResMgr->Find("Export") );
 }