diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index f1385039dd48e48032d67864932749d7518987fe..f119dec879a5e318eafe01ef37d14ca5eb9cbd3e 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 56587271d8da7f1e111483a6c4a6e487f5803892..21d1d7ade82d4798c132d5d3fc6643f3124e294f 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)