From b12277eaec97e03c156f7ba5233bd2d98b2772a8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Mon, 21 Nov 2016 21:03:13 +0100 Subject: [PATCH] Documentation and templates minor correction --- doc/en/ref_observers_requirements.rst | 35 ++++++++++++++++++++++++++- doc/fr/ref_observers_requirements.rst | 35 ++++++++++++++++++++++++++- src/daComposant/daCore/Templates.py | 18 ++++++++++++-- 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/doc/en/ref_observers_requirements.rst b/doc/en/ref_observers_requirements.rst index e734799..3822d13 100644 --- a/doc/en/ref_observers_requirements.rst +++ b/doc/en/ref_observers_requirements.rst @@ -92,6 +92,17 @@ Print on standard output the current value of the variable. print info, var[-1] +.. index:: single: ValueAndIndexPrinter (Observer) + +Template **ValueAndIndexPrinter** : +................................... + +Print on standard output the current value of the variable, adding its index. + +:: + + print str(info)+" index %i:"%(len(var)-1), var[-1] + .. index:: single: ValueSeriePrinter (Observer) Template **ValueSeriePrinter** : @@ -150,7 +161,7 @@ Save the value serie of the variable in a file of the '/tmp' directory named 'va Template **ValuePrinterAndSaver** : ................................... -Print on standard output and, in the same time, save in a file the current value of the variable. +Print on standard output and, in the same time save in a file, the current value of the variable. :: @@ -167,6 +178,28 @@ Print on standard output and, in the same time, save in a file the current value print 'Value saved in "%s"'%f numpy.savetxt(f,v) +.. index:: single: ValueIndexPrinterAndSaver (Observer) + +Template **ValueIndexPrinterAndSaver** : +........................................ + +Print on standard output and, in the same time save in a file, the current value of the variable, adding its index. + +:: + + import numpy, re + v=numpy.array(var[-1], ndmin=1) + print str(info)+" index %i:"%(len(var)-1),v + global istep + try: + istep += 1 + except: + istep = 0 + f='/tmp/value_%s_%05i.txt'%(info,istep) + f=re.sub('\s','_',f) + print 'Value saved in "%s"'%f + numpy.savetxt(f,v) + .. index:: single: ValueSeriePrinterAndSaver (Observer) Template **ValueSeriePrinterAndSaver** : diff --git a/doc/fr/ref_observers_requirements.rst b/doc/fr/ref_observers_requirements.rst index 5667bed..4f8e410 100644 --- a/doc/fr/ref_observers_requirements.rst +++ b/doc/fr/ref_observers_requirements.rst @@ -95,6 +95,17 @@ Imprime sur la sortie standard la valeur courante de la variable. print info, var[-1] +.. index:: single: ValueAndIndexPrinter (Observer) + +Modèle **ValueAndIndexPrinter** : +................................. + +Imprime sur la sortie standard la valeur courante de la variable, en ajoutant son index. + +:: + + print str(info)+" index %i:"%(len(var)-1), var[-1] + .. index:: single: ValueSeriePrinter (Observer) Modèle **ValueSeriePrinter** : @@ -153,7 +164,7 @@ Enregistre la s Modèle **ValuePrinterAndSaver** : ................................. -Imprime sur la sortie standard et, en même temps, enregistre dans un fichier la valeur courante de la variable. +Imprime sur la sortie standard et, en même temps enregistre dans un fichier, la valeur courante de la variable. :: @@ -170,6 +181,28 @@ Imprime sur la sortie standard et, en m print 'Value saved in "%s"'%f numpy.savetxt(f,v) +.. index:: single: ValueIndexPrinterAndSaver (Observer) + +Modèle **ValueIndexPrinterAndSaver** : +...................................... + +Imprime sur la sortie standard et, en même temps enregistre dans un fichier, la valeur courante de la variable, en ajoutant son index. + +:: + + import numpy, re + v=numpy.array(var[-1], ndmin=1) + print str(info)+" index %i:"%(len(var)-1),v + global istep + try: + istep += 1 + except: + istep = 0 + f='/tmp/value_%s_%05i.txt'%(info,istep) + f=re.sub('\s','_',f) + print 'Value saved in "%s"'%f + numpy.savetxt(f,v) + .. index:: single: ValueSeriePrinterAndSaver (Observer) Modèle **ValueSeriePrinterAndSaver** : diff --git a/src/daComposant/daCore/Templates.py b/src/daComposant/daCore/Templates.py index 118019b..2ce4a1f 100644 --- a/src/daComposant/daCore/Templates.py +++ b/src/daComposant/daCore/Templates.py @@ -99,6 +99,13 @@ ObserverTemplates.store( en_EN = "Print on standard output the current value of the variable", order = "next", ) +ObserverTemplates.store( + name = "ValueAndIndexPrinter", + content = """print str(info)+" index %i:"%(len(var)-1), var[-1]""", + fr_FR = "Imprime sur la sortie standard la valeur courante de la variable, en ajoutant son index", + en_EN = "Print on standard output the current value of the variable, adding its index", + order = "next", + ) ObserverTemplates.store( name = "ValueSeriePrinter", content = """print info, var[:]""", @@ -123,8 +130,15 @@ ObserverTemplates.store( ObserverTemplates.store( name = "ValuePrinterAndSaver", content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint info,v\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)""", - fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier la valeur courante de la variable", - en_EN = "Print on standard output and, in the same time, save in a file the current value of the variable", + fr_FR = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier, la valeur courante de la variable", + en_EN = "Print on standard output and, in the same time save in a file, the current value of the variable", + order = "next", + ) +ObserverTemplates.store( + name = "ValueIndexPrinterAndSaver", + content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint str(info)+" index %i:"%(len(var)-1),v\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)""", + fr_FR = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier, la valeur courante de la variable, en ajoutant son index", + en_EN = "Print on standard output and, in the same time save in a file, the current value of the variable, adding its index", order = "next", ) ObserverTemplates.store( -- 2.39.2