1 # Copyright (C) 2016-2023 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 LOG_LEVEL = 1 # 0 means all, 1 means all but DEBUG, 2 means all but INFO and DEBUG, 3 only FATAL
29 Prints an information message to the standard output.
31 :param msg: str -- The message to be printed.
34 if cls.LOG_LEVEL <= 0:
35 cls.__log("[DEBUG]", msg)
41 Prints an information message to the standard output.
43 :param msg: str -- The message to be printed.
46 if cls.LOG_LEVEL <= 1:
47 cls.__log("[INFO]", msg)
51 def Warning(cls, msg):
53 Prints a warning message to the standard output.
55 :param msg: str -- The message to be printed.
58 if cls.LOG_LEVEL <= 2:
59 cls.__log("[WARNING]", msg)
63 def FatalError(cls, msg):
65 Prints an error message to the standard output.
67 :param msg: str -- The message to be printed.
71 if cls.LOG_LEVEL <= 3:
72 cls.__log("[FATAL]", msg)
76 def __log(cls, typ, msg):
77 print("%s: %s" % (typ, msg))
79 def trQ(tag, context="CURVEPLOT"):
80 """ @return a QString read from the translation file """
81 from pyqtside.QtWidgets import QApplication
82 return QApplication.translate(context, tag)
84 def trU(tag, context="CURVEPLOT"):
85 """ @return same as above, but returns a Python unicode string. """
86 qs = trQ(tag, context)
87 return str(qs, 'utf-8')
89 def toUnicodeWithWarning(s, method_name):
93 Logger.Warning("%s - warning, passing non-unicode, non-ASCII string '%s'! Trying to convert myself to UTF-8 ..." % (method_name, s))
97 def completeResPath(fileName):
99 subPath = "@SALOME_CURVEPLOT_INSTALL_PYTHON@"
100 rd = os.environ.get("CURVEPLOT_ROOT_DIR", None)
102 raise Exception("CURVEPLOT_ROOT_DIR is not defined!")
103 if @SALOME_CURVEPLOT_TEST_MODE@: # do not remove automatically modified in CMake config
104 subPath = "@CRVPLOT_TEST_INSTALL@"
105 filePath = os.path.join(rd, subPath, fileName)