X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FdaComposant%2FdaCore%2FInterfaces.py;h=d0f203983573bf9d827562136c29def895c72100;hb=638487104745d6366bb26a744fd1acc858770f03;hp=bc25f135c1215f1f983e07d53c41fc5272e6661f;hpb=e0656540c715b3fa57adb5771421935a63e5284b;p=modules%2Fadao.git diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index bc25f13..d0f2039 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -52,12 +52,26 @@ class GenericCaseViewer(object): self._content = __content self._object = __object self._missing = """raise ValueError("This case requires beforehand to import or define the variable named <%s>. When corrected, remove this command, correct and uncomment the following one.")\n# """ + #------------------------ def _append(self, *args): "Transformation d'une commande individuelle en un enregistrement" raise NotImplementedError() def _extract(self, *args): "Transformation d'enregistrement(s) en commande(s) individuelle(s)" raise NotImplementedError() + #------------------------------ + def _initialize(self, __multilines): + "Permet des pré-conversions automatiques simples de commandes ou clés" + __translation = { + "Study_name" :"StudyName", + "Study_repertory" :"StudyRepertory", + "MaximumNumberOfSteps":"MaximumNumberOfIterations", + "FunctionDict" :"ScriptWithSwitch", + "FUNCTIONDICT_FILE" :"SCRIPTWITHSWITCH_FILE", + } + for k,v in __translation.items(): + __multilines = __multilines.replace(k,v) + return __multilines def _finalize(self, __upa=None): "Enregistrement du final" __hasNotExecute = True @@ -88,8 +102,9 @@ class GenericCaseViewer(object): "Chargement normalisé des commandes" if __filename is not None and os.path.exists(__filename): self._content = open(__filename, 'r').read() + self._content = self._initialize(self._content) elif __content is not None and type(__content) is str: - self._content = __content + self._content = self._initialize(__content) elif __object is not None and type(__object) is dict: self._object = copy.deepcopy(__object) else: @@ -652,7 +667,7 @@ class _ReportViewer(GenericCaseViewer): if k == "self": continue if isinstance(__v,Persistence.Persistence): __v = __v.values() numpy.set_printoptions(precision=15,threshold=1000000,linewidth=1000*15) - __ktext += "\n %s = %s, "%(k,repr(__v)) + __ktext += "\n %s = %s,"%(k,repr(__v)) numpy.set_printoptions(precision=8,threshold=1000,linewidth=75) if len(__ktext) > 0: __text += " with values:" + __ktext @@ -764,12 +779,9 @@ class ImportDetector(object): else: return False def is_not_local_file(self): - if not os.path.isfile(os.path.realpath(self.__url)): - return True - else: - return False + return not self.is_local_file() def raise_error_if_not_local_file(self): - if not os.path.isfile(os.path.realpath(self.__url)): + if self.is_not_local_file(): raise ValueError("The name or the url of the file object doesn't seem to exist. The given name is:\n \"%s\""%str(self.__url)) else: return False @@ -782,12 +794,9 @@ class ImportDetector(object): else: return False def is_not_local_dir(self): - if not os.path.isdir(self.__url): - return True - else: - return False + return not self.is_local_dir() def raise_error_if_not_local_dir(self): - if not os.path.isdir(self.__url): + if self.is_not_local_dir(): raise ValueError("The name or the url of the directory object doesn't seem to exist. The given name is:\n \"%s\""%str(self.__url)) else: return False @@ -902,7 +911,7 @@ class ImportFromFile(object): __header.append(__line) __skiprows += 1 __line = fid.readline().strip() - __varsline = __line + __varsline = __line # Ligne de labels par convention for i in range(max(0,__nblines)): __header.append(fid.readline()) return (__header, __varsline, __skiprows) @@ -950,7 +959,7 @@ class ImportFromFile(object): return self.__supportedformats def getvalue(self, ColNames=None, ColIndex=None ): - "Renvoie la ou les variables demandees par la liste de leurs noms" + "Renvoie la ou les variables demandées par la liste de leurs noms" # Uniquement si mise à jour if ColNames is not None: self._colnames = tuple(ColNames) if ColIndex is not None: self._colindex = str(ColIndex) @@ -1061,7 +1070,7 @@ class ImportScalarLinesFromFile(ImportFromFile): raise ValueError("Unkown file format \"%s\""%self._format) # def getvalue(self, VarNames = None, HeaderNames=()): - "Renvoie la ou les variables demandees par la liste de leurs noms" + "Renvoie la ou les variables demandées par la liste de leurs noms" if VarNames is not None: __varnames = tuple(VarNames) else: __varnames = None # @@ -1095,7 +1104,7 @@ class ImportScalarLinesFromFile(ImportFromFile): for i in range(1,len(HeaderNames)): __converters[i] = __replaceNone else: - raise ValueError("Can not find names of columns for initial values. Wrong first line is:\n \"%s\""%__firstline) + raise ValueError("Can not find names of columns for initial values. Wrong first line is:\n \"%s\""%self._varsline) # if self._format == "text/plain": __content = numpy.loadtxt(self._filename, dtype = __dtypes, usecols = __usecols, skiprows = self._skiprows, converters = __converters) @@ -1148,6 +1157,9 @@ class EficasGUI(object): if "EFICAS_ROOT" in os.environ: __EFICAS_ROOT = os.environ["EFICAS_ROOT"] __path_ok = True + elif "EFICAS_NOUVEAU_ROOT" in os.environ: + __EFICAS_ROOT = os.environ["EFICAS_NOUVEAU_ROOT"] + __path_ok = True else: self.__msg += "\nKeyError:\n"+\ " the required environment variable EFICAS_ROOT is unknown.\n"+\