From f1f84674fac6dc4eaedbb2346d54b54573b50a5a Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Fri, 21 Oct 2022 11:08:43 +0200
Subject: [PATCH] DDSim: fix bug preventing the use of integers for the
verbosity level
---
DDG4/python/DDSim/DD4hepSimulation.py | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py
index 1ae61cf68..d066c2ace 100644
--- a/DDG4/python/DDSim/DD4hepSimulation.py
+++ b/DDG4/python/DDSim/DD4hepSimulation.py
@@ -41,6 +41,17 @@ 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):
@@ -168,6 +179,7 @@ class DD4hepSimulation(object):
parser.add_argument("-v", "--printLevel", action="store", default=self.printLevel, dest="printLevel",
choices=(1, 2, 3, 4, 5, 6, 7, 'VERBOSE', 'DEBUG',
'INFO', 'WARNING', 'ERROR', 'FATAL', 'ALWAYS'),
+ type=outputLevelType,
help="Verbosity use integers from 1(most) to 7(least) verbose"
"\nor strings: VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS")
--
GitLab