Salome HOME
Correction of Python 3 compatibility and examples
[modules/adao.git] / src / daComposant / daCore / Interfaces.py
index 7737fa05ad006d889f1c3e2e1e2a45346e8c0773..3c1f5d4b834f4fe4dff93ffb451714a3c0890945 100644 (file)
@@ -28,10 +28,10 @@ __all__ = []
 
 import os
 import sys
-import logging
-import copy
 import numpy
 import mimetypes
+import logging
+import copy
 from daCore import Persistence
 from daCore import PlatformInfo
 from daCore import Templates
@@ -101,7 +101,7 @@ class _TUIViewer(GenericCaseViewer):
         self._addLine("# -*- coding: utf-8 -*-")
         self._addLine("#\n# Python script using ADAO TUI\n#")
         self._addLine("from numpy import array, matrix")
-        self._addLine("import adaoBuilder")
+        self._addLine("from adao import adaoBuilder")
         self._addLine("%s = adaoBuilder.New('%s')"%(self._objname, self._name))
         if self._content is not None:
             for command in self._content:
@@ -118,9 +118,10 @@ class _TUIViewer(GenericCaseViewer):
             for k in __keys:
                 __v = __local[k]
                 if __v is None: continue
-                if   k == "Checked" and not __v: continue
-                if   k == "Stored"  and not __v: continue
-                if   k == "AvoidRC" and __v: continue
+                if   k == "Checked"  and not __v: continue
+                if   k == "Stored"   and not __v: continue
+                if   k == "ColMajor" and not __v: continue
+                if   k == "AvoidRC"  and __v: continue
                 if   k == "noDetails": continue
                 if isinstance(__v,Persistence.Persistence): __v = __v.values()
                 if callable(__v): __text = self._missing%__v.__name__+__text
@@ -391,7 +392,7 @@ class _SCDViewer(GenericCaseViewer):
                     __text += "%s_config['From'] = '%s'\n"%(__command,__f)
                     __text += "%s_config['Data'] = %s\n"%(__command,__v)
                     __text = __text.replace("''","'")
-                elif __k in ('Stored', 'Checked'):
+                elif __k in ('Stored', 'Checked', 'ColMajor'):
                     if bool(__v):
                         __text += "%s_config['%s'] = '%s'\n"%(__command,__k,int(bool(__v)))
                 elif __k in ('AvoidRC', 'noDetails'):
@@ -421,7 +422,7 @@ class _SCDViewer(GenericCaseViewer):
         self._addLine("Analysis_config['From'] = 'String'")
         self._addLine("Analysis_config['Data'] = \"\"\"import numpy")
         self._addLine("xa=numpy.ravel(ADD.get('Analysis')[-1])")
-        self._addLine("print 'Analysis:',xa\"\"\"")
+        self._addLine("print('Analysis:',xa)\"\"\"")
         self._addLine("study_config['UserPostAnalysis'] = Analysis_config")
     def __loadVariablesByScript(self):
         __ExecVariables = {} # Necessaire pour recuperer la variable
@@ -666,12 +667,14 @@ class ImportFromFile(object):
         self.__header, self._varsline, self._skiprows = self.__getentete()
         #
         if self._format == "text/csv" or Format.upper() == "CSV":
+            self._format = "text/csv"
             self.__filestring = "".join(self.__header)
             if self.__filestring.count(",") > 1:
                 self._delimiter = ","
             elif self.__filestring.count(";") > 1:
                 self._delimiter = ";"
         elif self._format == "text/tab-separated-values" or Format.upper() == "TSV":
+            self._format = "text/tab-separated-values"
             self._delimiter = "\t"
         else:
             self._delimiter = None
@@ -776,6 +779,7 @@ class ImportFromFile(object):
                 __index = numpy.loadtxt(self._filename, dtype = bytes, usecols = (__useindex,), delimiter = self._delimiter, skiprows=self._skiprows)
         else:
             raise ValueError("Unkown file format \"%s\""%self._format)
+        if __columns is None: __columns = ()
         #
         def toString(value):
             try:
@@ -792,6 +796,9 @@ class ImportFromFile(object):
         with open(self._filename,'r') as fid:
             return fid.read()
 
+    def getformat(self):
+        return self._format
+
 # ==============================================================================
 class ImportScalarLinesFromFile(ImportFromFile):
     """