From c9834031f12dcc25ef19171260b59f17a28de98f Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 13 Nov 2018 10:18:33 +0300 Subject: [PATCH] Avoid redundant messages - MEDCoupling has been renamed to medcoupling - Show INF and DBG messages in verbose mode only --- doc/tut/medcoupling/partition.py | 2 +- doc/tut/medcoupling/testmed_gendata.py | 2 +- doc/tut/medcoupling/testmed_lena.py | 2 +- doc/tut/medcoupling/testmed_simple.py | 2 +- doc/tut/medcoupling/testpil.py | 2 +- doc/tut/medloader/testamel.py | 2 +- src/MEDCalc/tui/__init__.py | 10 ++++++++++ src/MEDCalc/tui/fieldproxy.py | 20 +++++++++++-------- src/MEDCalc/tui/medimages.py | 2 +- .../MEDCouplingCorbaSwigTest.py | 2 +- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/doc/tut/medcoupling/partition.py b/doc/tut/medcoupling/partition.py index 624000a47..76cf132c7 100644 --- a/doc/tut/medcoupling/partition.py +++ b/doc/tut/medcoupling/partition.py @@ -26,7 +26,7 @@ # WRN: this use case does not require a med input file because the # data (mesh and field) to work with are created from scratch. -from MEDCoupling import * +from medcoupling import * # ======================================================= # Creation of the input data (mesh and field) diff --git a/doc/tut/medcoupling/testmed_gendata.py b/doc/tut/medcoupling/testmed_gendata.py index e3bc9daab..ef99cb99a 100755 --- a/doc/tut/medcoupling/testmed_gendata.py +++ b/doc/tut/medcoupling/testmed_gendata.py @@ -24,7 +24,7 @@ # fields when defined on a cartesian mesh (grid). # (gboulant - 11/07/2011) -import MEDCoupling as MC +import medcoupling as MC import MEDLoader as ML import numpy diff --git a/doc/tut/medcoupling/testmed_lena.py b/doc/tut/medcoupling/testmed_lena.py index 3849d0f82..740bf7d85 100755 --- a/doc/tut/medcoupling/testmed_lena.py +++ b/doc/tut/medcoupling/testmed_lena.py @@ -25,7 +25,7 @@ import os -import MEDCoupling as MC +import medcoupling as MC import MEDLoader as ML # diff --git a/doc/tut/medcoupling/testmed_simple.py b/doc/tut/medcoupling/testmed_simple.py index 9801976d9..4fd38f667 100755 --- a/doc/tut/medcoupling/testmed_simple.py +++ b/doc/tut/medcoupling/testmed_simple.py @@ -23,7 +23,7 @@ # and save all the stuff in a med file. # (gboulant - 27/06/2011) -import MEDCoupling as MC +import medcoupling as MC import MEDLoader as ML # diff --git a/doc/tut/medcoupling/testpil.py b/doc/tut/medcoupling/testpil.py index c93ef1337..8516405b1 100755 --- a/doc/tut/medcoupling/testpil.py +++ b/doc/tut/medcoupling/testpil.py @@ -58,7 +58,7 @@ def image2matrix(): print(matrix) print(list(matrix)) -import MEDCoupling as MC +import medcoupling as MC import MEDLoader as ML def createMesh(meshname, sizeX, sizeY): """ diff --git a/doc/tut/medloader/testamel.py b/doc/tut/medloader/testamel.py index 1021cbc97..e6f784202 100644 --- a/doc/tut/medloader/testamel.py +++ b/doc/tut/medloader/testamel.py @@ -25,7 +25,7 @@ # # (gboulant, nov. 2012) from MEDLoader import * -from MEDCoupling import * +from medcoupling import * import os filename = "timeseries.med" diff --git a/src/MEDCalc/tui/__init__.py b/src/MEDCalc/tui/__init__.py index 471500800..deeb66ff6 100644 --- a/src/MEDCalc/tui/__init__.py +++ b/src/MEDCalc/tui/__init__.py @@ -20,9 +20,19 @@ # This functions are to be used to notify the USER of some events # arising on the field operation. It is NOT to be used for logging # purpose +def print_verbose(function): + from functools import wraps + @wraps(function) + def wrapper(self, *args, **kwargs): + from salome_utils import verbose + if verbose(): + function(self, *args, **kwargs) + return wrapper +@print_verbose def inf(msg): print("INF: "+str(msg)) def wrn(msg): print("WRN: "+str(msg)) def err(msg): print("ERR: "+str(msg)) +@print_verbose def dbg(msg): print("DBG: "+str(msg)) # Initialize CORBA stuff diff --git a/src/MEDCalc/tui/fieldproxy.py b/src/MEDCalc/tui/fieldproxy.py index 2a5215c25..52c0e7bb9 100644 --- a/src/MEDCalc/tui/fieldproxy.py +++ b/src/MEDCalc/tui/fieldproxy.py @@ -29,14 +29,14 @@ calculator = factory.getCalculator() # Some helper functions to deal with the fields and meshes import sys if sys.platform == "win32": - import MEDCouplingCompat as MEDCoupling + import MEDCouplingCompat as medcoupling else: - import MEDCoupling + import medcoupling __mapTypeOfFieldLabel = { - MEDCoupling.ON_CELLS: "ON_CELLS", - MEDCoupling.ON_NODES: "ON_NODES", - MEDCoupling.ON_GAUSS_PT: "ON_GAUSS_PT", - MEDCoupling.ON_GAUSS_NE: "ON_GAUSS_NE" + medcoupling.ON_CELLS: "ON_CELLS", + medcoupling.ON_NODES: "ON_NODES", + medcoupling.ON_GAUSS_PT: "ON_GAUSS_PT", + medcoupling.ON_GAUSS_NE: "ON_GAUSS_NE" } # def _typeOfFieldLabel(typeOfField): @@ -92,7 +92,9 @@ class FieldProxy: """ self.__fieldHandler = fieldHandler self.__restriction = None - print(self.__repr__()) + from salome_utils import verbose + if verbose(): + print(self.__repr__()) # def __getattr__(self, name ): """ @@ -407,7 +409,9 @@ class FieldProxy: notifyGui_updateField(self.id) # Print for visual control - print(self.__repr__()) + from salome_utils import verbose + if verbose(): + print(self.__repr__()) # # diff --git a/src/MEDCalc/tui/medimages.py b/src/MEDCalc/tui/medimages.py index e36ad86b4..78dd01628 100644 --- a/src/MEDCalc/tui/medimages.py +++ b/src/MEDCalc/tui/medimages.py @@ -24,7 +24,7 @@ import sys if sys.platform == "win32": import MEDCouplingCompat as MC else: - import MEDCoupling as MC + import medcoupling as MC import MEDLoader as ML diff --git a/src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTest.py b/src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTest.py index 272329a6c..9d3adbb86 100644 --- a/src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTest.py +++ b/src/MEDCouplingCorba_Swig/MEDCouplingCorbaSwigTest.py @@ -18,7 +18,7 @@ # # Author : Anthony Geay (CEA/DEN) -from MEDCoupling import * +from medcoupling import * import math import os -- 2.39.2