Salome HOME
Updating copyright date information
[modules/adao.git] / src / daComposant / daCore / Interfaces.py
index 47164d8f42aad8cf4003a7b72467558c0163c401..bc25f135c1215f1f983e07d53c41fc5272e6661f 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2008-2020 EDF R&D
+# Copyright (C) 2008-2022 EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -35,11 +35,12 @@ import copy
 from daCore import Persistence
 from daCore import PlatformInfo
 from daCore import Templates
+from daCore import Reporting
 
 # ==============================================================================
 class GenericCaseViewer(object):
     """
-    Gestion des commandes de creation d'une vue de cas
+    Gestion des commandes de création d'une vue de cas
     """
     def __init__(self, __name="", __objname="case", __content=None, __object=None):
         "Initialisation et enregistrement de l'entete"
@@ -52,15 +53,20 @@ class GenericCaseViewer(object):
         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 de commande individuelle en enregistrement"
+        "Transformation d'une commande individuelle en un enregistrement"
         raise NotImplementedError()
     def _extract(self, *args):
-        "Transformation d'enregistrement en commande individuelle"
+        "Transformation d'enregistrement(s) en commande(s) individuelle(s)"
         raise NotImplementedError()
     def _finalize(self, __upa=None):
         "Enregistrement du final"
-        if __upa is not None and len(__upa)>0:
+        __hasNotExecute = True
+        for l in self._lineSerie:
+            if "%s.execute"%(self._objname,) in l: __hasNotExecute = False
+        if __hasNotExecute:
             self._lineSerie.append("%s.execute()"%(self._objname,))
+        if __upa is not None and len(__upa)>0:
+            __upa = __upa.replace("ADD",str(self._objname))
             self._lineSerie.append(__upa)
     def _addLine(self, line=""):
         "Ajoute un enregistrement individuel"
@@ -93,7 +99,7 @@ class GenericCaseViewer(object):
 
 class _TUIViewer(GenericCaseViewer):
     """
-    Etablissement des commandes d'un cas ADAO TUI (Cas<->TUI)
+    Établissement des commandes d'un cas ADAO TUI (Cas<->TUI)
     """
     def __init__(self, __name="", __objname="case", __content=None, __object=None):
         "Initialisation et enregistrement de l'entete"
@@ -109,6 +115,8 @@ class _TUIViewer(GenericCaseViewer):
     def _append(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False):
         "Transformation d'une commande individuelle en un enregistrement"
         if __command is not None and __keys is not None and __local is not None:
+            if "Concept" in __keys:
+                logging.debug("TUI Order processed: %s"%(__local["Concept"],))
             __text  = ""
             if __pre is not None:
                 __text += "%s = "%__pre
@@ -116,6 +124,7 @@ class _TUIViewer(GenericCaseViewer):
             if "self" in __keys: __keys.remove("self")
             if __command not in ("set","get") and "Concept" in __keys: __keys.remove("Concept")
             for k in __keys:
+                if k not in __local: continue
                 __v = __local[k]
                 if __v is None: continue
                 if   k == "Checked"              and not __v: continue
@@ -123,7 +132,7 @@ class _TUIViewer(GenericCaseViewer):
                 if   k == "ColMajor"             and not __v: continue
                 if   k == "InputFunctionAsMulti" and not __v: continue
                 if   k == "nextStep"             and not __v: continue
-                if   k == "AvoidRC"              and     __v: continue
+                if   k == "PerformanceProfile"   and     __v: continue
                 if   k == "noDetails":                        continue
                 if isinstance(__v,Persistence.Persistence): __v = __v.values()
                 if callable(__v): __text = self._missing%__v.__name__+__text
@@ -133,11 +142,11 @@ class _TUIViewer(GenericCaseViewer):
                 numpy.set_printoptions(precision=15,threshold=1000000,linewidth=1000*15)
                 __text += "%s=%s, "%(k,repr(__v))
                 numpy.set_printoptions(precision=8,threshold=1000,linewidth=75)
-            __text.rstrip(", ")
-            __text += ")"
+            __text = __text.rstrip(", ")
+            __text += " )"
             self._addLine(__text)
     def _extract(self, __multilines="", __object=None):
