From c4e56a5eb7ac8b2406e2c3c22e438087beff268d Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Thu, 9 Jun 2022 11:41:07 +0200 Subject: [PATCH] DDSim: compactFile can only be one instance, otherwise we cannot overwrite what is in the steeringfile, still takes multiple XML files --- DDG4/python/DDSim/DD4hepSimulation.py | 7 +++---- DDG4/python/DDSim/Helper/ConfigHelper.py | 10 ---------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index f1385039d..f119dec87 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -19,7 +19,7 @@ from DDSim.Helper.Filter import Filter from DDSim.Helper.Random import Random from DDSim.Helper.Action import Action from DDSim.Helper.OutputConfig import OutputConfig -from DDSim.Helper.ConfigHelper import ConfigHelper, ExtendAction +from DDSim.Helper.ConfigHelper import ConfigHelper from DDSim.Helper.MagneticField import MagneticField from DDSim.Helper.ParticleHandler import ParticleHandler from DDSim.Helper.Gun import Gun @@ -131,8 +131,6 @@ class DD4hepSimulation(object): parser = argparse.ArgumentParser("Running DD4hep Simulations:", formatter_class=argparse.RawTextHelpFormatter) - # add myextend for python2.7 - parser.register('action', 'myextend', ExtendAction) parser.add_argument("--steeringFile", "-S", action="store", default=self.steeringFile, help="Steering file to change default behaviour") @@ -147,7 +145,8 @@ class DD4hepSimulation(object): if self._argv is None: self._argv = list(argv) if argv else list(sys.argv) - parser.add_argument("--compactFile", nargs='+', action="myextend", default=self.compactFile, type=str, + parser.add_argument("--compactFile", nargs='+', action="store", + default=ConfigHelper.makeList(self.compactFile), type=str, help="The compact XML file, or multiple compact files, if the last one is the closer.") parser.add_argument("--runType", action="store", choices=("batch", "vis", "run", "shell"), default=self.runType, diff --git a/DDG4/python/DDSim/Helper/ConfigHelper.py b/DDG4/python/DDSim/Helper/ConfigHelper.py index 56587271d..21d1d7ade 100644 --- a/DDG4/python/DDSim/Helper/ConfigHelper.py +++ b/DDG4/python/DDSim/Helper/ConfigHelper.py @@ -14,8 +14,6 @@ call for the parser object create an additional member:: from __future__ import absolute_import, unicode_literals -import argparse - import ddsix as six @@ -132,11 +130,3 @@ class ConfigHelper(object): dest="%s.%s" % (name, var), **optionsDict ) - - -class ExtendAction(argparse.Action): - """Class to add the extend action for argparse to python2.7""" - def __call__(self, parser, namespace, values, option_string=None): - items = getattr(namespace, self.dest) or [] - items.extend(values) - setattr(namespace, self.dest, items) -- GitLab