Salome HOME
Correction of ADAO TUI Python dump
[modules/adao.git] / src / daSalome / adaoBuilder.py
1 #-*-coding:iso-8859-1-*-
2 #
3 # Copyright (C) 2008-2017 EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22
23 """
24     Normalized interface for ADAO scripting (full version API)
25 """
26 __author__ = "Jean-Philippe ARGAUD"
27 __all__ = ["New"]
28
29 import os
30 from daCore.AssimilationStudy import AssimilationStudy as _AssimilationStudy
31 from daCore.Templates import ObserverTemplates as _ObserverTemplates
32 from daCore.BasicObjects import ImportFromScript as _ImportFromScript
33 from daCore.BasicObjects import ObserverF as _ObserverF
34
35 # ==============================================================================
36 class New(object):
37     """
38     Creation TUI d'un cas ADAO
39     """
40     def __init__(self, name = ""):
41         self.__adaoStudy = _AssimilationStudy(name)
42         self.__case = _CaseLogger(name)
43
44     # -----------------------------------------------------------
45
46     def set(
47             self,
48             Concept              = None,
49             Algorithm            = None,
50             DiagonalSparseMatrix = None,
51             Info                 = None,
52             Matrix               = None,
53             OneFunction          = None,
54             Parameters           = None,
55             ScalarSparseMatrix   = None,
56             Script               = None,
57             Stored               = False,
58             String               = None,
59             Template             = None,
60             ThreeFunctions       = None,
61             AppliedInXb          = None,
62             Variable             = None,
63             Vector               = None,
64             VectorSerie          = None):
65         "Interface unique de definition de variables d'entrees par argument"
66         self.__case.register("set",dir(),locals(),None,True)
67         try:
68             if   Concept == "Background":
69                 self.setBackground(Vector,VectorSerie,Script,Stored)
70             elif Concept == "BackgroundError":
71                 self.setBackgroundError(Matrix,ScalarSparseMatrix,
72                                         DiagonalSparseMatrix,Script,Stored)
73             elif Concept == "CheckingPoint":
74                 self.setCheckingPoint(Vector,VectorSerie,Script,Stored)
75             elif Concept == "ControlModel":
76                 self.setControlModel(Matrix,OneFunction,ThreeFunctions,
77                                      Parameters,Script,Stored)
78             elif Concept == "ControlInput":
79                 self.setControlInput(Vector,VectorSerie,Script,Stored)
80             elif Concept == "EvolutionError":
81                 self.setEvolutionError(Matrix,ScalarSparseMatrix,
82                                        DiagonalSparseMatrix,Script,Stored)
83             elif Concept == "EvolutionModel":
84                 self.setEvolutionModel(Matrix,OneFunction,ThreeFunctions,
85                                        Parameters,Script,Stored)
86             elif Concept == "Observation":
87                 self.setObservation(Vector,VectorSerie,Script,Stored)
88             elif Concept == "ObservationError":
89                 self.setObservationError(Matrix,ScalarSparseMatrix,
90                                          DiagonalSparseMatrix,Script,Stored)
91             elif Concept == "ObservationOperator":
92                 self.setObservationOperator(Matrix,OneFunction,ThreeFunctions,
93                                             AppliedInXb, Parameters,Script,Stored)
94             elif Concept == "AlgorithmParameters":
95                 self.setAlgorithmParameters(Algorithm,Parameters,Script)
96             elif Concept == "Debug":
97                 self.setDebug()
98             elif Concept == "NoDebug":
99                 self.setNoDebug()
100             elif Concept == "Observer":
101                 self.setObserver(Variable,Template,String,Script,Info)
102             else:
103                 raise ValueError("the variable named '%s' is not allowed."%str(Concept))
104         except Exception as e:
105             if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
106             else: msg = ""
107             raise ValueError("during settings, the following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal."%(str(e),msg))
108
109     # -----------------------------------------------------------
110
111     def setBackground(
112             self,
113             Vector         = None,
114             VectorSerie    = None,
115             Script         = None,
116             Stored         = False):
117         "Definition d'une entree de calcul"
118         self.__case.register("setBackground", dir(), locals())
119         if Script is not None:
120             __Vector, __PersistentVector = None, None
121             if VectorSerie:
122                 __PersistentVector = _ImportFromScript(Script).getvalue( "Background" )
123             else:
124                 __Vector = _ImportFromScript(Script).getvalue( "Background" )
125         else:
126             __Vector, __PersistentVector = Vector, VectorSerie
127         #
128         self.__adaoStudy.setBackground(
129             asVector           = __Vector,
130             asPersistentVector = __PersistentVector,
131             toBeStored         = Stored,
132             )
133
134     def setBackgroundError(
135             self,
136             Matrix               = None,
137             ScalarSparseMatrix   = None,
138             DiagonalSparseMatrix = None,
139             Script               = None,
140             Stored               = False):
141         "Definition d'une entree de calcul"
142         self.__case.register("setBackgroundError", dir(), locals())
143         if Script is not None:
144             __Covariance, __Scalar, __Vector = None, None, None
145             if ScalarSparseMatrix:
146                 __Scalar = _ImportFromScript(Script).getvalue( "BackgroundError" )
147             elif DiagonalSparseMatrix:
148                 __Vector = _ImportFromScript(Script).getvalue( "BackgroundError" )
149             else:
150                 __Covariance = _ImportFromScript(Script).getvalue( "BackgroundError" )
151         else:
152             __Covariance, __Scalar, __Vector = Matrix, ScalarSparseMatrix, DiagonalSparseMatrix
153         #
154         self.__adaoStudy.setBackgroundError(
155             asCovariance  = __Covariance,
156             asEyeByScalar = __Scalar,
157             asEyeByVector = __Vector,
158             toBeStored    = Stored,
159             )
160
161     def setCheckingPoint(
162             self,
163             Vector         = None,
164             VectorSerie    = None,
165             Script         = None,
166             Stored         = False):
167         "Definition d'une entree de verification"
168         self.__case.register("setCheckingPoint", dir(), locals())
169         if Script is not None:
170             __Vector, __PersistentVector = None, None
171             if VectorSerie:
172                 __PersistentVector = _ImportFromScript(Script).getvalue( "CheckingPoint" )
173             else:
174                 __Vector = _ImportFromScript(Script).getvalue( "CheckingPoint" )
175         else:
176             __Vector, __PersistentVector = Vector, VectorSerie
177         #
178         self.__adaoStudy.setBackground(
179             asVector           = __Vector,
180             asPersistentVector = __PersistentVector,
181             toBeStored         = Stored,
182             )
183
184     def setControlModel(
185             self,
186             Matrix         = None,
187             OneFunction    = None,
188             ThreeFunctions = None,
189             Parameters     = None,
190             Script         = None,
191             Stored         = False):
192         "Definition d'une entree de calcul"
193         self.__case.register("setControlModel", dir(), locals())
194         __Parameters = {}
195         if (Parameters is not None) and isinstance(Parameters, dict):
196             if "DifferentialIncrement" in Parameters:
197                 __Parameters["withIncrement"] = Parameters["DifferentialIncrement"]
198             if "CenteredFiniteDifference" in Parameters:
199                 __Parameters["withCenteredDF"] = Parameters["CenteredFiniteDifference"]
200         if Script is not None:
201             __Matrix, __Function = None, None
202             if Matrix:
203                 __Matrix = _ImportFromScript(Script).getvalue( "ObservationOperator" )
204             elif OneFunction:
205                 __Function = { "Direct":_ImportFromScript(Script).getvalue( "DirectOperator" ) }
206                 __Function.update({"useApproximatedDerivatives":True})
207                 __Function.update(__Parameters)
208             elif ThreeFunctions:
209                 __Function = {
210                     "Direct" :_ImportFromScript(Script).getvalue( "DirectOperator" ),
211                     "Tangent":_ImportFromScript(Script).getvalue( "TangentOperator" ),
212                     "Adjoint":_ImportFromScript(Script).getvalue( "AdjointOperator" ),
213                     }
214                 __Function.update(__Parameters)
215         else:
216             __Matrix = Matrix
217             if OneFunction is not None:
218                 __Function = { "Direct":OneFunction }
219                 __Function.update({"useApproximatedDerivatives":True})
220                 __Function.update(__Parameters)
221             elif ThreeFunctions is not None:
222                 if (not isinstance(ThreeFunctions, dict)) or \
223                    "Direct"  not in ThreeFunctions or \
224                    "Tangent" not in ThreeFunctions or \
225                    "Adjoint" not in ThreeFunctions:
226                     raise ValueError("ThreeFunctions has to be a dictionnary and to have the 3 keys Direct, Tangent, Adjoint")
227                 __Function = ThreeFunctions
228                 __Function.update(__Parameters)
229             else:
230                 __Function = None
231         #
232         self.__adaoStudy.setControlModel(
233             asFunction = __Function,
234             asMatrix   = __Matrix,
235             toBeStored = Stored,
236             )
237
238     def setControlInput(
239             self,
240             Vector         = None,
241             VectorSerie    = None,
242             Script         = None,
243             Stored         = False):
244         "Definition d'une entree de calcul"
245         self.__case.register("setControlInput", dir(), locals())
246         if Script is not None:
247             __Vector, __PersistentVector = None, None
248             if VectorSerie:
249                 __PersistentVector = _ImportFromScript(Script).getvalue( "ControlInput" )
250             else:
251                 __Vector = _ImportFromScript(Script).getvalue( "ControlInput" )
252         else:
253             __Vector, __PersistentVector = Vector, VectorSerie
254         #
255         self.__adaoStudy.setControlInput(
256             asVector           = __Vector,
257             asPersistentVector = __PersistentVector,
258             toBeStored         = Stored,
259             )
260
261     def setEvolutionError(
262             self,
263             Matrix               = None,
264             ScalarSparseMatrix   = None,
265             DiagonalSparseMatrix = None,
266             Script               = None,
267             Stored               = False):
268         "Definition d'une entree de calcul"
269         self.__case.register("setEvolutionError", dir(), locals())
270         if Script is not None:
271             __Covariance, __Scalar, __Vector = None, None, None
272             if ScalarSparseMatrix:
273                 __Scalar = _ImportFromScript(Script).getvalue( "EvolutionError" )
274             elif DiagonalSparseMatrix:
275                 __Vector = _ImportFromScript(Script).getvalue( "EvolutionError" )
276             else:
277                 __Covariance = _ImportFromScript(Script).getvalue( "EvolutionError" )
278         else:
279             __Covariance, __Scalar, __Vector = Matrix, ScalarSparseMatrix, DiagonalSparseMatrix
280         #
281         self.__adaoStudy.setEvolutionError(
282             asCovariance  = __Covariance,
283             asEyeByScalar = __Scalar,
284             asEyeByVector = __Vector,
285             toBeStored    = Stored,
286             )
287
288     def setEvolutionModel(
289             self,
290             Matrix         = None,
291             OneFunction    = None,
292             ThreeFunctions = None,
293             Parameters     = None,
294             Script         = None,
295             Stored         = False):
296         "Definition d'une entree de calcul"
297         self.__case.register("setEvolutionModel", dir(), locals())
298         __Parameters = {}
299         if (Parameters is not None) and isinstance(Parameters, dict):
300             if "DifferentialIncrement" in Parameters:
301                 __Parameters["withIncrement"] = Parameters["DifferentialIncrement"]
302             if "CenteredFiniteDifference" in Parameters:
303                 __Parameters["withCenteredDF"] = Parameters["CenteredFiniteDifference"]
304             if "EnableMultiProcessing" in Parameters:
305                 __Parameters["withmpEnabled"] = Parameters["EnableMultiProcessing"]
306             if "NumberOfProcesses" in Parameters:
307                 __Parameters["withmpWorkers"] = Parameters["NumberOfProcesses"]
308         if Script is not None:
309             __Matrix, __Function = None, None
310             if Matrix:
311                 __Matrix = _ImportFromScript(Script).getvalue( "ObservationOperator" )
312             elif OneFunction:
313                 __Function = { "Direct":_ImportFromScript(Script).getvalue( "DirectOperator" ) }
314                 __Function.update({"useApproximatedDerivatives":True})
315                 __Function.update(__Parameters)
316             elif ThreeFunctions:
317                 __Function = {
318                     "Direct" :_ImportFromScript(Script).getvalue( "DirectOperator" ),
319                     "Tangent":_ImportFromScript(Script).getvalue( "TangentOperator" ),
320                     "Adjoint":_ImportFromScript(Script).getvalue( "AdjointOperator" ),
321                     }
322                 __Function.update(__Parameters)
323         else:
324             __Matrix = Matrix
325             if OneFunction is not None:
326                 __Function = { "Direct":OneFunction }
327                 __Function.update({"useApproximatedDerivatives":True})
328                 __Function.update(__Parameters)
329             elif ThreeFunctions is not None:
330                 if (not isinstance(ThreeFunctions, dict)) or \
331                    "Direct"  not in ThreeFunctions or \
332                    "Tangent" not in ThreeFunctions or \
333                    "Adjoint" not in ThreeFunctions:
334                     raise ValueError("ThreeFunctions has to be a dictionnary and to have the 3 keys Direct, Tangent, Adjoint")
335                 __Function = ThreeFunctions
336                 __Function.update(__Parameters)
337             else:
338                 __Function = None
339         #
340         self.__adaoStudy.setEvolutionModel(
341             asFunction = __Function,
342             asMatrix   = __Matrix,
343             toBeStored = Stored,
344             )
345
346     def setObservation(
347             self,
348             Vector         = None,
349             VectorSerie    = None,
350             Script         = None,
351             Stored         = False):
352         "Definition d'une entree de calcul"
353         self.__case.register("setObservation", dir(), locals())
354         if Script is not None:
355             __Vector, __PersistentVector = None, None
356             if VectorSerie:
357                 __PersistentVector = _ImportFromScript(Script).getvalue( "Observation" )
358             else:
359                 __Vector = _ImportFromScript(Script).getvalue( "Observation" )
360         else:
361             __Vector, __PersistentVector = Vector, VectorSerie
362         #
363         self.__adaoStudy.setObservation(
364             asVector           = __Vector,
365             asPersistentVector = __PersistentVector,
366             toBeStored         = Stored,
367             )
368
369     def setObservationError(
370             self,
371             Matrix               = None,
372             ScalarSparseMatrix   = None,
373             DiagonalSparseMatrix = None,
374             Script               = None,
375             Stored               = False):
376         "Definition d'une entree de calcul"
377         self.__case.register("setObservationError", dir(), locals())
378         if Script is not None:
379             __Covariance, __Scalar, __Vector = None, None, None
380             if ScalarSparseMatrix:
381                 __Scalar = _ImportFromScript(Script).getvalue( "ObservationError" )
382             elif DiagonalSparseMatrix:
383                 __Vector = _ImportFromScript(Script).getvalue( "ObservationError" )
384             else:
385                 __Covariance = _ImportFromScript(Script).getvalue( "ObservationError" )
386         else:
387             __Covariance, __Scalar, __Vector = Matrix, ScalarSparseMatrix, DiagonalSparseMatrix
388         #
389         self.__adaoStudy.setObservationError(
390             asCovariance  = __Covariance,
391             asEyeByScalar = __Scalar,
392             asEyeByVector = __Vector,
393             toBeStored    = Stored,
394             )
395
396     def setObservationOperator(
397             self,
398             Matrix         = None,
399             OneFunction    = None,
400             ThreeFunctions = None,
401             AppliedInXb    = None,
402             Parameters     = None,
403             Script         = None,
404             Stored         = False):
405         "Definition d'une entree de calcul"
406         self.__case.register("setObservationOperator", dir(), locals())
407         __Parameters = {}
408         if (Parameters is not None) and isinstance(Parameters, dict):
409             if "DifferentialIncrement" in Parameters:
410                 __Parameters["withIncrement"] = Parameters["DifferentialIncrement"]
411             if "CenteredFiniteDifference" in Parameters:
412                 __Parameters["withCenteredDF"] = Parameters["CenteredFiniteDifference"]
413             if "EnableMultiProcessing" in Parameters:
414                 __Parameters["EnableMultiProcessing"] = Parameters["EnableMultiProcessing"]
415                 __Parameters["withmpEnabled"]         = Parameters["EnableMultiProcessing"]
416             if "NumberOfProcesses" in Parameters:
417                 __Parameters["NumberOfProcesses"] = Parameters["NumberOfProcesses"]
418                 __Parameters["withmpWorkers"]     = Parameters["NumberOfProcesses"]
419         if Script is not None:
420             __Matrix, __Function = None, None
421             if Matrix:
422                 __Matrix = _ImportFromScript(Script).getvalue( "ObservationOperator" )
423             elif OneFunction:
424                 __Function = { "Direct":_ImportFromScript(Script).getvalue( "DirectOperator" ) }
425                 __Function.update({"useApproximatedDerivatives":True})
426                 __Function.update(__Parameters)
427             elif ThreeFunctions:
428                 __Function = {
429                     "Direct" :_ImportFromScript(Script).getvalue( "DirectOperator" ),
430                     "Tangent":_ImportFromScript(Script).getvalue( "TangentOperator" ),
431                     "Adjoint":_ImportFromScript(Script).getvalue( "AdjointOperator" ),
432                     }
433                 __Function.update(__Parameters)
434         else:
435             __Matrix = Matrix
436             if OneFunction is not None:
437                 __Function = { "Direct":OneFunction }
438                 __Function.update({"useApproximatedDerivatives":True})
439                 __Function.update(__Parameters)
440             elif ThreeFunctions is not None:
441                 if (not isinstance(ThreeFunctions, dict)) or \
442                    "Direct"  not in ThreeFunctions or \
443                    "Tangent" not in ThreeFunctions or \
444                    "Adjoint" not in ThreeFunctions:
445                     raise ValueError("ThreeFunctions has to be a dictionnary and to have the 3 keys Direct, Tangent, Adjoint")
446                 __Function = ThreeFunctions
447                 __Function.update(__Parameters)
448             else:
449                 __Function = None
450         if AppliedInXb is not None:
451             __appliedToX = {"HXb":AppliedInXb}
452         else:
453             __appliedToX = None
454         #
455         self.__adaoStudy.setObservationOperator(
456             asFunction = __Function,
457             asMatrix   = __Matrix,
458             appliedToX = __appliedToX,
459             toBeStored = Stored,
460             )
461
462     # -----------------------------------------------------------
463
464     def setAlgorithmParameters(
465             self,
466             Algorithm  = None,
467             Parameters = None,
468             Script     = None):
469         "Definition d'un parametrage du calcul"
470         self.__case.register("setAlgorithmParameters", dir(), locals())
471         if Script is not None:
472             __Algorithm  = _ImportFromScript(Script).getvalue( "Algorithm" )
473             __Parameters = _ImportFromScript(Script).getvalue( "AlgorithmParameters", "Parameters" )
474         else:
475             __Algorithm  = Algorithm
476             __Parameters = Parameters
477         self.__adaoStudy.setAlgorithm( choice = __Algorithm )
478         self.__adaoStudy.setAlgorithmParameters( asDico = __Parameters )
479
480     def setDebug(self):
481         "Definition d'un parametrage du calcul"
482         self.__case.register("setDebug",dir(),locals())
483         return self.__adaoStudy.setDebug()
484
485     def setNoDebug(self):
486         "Definition d'un parametrage du calcul"
487         self.__case.register("setNoDebug",dir(),locals())
488         return self.__adaoStudy.unsetDebug()
489
490     def setObserver(
491             self,
492             Variable = None,
493             Template = None,
494             String   = None,
495             Script   = None,
496             Info     = None):
497         "Definition d'un parametrage du calcul"
498         self.__case.register("setObserver", dir(), locals())
499         if Variable is None:
500             raise ValueError("setting an observer has to be done over a variable name, not over None.")
501         else:
502             __Variable = str(Variable)
503             if Info is None:
504                 __Info = str(Variable)
505             else:
506                 __Info = str(Info)
507         #
508         if String is not None:
509             __FunctionText = String
510         elif (Template is not None) and (Template in _ObserverTemplates):
511             __FunctionText = _ObserverTemplates[Template]
512         elif Script is not None:
513             __FunctionText = _ImportFromScript(Script).getstring()
514         else:
515             __FunctionText = ""
516         __Function = _ObserverF(__FunctionText)
517         #
518         self.__adaoStudy.setDataObserver(
519             VariableName   = __Variable,
520             HookFunction   = __Function.getfunc(),
521             HookParameters = __Info,
522             )
523
524     # -----------------------------------------------------------
525
526     def executePythonScheme(self):
527         "Lancement du calcul"
528         self.__case.register("executePythonScheme", dir(), locals())
529         try:
530             self.__adaoStudy.analyze()
531         except Exception as e:
532             if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
533             else: msg = ""
534             raise ValueError("during execution, the following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal."%(str(e),msg))
535
536     execute = executePythonScheme
537
538     def executeYACSScheme(self, File=None):
539         "Lancement du calcul"
540         self.__case.register("executeYACSScheme", dir(), locals())
541         raise NotImplementedError()
542
543     # -----------------------------------------------------------
544
545     def get(self, Concept=None):
546         "Recuperation d'une sortie du calcul"
547         self.__case.register("get",dir(),locals(),Concept)
548         return self.__adaoStudy.get(Concept)
549
550     def dumpNormalizedCommands(self, filename=None):
551         "Recuperation de la liste des commandes du cas TUI"
552         return self.__case.dump(filename, "TUI")
553
554     def __dir__(self):
555         return ['set', 'get', 'execute', '__doc__', '__init__', '__module__']
556
557 # ==============================================================================
558 class _CaseLogger(object):
559     """
560     Conservation des commandes de creation d'un cas
561     """
562     def __init__(self, __name="", __objname="case"):
563         self.__name     = str(__name)
564         self.__objname  = str(__objname)
565         self.__logSerie = []
566         self.__switchoff = False
567     def register(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False):
568         "Enregistrement d'une commande individuelle"
569         if __command is not None and __keys is not None and __local is not None and not self.__switchoff:
570             if "self" in __keys: __keys.remove("self")
571             self.__logSerie.append( (str(__command), __keys, __local, __pre, __switchoff) )
572             if __switchoff:
573                 self.__switchoff = True
574         if not __switchoff:
575             self.__switchoff = False
576     def dump(self, __filename=None, __format="TUI"):
577         if __format == "TUI":
578             self.__dumper = _TUIViewer(self.__name, self.__objname, self.__logSerie)
579             __text = self.__dumper.dump(__filename)
580         else:
581             raise ValueError("Dumping as \"%s\" is not available"%__format)
582         return __text
583
584 # ==============================================================================
585 class _GenericViewer(object):
586     """
587     Etablissement des commandes de creation d'une vue
588     """
589     def __init__(self, __name="", __objname="case", __content=None):
590         self._name     = str(__name)
591         self._objname  = str(__objname)
592         self._lineSerie = []
593         self._switchoff = False
594         self._numobservers = 1
595     def _addLine(self, line=""):
596         self._lineSerie.append(line)
597     def _append(self):
598         "Enregistrement d'une commande individuelle"
599         raise NotImplementedError()
600     def dump(self, __filename=None):
601         "Restitution de la liste des commandes de creation d'un cas"
602         raise NotImplementedError()
603
604 class _TUIViewer(_GenericViewer):
605     """
606     Etablissement des commandes de creation d'un cas TUI
607     """
608     def __init__(self, __name="", __objname="case", __content=None):
609         _GenericViewer.__init__(self, __name, __objname, __content)
610         self._addLine("#\n# Python script for ADAO TUI\n#")
611         self._addLine("from numpy import array, matrix")
612         self._addLine("import adaoBuilder")
613         self._addLine("%s = adaoBuilder.New('%s')"%(self._objname, self._name))
614         if __content is not None:
615             for command in __content:
616                 self._append(*command)
617     def _append(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False):
618         if __command is not None and __keys is not None and __local is not None:
619             __text  = ""
620             if __pre is not None:
621                 __text += "%s = "%__pre
622             __text += "%s.%s( "%(self._objname,str(__command))
623             if "self" in __keys: __keys.remove("self")
624             for k in __keys:
625                 __v = __local[k]
626                 if __v is None: continue
627                 if   k == "Checked" and not __v: continue
628                 if   k == "Stored"  and not __v: continue
629                 __text += "%s=%s, "%(k,repr(__v))
630             __text += ")"
631             self._addLine(__text)
632     def dump(self, __filename=None):
633         __text = "\n".join(self._lineSerie)
634         if __filename is not None:
635             fid = open(__filename,"w")
636             fid.write(__text)
637             fid.close()
638         return __text
639
640 # ==============================================================================
641 if __name__ == "__main__":
642     print('\n AUTODIAGNOSTIC \n')