-        "Transformation un enregistrement en une commande individuelle"
+        "Transformation d'enregistrement(s) en commande(s) individuelle(s)"
         __is_case = False
         __commands = []
         __multilines = __multilines.replace("\r\n","\n")
@@ -156,7 +165,7 @@ class _TUIViewer(GenericCaseViewer):
 
 class _COMViewer(GenericCaseViewer):
     """
-    Etablissement des commandes d'un cas COMM (Eficas Native Format/Cas<-COM)
+    Établissement des commandes d'un cas COMM (Eficas Native Format/Cas<-COM)
     """
     def __init__(self, __name="", __objname="case", __content=None, __object=None):
         "Initialisation et enregistrement de l'entete"
@@ -171,10 +180,26 @@ class _COMViewer(GenericCaseViewer):
             for command in self._content:
                 self._append(*command)
     def _extract(self, __multilines=None, __object=None):
-        "Transformation un enregistrement en une commande individuelle"
+        "Transformation d'enregistrement(s) en commande(s) individuelle(s)"
+        __suppparameters = {}
         if __multilines is not None:
-            __multilines = __multilines.replace("ASSIMILATION_STUDY","dict")
-            __multilines = __multilines.replace("CHECKING_STUDY",    "dict")
+            if 'adaoBuilder' in __multilines:
+                raise ValueError("Impossible to load given content as an ADAO COMM one (Hint: it's perhaps not a COMM input, but a TUI one).")
+            if "ASSIMILATION_STUDY" in __multilines:
+                __suppparameters.update({'StudyType':"ASSIMILATION_STUDY"})
+                __multilines = __multilines.replace("ASSIMILATION_STUDY","dict")
+            elif "OPTIMIZATION_STUDY" in __multilines:
+                __suppparameters.update({'StudyType':"ASSIMILATION_STUDY"})
+                __multilines = __multilines.replace("OPTIMIZATION_STUDY",    "dict")
+            elif "REDUCTION_STUDY" in __multilines:
+                __suppparameters.update({'StudyType':"ASSIMILATION_STUDY"})
+                __multilines = __multilines.replace("REDUCTION_STUDY",    "dict")
+            elif "CHECKING_STUDY" in __multilines:
+                __suppparameters.update({'StudyType':"CHECKING_STUDY"})
+                __multilines = __multilines.replace("CHECKING_STUDY",    "dict")
+            else:
+                __multilines = __multilines.replace("ASSIMILATION_STUDY","dict")
+            #
             __multilines = __multilines.replace("_F(",               "dict(")
             __multilines = __multilines.replace(",),);",             ",),)")
         __fulllines = ""
@@ -199,18 +224,33 @@ class _COMViewer(GenericCaseViewer):
                 __commands.append( "set( Concept='Name', String='%s')"%(str(r),) )
             elif   __command == "StudyRepertory":
                 __commands.append( "set( Concept='Directory', String='%s')"%(str(r),) )
+            elif   __command == "Debug" and str(r) == "0":
+                __commands.append( "set( Concept='NoDebug' )" )
+            elif   __command == "Debug" and str(r) == "1":
+                __commands.append( "set( Concept='Debug' )" )
+            elif   __command == "ExecuteInContainer":
+                __suppparameters.update({'ExecuteInContainer':r})
             #
             elif __command == "UserPostAnalysis" and type(r) is dict:
                 if 'STRING' in r:
-                    __UserPostAnalysis = r['STRING']
+                    __UserPostAnalysis = r['STRING'].replace("ADD",str(self._objname))
+                    __commands.append( "set( Concept='UserPostAnalysis', String=\"\"\"%s\"\"\" )"%(__UserPostAnalysis,) )
                 elif 'SCRIPT_FILE' in r and os.path.exists(r['SCRIPT_FILE']):
                     __UserPostAnalysis = open(r['SCRIPT_FILE'],'r').read()
-                elif 'Template' in r and 'ValueTemplate' in r:
+                    __commands.append( "set( Concept='UserPostAnalysis', Script='%s' )"%(r['SCRIPT_FILE'],) )
+                elif 'Template' in r and not 'ValueTemplate' in r:
                     # AnalysisPrinter...
