diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index d066c2ace5b6ec4604e6dad3ec798239b8298ab9..c8397eae2d5f2e94e92b5fa54d8089d6bec1d7ff 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -19,6 +19,7 @@ from DDSim.Helper.Physics import Physics from DDSim.Helper.Filter import Filter from DDSim.Helper.Random import Random from DDSim.Helper.Action import Action +from DDSim.Helper.Output import Output, outputLevel, outputLevelType from DDSim.Helper.OutputConfig import OutputConfig from DDSim.Helper.InputConfig import InputConfig from DDSim.Helper.ConfigHelper import ConfigHelper @@ -41,36 +42,6 @@ except ImportError: POSSIBLEINPUTFILES = (".stdhep", ".slcio", ".HEPEvt", ".hepevt", ".hepmc", ".pairs") -def outputLevelType(level): - """Return verbosity level as integer if possible. - - Still benefit from argparsers list of possible choices - """ - try: - return int(level) - except: - return str(level) - - -def outputLevel(level): - """return INT for outputlevel""" - if isinstance(level, int): - if level < 1 or 7 < level: - raise KeyError - return level - outputlevels = {"VERBOSE": 1, - "DEBUG": 2, - "INFO": 3, - "WARNING": 4, - "ERROR": 5, - "FATAL": 6, - "ALWAYS": 7} - return outputlevels[level.upper()] - - -from DDSim.Helper.Output import Output # noqa - - class DD4hepSimulation(object): """Class to hold all the parameters and functions to run simulation""" @@ -592,16 +563,10 @@ class DD4hepSimulation(object): def __checkOutputLevel(self, level): """return outputlevel as int so we don't have to import anything for faster startup""" try: - level = int(level) - if level < 1 or 7 < level: - raise KeyError - return level + return outputLevel(level) except ValueError: - try: - return outputLevel(level.upper()) - except ValueError: - self._errorMessages.append("ERROR: printLevel is neither integer nor string") - return -1 + self._errorMessages.append("ERROR: printLevel is neither integer nor string") + return -1 except KeyError: self._errorMessages.append("ERROR: printLevel '%s' unknown" % level) return -1 diff --git a/DDG4/python/DDSim/Helper/Output.py b/DDG4/python/DDSim/Helper/Output.py index 2be6424199dedd00f599f642da4ba87612260ae9..cd81f68fea8fc475596e3322ffb2b4e825fa2acd 100644 --- a/DDG4/python/DDSim/Helper/Output.py +++ b/DDG4/python/DDSim/Helper/Output.py @@ -2,7 +2,33 @@ from __future__ import absolute_import, unicode_literals from DDSim.Helper.ConfigHelper import ConfigHelper -from DDSim.DD4hepSimulation import outputLevel, outputLevelType + + +def outputLevelType(level): + """Return verbosity level as integer if possible. + + Still benefit from argparsers list of possible choices + """ + try: + return int(level) + except ValueError: + return str(level) + + +def outputLevel(level): + """return INT for outputlevel""" + if isinstance(level, int): + if level < 1 or 7 < level: + raise KeyError + return level + outputlevels = {"VERBOSE": 1, + "DEBUG": 2, + "INFO": 3, + "WARNING": 4, + "ERROR": 5, + "FATAL": 6, + "ALWAYS": 7} + return outputlevels[level.upper()] class Output(ConfigHelper):