Salome HOME
Fix Platine test
[modules/shaper.git] / src / PythonAPI / model / exchange / exchange.py
index c294bc4e4a764c11cdc9d35ae1b451b8bc38bf58..c884451af4c377c19667f84cd85e264fb4d48f92 100644 (file)
@@ -7,36 +7,50 @@ from model.roots import Interface
 
 
 def addImport(part, *args):
-    """Add an Import feature to the Part and return Import.
+    """Add an Import feature to the Part.
 
-    Pass all args to Import __init__ function.
+    .. function:: addImport(part, file_path)
+
+    Args:
+        part (ModelAPI_Document): part document
+        file_path (string): path to the imported file
+
+    Returns:
+        Import: import object
     """
+    assert(args)
     feature = part.addFeature("Import")
     return Import(feature, *args)
 
 
 class Import(Interface):
-    """Interface on an Import feature."""
+    """Interface class for Import feature.
 
-    def __init__(self, feature, *args):
-        """Initialize an Import feature with given parameters.
+    .. function:: Import(feature)
 
-        Expected arguments for all modes:
-        feature -- an Import feature
+        Create interface for the feature without initialization.
 
-        For initialization (expect 1 argument):
-        file_path -- path to the imported file
-        """
+    .. function:: Import(feature, file_path)
+
+        Create interface for the feature and initialize the feature with arguments.
+    """
+
+    def __init__(self, feature, *args):
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Import")
 
         self._file_path = self._feature.data().string("file_path")
 
+        assert(self._file_path)
+
         if not args:
             return
 
         assert(len(args) == 1)
-        self.setFilePath(*args)
+        self.setFilePath(args[0])
+
+        self.execute()
         pass
 
     def setFilePath(self, file_path):
@@ -44,33 +58,43 @@ class Import(Interface):
 
         See __init__.
         """
-        self._fill_attribute(self._file_path, file_path)
+        self._fillAttribute(self._file_path, file_path)
         pass
 
 
-def addExport(part, *args):
-    """Add an Export feature to the Part and return Export.
+def exportToFile(part, *args):
+    """Perform export from the Part to file.
 
-    Pass all args to Export __init__ function.
+    .. function:: exportToFile(part, file_path, file_format, selection_list)
+
+    Args:
+        part (ModelAPI_Document): part document
+        file_path (string): path to the exported file
+        file_format (string): format of to the exported file
+        selection_list (list of Selection): objects to export
+
+    Returns:
+        Export: export object
     """
+    assert(args)
     feature = part.addFeature("Export")
     return Export(feature, *args)
 
 
 class Export(Interface):
-    """Interface on an Export feature."""
+    """Interface class for Export feature.
 
-    def __init__(self, feature, *args):
-        """Initialize an Export feature with given parameters.
+    .. function:: Export(feature)
 
-        Expected arguments for all modes:
-        feature -- an Export feature
+        Create interface for the feature without initialization.
 
-        For initialization (expect 3 argument):
-        file_path -- path to the exported file
-        file_format -- format of to the exported file
-        objects -- objects to export
-        """
+    .. function:: Export(feature, file_path, file_format, selection_list)
+
+        Create interface for the feature and initialize the feature with arguments.
+    """
+
+    def __init__(self, feature, *args):
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
         Interface.__init__(self, feature)
         assert(self._feature.getKind() == "Export")
 
@@ -78,6 +102,10 @@ class Export(Interface):
         self._file_format = self._feature.data().string("file_format")
         self._objects = self._feature.data().selectionList("selection_list")
 
+        assert(self._file_path)
+        assert(self._file_format)
+        assert(self._objects)
+
         if not args:
             return
 
@@ -85,6 +113,8 @@ class Export(Interface):
         self.setFilePath(args[0])
         self.setFileFormat(args[1])
         self.setObjects(args[2])
+
+        self.execute()
         pass
 
     def setFilePath(self, file_path):
@@ -92,7 +122,7 @@ class Export(Interface):
 
         See __init__.
         """
-        self._fill_attribute(self._file_path, file_path)
+        self._fillAttribute(self._file_path, file_path)
         pass
 
     def setFileFormat(self, file_format):
@@ -100,7 +130,7 @@ class Export(Interface):
 
         See __init__.
         """
-        self._fill_attribute(self._file_format, file_format)
+        self._fillAttribute(self._file_format, file_format)
         pass
 
     def setObjects(self, objects):
@@ -108,5 +138,5 @@ class Export(Interface):
 
         See __init__.
         """
-        self._fill_attribute(self._objects, object)
+        self._fillAttribute(self._objects, object)
         pass