+                    if r['Template'] not in Templates.UserPostAnalysisTemplates:
+                        raise ValueError("User post-analysis template \"%s\" does not exist."%(r['Template'],))
+                    else:
+                        __UserPostAnalysis = Templates.UserPostAnalysisTemplates[r['Template']]
+                    __commands.append( "set( Concept='UserPostAnalysis', Template='%s' )"%(r['Template'],) )
+                elif 'Template' in r and 'ValueTemplate' in r:
+                    # Le template ayant pu être modifié, donc on ne prend que le ValueTemplate...
                     __UserPostAnalysis = r['ValueTemplate']
+                    __commands.append( "set( Concept='UserPostAnalysis', String=\"\"\"%s\"\"\" )"%(__UserPostAnalysis,) )
                 else:
                     __UserPostAnalysis = ""
-                __UserPostAnalysis = __UserPostAnalysis.replace("ADD",self._objname)
             #
             elif __command == "AlgorithmParameters" and type(r) is dict and 'Algorithm' in r:
                 if 'data' in r and r['Parameters'] == 'Dict':
@@ -242,13 +282,13 @@ class _COMViewer(GenericCaseViewer):
                     if __idata['NodeType'] == 'Template' and 'Template' in __idata:
                         __template = __idata['Template']
                         if 'Info' in __idata:
-                            __info = ", Info='%s'"%(__idata['Info'],)
+                            __info = ", Info=\"\"\"%s\"\"\""%(__idata['Info'],)
                         else:
                             __info = ""
-                        __commands.append( "set( Concept='Observer', Variable='%s', Template='%s'%s )"%(sk,__template,__info) )
+                        __commands.append( "set( Concept='Observer', Variable='%s', Template=\"\"\"%s\"\"\"%s )"%(sk,__template,__info) )
                     if __idata['NodeType'] == 'String' and 'Value' in __idata:
                         __value =__idata['Value']
-                        __commands.append( "set( Concept='Observer', Variable='%s', String='%s' )"%(sk,__value) )
+                        __commands.append( "set( Concept='Observer', Variable='%s', String=\"\"\"%s\"\"\" )"%(sk,__value) )
             #
             # Background, ObservationError, ObservationOperator...
             elif type(r) is dict:
@@ -284,6 +324,8 @@ class _COMViewer(GenericCaseViewer):
                 __arguments = ["%s = %s"%(k,repr(v)) for k,v in __argumentsList]
                 __commands.append( "set( Concept='%s', %s )"%(__command, ", ".join(__arguments)))
         #
+        __commands.append( "set( Concept='%s', Parameters=%s )"%('SupplementaryParameters', repr(__suppparameters)))
+        #
         # ----------------------------------------------------------------------
         __commands.sort() # Pour commencer par 'AlgorithmParameters'
         __commands.append(__UserPostAnalysis)
@@ -291,20 +333,30 @@ class _COMViewer(GenericCaseViewer):
 
 class _SCDViewer(GenericCaseViewer):
     """
-    Etablissement des commandes d'un cas SCD (Study Config Dictionary/Cas->SCD)
+    Établissement des commandes d'un cas SCD (Study Config Dictionary/Cas->SCD)
+
+    Remarque : le fichier généré est différent de celui obtenu par EFICAS
     """
     def __init__(self, __name="", __objname="case", __content=None, __object=None):
-        "Initialisation et enregistrement de l'entete"
+        "Initialisation et enregistrement de l'entête"
         GenericCaseViewer.__init__(self, __name, __objname, __content, __object)
+        #
+        if __content is not None:
+            for command in __content:
+                if command[0] == "set": __command = command[2]["Concept"]
+                else:                   __command = command[0].replace("set", "", 1)
+                if __command == 'Name':
+                    self._name = command[2]["String"]
+        #
+        self.__DebugCommandNotSet = True
+        self.__ObserverCommandNotSet = True
+        self.__UserPostAnalysisNotSet = True
+        #
         self._addLine("# -*- coding: utf-8 -*-")
-        self._addLine("#\n# Input for ADAO converter to YACS\n#")
-        self._addLine("from numpy import array, matrix")
+        self._addLine("#\n# Input for ADAO converter to SCD\n#")
         self._addLine("#")
         self._addLine("study_config = {}")
