- def __init__(self, __filename=None):
- "Verifie l'existence et importe le script"
- self.__filename = __filename.rstrip(".py")
- if self.__filename is None:
- raise ValueError("The name of the file containing the variable to be imported has to be specified.")
- if not os.path.isfile(str(self.__filename)+".py"):
- raise ValueError("The file containing the variable to be imported doesn't seem to exist. The given file name is:\n \"%s\""%self.__filename)
- self.__scriptfile = __import__(self.__filename, globals(), locals(), [])
- self.__scriptstring = open(self.__filename+".py",'r').read()
- def getvalue(self, __varname=None, __synonym=None ):
- "Renvoie la variable demandee"
- if __varname is None:
- raise ValueError("The name of the variable to be imported has to be specified.")
- if not hasattr(self.__scriptfile, __varname):
- if __synonym is None:
- raise ValueError("The imported script file \"%s\" doesn't contain the specified variable \"%s\"."%(str(self.__filename)+".py",__varname))
- elif not hasattr(self.__scriptfile, __synonym):
- raise ValueError("The imported script file \"%s\" doesn't contain the specified variable \"%s\"."%(str(self.__filename)+".py",__synonym))
- else:
- return getattr(self.__scriptfile, __synonym)
+ def __init__(self, __name="", __objname="case", __addViewers=None, __addLoaders=None):
+ self.__name = str(__name)
+ self.__objname = str(__objname)
+ self.__logSerie = []
+ self.__switchoff = False
+ self.__viewers = {
+ "TUI" :Interfaces._TUIViewer,
+ "SCD" :Interfaces._SCDViewer,
+ "YACS":Interfaces._YACSViewer,
+ }
+ self.__loaders = {
+ "TUI" :Interfaces._TUIViewer,
+ "COM" :Interfaces._COMViewer,
+ }
+ if __addViewers is not None:
+ self.__viewers.update(dict(__addViewers))
+ if __addLoaders is not None:
+ self.__loaders.update(dict(__addLoaders))
+
+ def register(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False):
+ "Enregistrement d'une commande individuelle"
+ if __command is not None and __keys is not None and __local is not None and not self.__switchoff:
+ if "self" in __keys: __keys.remove("self")
+ self.__logSerie.append( (str(__command), __keys, __local, __pre, __switchoff) )
+ if __switchoff:
+ self.__switchoff = True
+ if not __switchoff:
+ self.__switchoff = False
+
+ def dump(self, __filename=None, __format="TUI", __upa=""):
+ "Restitution normalisée des commandes"
+ if __format in self.__viewers:
+ __formater = self.__viewers[__format](self.__name, self.__objname, self.__logSerie)
+ else:
+ raise ValueError("Dumping as \"%s\" is not available"%__format)
+ return __formater.dump(__filename, __upa)
+
+ def load(self, __filename=None, __content=None, __object=None, __format="TUI"):
+ "Chargement normalisé des commandes"
+ if __format in self.__loaders:
+ __formater = self.__loaders[__format]()
+ else:
+ raise ValueError("Loading as \"%s\" is not available"%__format)
+ return __formater.load(__filename, __content, __object)
+
+# ==============================================================================
+def MultiFonction(
+ __xserie,
+ _extraArguments = None,
+ _sFunction = lambda x: x,
+ _mpEnabled = False,
+ _mpWorkers = None,
+ ):
+ """
+ Pour une liste ordonnée de vecteurs en entrée, renvoie en sortie la liste
+ correspondante de valeurs de la fonction en argument
+ """
+ # Vérifications et définitions initiales
+ # logging.debug("MULTF Internal multifonction calculations begin with function %s"%(_sFunction.__name__,))
+ if not PlatformInfo.isIterable( __xserie ):
+ raise TypeError("MultiFonction not iterable unkown input type: %s"%(type(__xserie),))
+ if _mpEnabled:
+ if (_mpWorkers is None) or (_mpWorkers is not None and _mpWorkers < 1):
+ __mpWorkers = None