-        self._addLine("study_config['StudyType'] = 'ASSIMILATION_STUDY'")
         self._addLine("study_config['Name'] = '%s'"%self._name)
-        self._addLine("observers = {}")
-        self._addLine("study_config['Observers'] = observers")
         self._addLine("#")
         self._addLine("inputvariables_config = {}")
         self._addLine("inputvariables_config['Order'] =['adao_default']")
@@ -322,15 +374,24 @@ class _SCDViewer(GenericCaseViewer):
         "Transformation d'une commande individuelle en un enregistrement"
         if __command == "set": __command = __local["Concept"]
         else:                  __command = __command.replace("set", "", 1)
+        logging.debug("SCD Order processed: %s"%(__command))
         #
         __text  = None
         if __command in (None, 'execute', 'executePythonScheme', 'executeYACSScheme', 'get', 'Name'):
             return
+        elif __command in ['Directory',]:
+            __text  = "#\nstudy_config['Repertory'] = %s"%(repr(__local['String']))
         elif __command in ['Debug', 'setDebug']:
             __text  = "#\nstudy_config['Debug'] = '1'"
+            self.__DebugCommandNotSet = False
         elif __command in ['NoDebug', 'setNoDebug']:
             __text  = "#\nstudy_config['Debug'] = '0'"
+            self.__DebugCommandNotSet = False
         elif __command in ['Observer', 'setObserver']:
+            if self.__ObserverCommandNotSet:
+                self._addLine("observers = {}")
+                self._addLine("study_config['Observers'] = observers")
+                self.__ObserverCommandNotSet = False
             __obs   = __local['Variable']
             self._numobservers += 1
             __text  = "#\n"
@@ -349,12 +410,28 @@ class _SCDViewer(GenericCaseViewer):
             else:
                 __text += "observers['%s']['info'] = \"\"\"%s\"\"\"\n"%(__obs, __obs)
             __text += "observers['%s']['number'] = %s"%(__obs, self._numobservers)
+        elif __command in ['UserPostAnalysis', 'setUserPostAnalysis']:
+            __text  = "#\n"
+            __text += "Analysis_config = {}\n"
+            if __local['String'] is not None:
+                __text += "Analysis_config['From'] = 'String'\n"
+                __text += "Analysis_config['Data'] = \"\"\"%s\"\"\"\n"%(__local['String'],)
+            if __local['Script'] is not None:
+                __text += "Analysis_config['From'] = 'Script'\n"
+                __text += "Analysis_config['Data'] = \"\"\"%s\"\"\"\n"%(__local['Script'],)
+            if __local['Template'] is not None and __local['Template'] in Templates.UserPostAnalysisTemplates:
+                __text += "Analysis_config['From'] = 'String'\n"
+                __text += "Analysis_config['Data'] = \"\"\"%s\"\"\"\n"%(Templates.UserPostAnalysisTemplates[__local['Template']],)
+            __text += "study_config['UserPostAnalysis'] = Analysis_config"
+            self.__UserPostAnalysisNotSet = False
         elif __local is not None: # __keys is not None and
             numpy.set_printoptions(precision=15,threshold=1000000,linewidth=1000*15)
             __text  = "#\n"
             __text += "%s_config = {}\n"%__command
             __local.pop('self','')
             __to_be_removed = []
+            __vectorIsDataFile = False
+            __vectorIsScript = False
             for __k,__v in __local.items():
                 if __v is None: __to_be_removed.append(__k)
             for __k in __to_be_removed:
@@ -363,6 +440,7 @@ class _SCDViewer(GenericCaseViewer):
                 if __k == "Concept": continue
                 if __k in ['ScalarSparseMatrix','DiagonalSparseMatrix','Matrix','OneFunction','ThreeFunctions'] and 'Script' in __local and __local['Script'] is not None: continue
                 if __k in ['Vector','VectorSerie'] and 'DataFile' in __local and __local['DataFile'] is not None: continue
+                if __k == 'Parameters' and not (__command in ['AlgorithmParameters','SupplementaryParameters']): continue
                 if __k == 'Algorithm':
                     __text += "study_config['Algorithm'] = %s\n"%(repr(__v))
                 elif __k == 'DataFile':
@@ -375,6 +453,7 @@ class _SCDViewer(GenericCaseViewer):
                     __text += "%s_config['From'] = '%s'\n"%(__command,__f)
                     __text += "%s_config['Data'] = %s\n"%(__command,__v)
                     __text = __text.replace("''","'")
+                    __vectorIsDataFile = True
                 elif __k == 'Script':
                     __k = 'Vector'
                     __f = 'Script'
@@ -408,13 +487,16 @@ class _SCDViewer(GenericCaseViewer):
                     __text += "%s_config['From'] = '%s'\n"%(__command,__f)
                     __text += "%s_config['Data'] = %s\n"%(__command,__v)
                     __text = __text.replace("''","'")
+                    __vectorIsScript = True
                 elif __k in ('Stored', 'Checked', 'ColMajor', 'InputFunctionAsMulti', 'nextStep'):
                     if bool(__v):
                         __text += "%s_config['%s'] = '%s'\n"%(__command,__k,int(bool(__v)))
-                elif __k in ('AvoidRC', 'noDetails'):
+                elif __k in ('PerformanceProfile', 'noDetails'):
                     if not bool(__v):
                         __text += "%s_config['%s'] = '%s'\n"%(__command,__k,int(bool(__v)))
                 else:
+                    if __k == 'Vector' and __vectorIsScript: continue
+                    if __k == 'Vector' and __vectorIsDataFile: continue
                     if __k == 'Parameters': __k = "Dict"
                     if isinstance(__v,Persistence.Persistence): __v = __v.values()
                     if callable(__v): __text = self._missing%__v.__name__+__text
@@ -433,13 +515,16 @@ class _SCDViewer(GenericCaseViewer):
             self._switchoff = False
     def _finalize(self, *__args):
         self.__loadVariablesByScript()
-        self._addLine("#")
-        self._addLine("Analysis_config = {}")
-        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("study_config['UserPostAnalysis'] = Analysis_config")
+        if self.__DebugCommandNotSet:
+            self._addLine("#\nstudy_config['Debug'] = '0'")
+        if self.__UserPostAnalysisNotSet:
+            self._addLine("#")
+            self._addLine("Analysis_config = {}")
+            self._addLine("Analysis_config['From'] = 'String'")
+            self._addLine("Analysis_config['Data'] = \"\"\"import numpy")
+            self._addLine("xa=ADD.get('Analysis')[-1]")
+            self._addLine("print('Analysis:',xa)\"\"\"")
+            self._addLine("study_config['UserPostAnalysis'] = Analysis_config")
     def __loadVariablesByScript(self):
         __ExecVariables = {} # Necessaire pour recuperer la variable
         exec("\n".join(self._lineSerie), __ExecVariables)
@@ -469,6 +554,20 @@ class _SCDViewer(GenericCaseViewer):
             __text += "AlgorithmParameters_config['From'] = 'String'\n"
             __text += "AlgorithmParameters_config['Data'] = '{}'\n"
             self._addLine(__text)
+        if 'SupplementaryParameters' in study_config and \
+                isinstance(study_config['SupplementaryParameters'], dict) and \
+                "From" in study_config['SupplementaryParameters'] and \
+                study_config['SupplementaryParameters']["From"] == 'String' and \
+                "Data" in study_config['SupplementaryParameters']:
+            __dict = eval(study_config['SupplementaryParameters']["Data"])
+            if 'ExecuteInContainer' in __dict:
+                self._addLine("#\nstudy_config['ExecuteInContainer'] = '%s'"%__dict['ExecuteInContainer'])
+            else:
+                self._addLine("#\nstudy_config['ExecuteInContainer'] = 'No'")
+            if 'StudyType' in __dict:
+                self._addLine("#\nstudy_config['StudyType'] = '%s'"%__dict['StudyType'])
+            if 'StudyType' in __dict and __dict['StudyType'] != "ASSIMILATION_STUDY":
+                self.__UserPostAnalysisNotSet = False
         del study_config
 
 class _YACSViewer(GenericCaseViewer):
@@ -493,8 +592,8 @@ class _YACSViewer(GenericCaseViewer):
         if not PlatformInfo.has_salome or \
             not PlatformInfo.has_adao:
             raise ImportError(
-                "Unable to get SALOME or ADAO environnement variables for YACS conversion.\n"+\
-                "Please load the right environnement before trying to use it.")
+                "Unable to get SALOME or ADAO environnement for YACS conversion.\n"+\
+                "Please load the right SALOME environnement before trying to use it.")
         else:
             from daYacsSchemaCreator.run import create_schema_from_content
         # -----
@@ -514,6 +613,76 @@ class _YACSViewer(GenericCaseViewer):
         __fid.close()
         return __text
 
+# ==============================================================================
+class _ReportViewer(GenericCaseViewer):
+    """
+    Partie commune de restitution simple
+    """
+    def __init__(self, __name="", __objname="case", __content=None, __object=None):
+        "Initialisation et enregistrement de l'entete"
+        GenericCaseViewer.__init__(self, __name, __objname, __content, __object)
+        self._r = Reporting.ReportStorage()
+        self._r.clear()
+        if self._name == "":
+            self._r.append("ADAO Study report", "title")
+        else:
+            self._r.append(str(self._name), "title")
+        if self._content is not None:
+            for command in self._content:
+                self._append(*command)
+    def _append(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False):
+        "Transformation d'une commande individuelle en un enregistrement"
+        if __command is not None and __keys is not None and __local is not None:
+            if __command in ("set","get") and "Concept" in __keys: __command = __local["Concept"]
+            __text  = ""
+            __text += "<i>%s</i> command has been set"%str(__command.replace("set",""))
+            __ktext = ""
+            for k in __keys:
+                if k not in __local: continue
+                __v = __local[k]
+                if __v is None: continue
+                if   k == "Checked"              and not __v: continue
+                if   k == "Stored"               and not __v: continue
+                if   k == "ColMajor"             and not __v: continue
+                if   k == "InputFunctionAsMulti" and not __v: continue
+                if   k == "nextStep"             and not __v: continue
+                if   k == "PerformanceProfile"   and     __v: continue
+                if   k == "noDetails":                        continue
+                if   k == "Concept":                          continue
+                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))
+                numpy.set_printoptions(precision=8,threshold=1000,linewidth=75)
+            if len(__ktext) > 0:
+                __text += " with values:" + __ktext
+            __text = __text.rstrip(", ")
+            self._r.append(__text, "uli")
+    def _finalize(self, __upa=None):
+        "Enregistrement du final"
+        raise NotImplementedError()
+
+class _SimpleReportInRstViewer(_ReportViewer):
+    """
+    Restitution simple en RST
+    """
+    def _finalize(self, __upa=None):
+        self._lineSerie.append(Reporting.ReportViewInRst(self._r).__str__())
+
+class _SimpleReportInHtmlViewer(_ReportViewer):
+    """
+    Restitution simple en HTML
+    """
+    def _finalize(self, __upa=None):
+        self._lineSerie.append(Reporting.ReportViewInHtml(self._r).__str__())
+
+class _SimpleReportInPlainTxtViewer(_ReportViewer):
+    """
+    Restitution simple en TXT
+    """
+    def _finalize(self, __upa=None):
+        self._lineSerie.append(Reporting.ReportViewInPlainTxt(self._r).__str__())
+
 # ==============================================================================
 class ImportFromScript(object):
     """
@@ -533,8 +702,12 @@ class ImportFromScript(object):
             __basename = __filename.rstrip(".py")
         PlatformInfo.checkFileNameImportability( __basename+".py" )
         self.__basename = __basename
-        self.__filenspace = __import__(__basename, globals(), locals(), [])
-        self.__filestring = open(__filename,'r').read()
+        try:
+            self.__filenspace = __import__(__basename, globals(), locals(), [])
+        except NameError:
+            self.__filenspace = ""
+        with open(__filename,'r') as fid:
+            self.__filestring = fid.read()
     def getvalue(self, __varname=None, __synonym=None ):
         "Renvoie la variable demandee par son nom ou son synonyme"
         if __varname is None: