From 566f1d7afb02b0cc3a1212bb6a2197cd32fbdaef Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sat, 6 Oct 2018 16:46:15 +0400 Subject: [PATCH] =?UTF-8?q?tailor.py:=20possibilit=C3=A9=20de=20modifier?= =?UTF-8?q?=20les=20pr=C3=A9r=C3=A9glages=20par=20les=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tailor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tailor.py b/tailor.py index 26d28cc..6974874 100755 --- a/tailor.py +++ b/tailor.py @@ -170,7 +170,7 @@ Si cet argument n'est pas spécifié, l'entrée standard est utilisée comme sou description=__doc__, formatter_class=FancyHelpFormatter, ) - AP.set_defaults(inputfile=None, follow=False, patterns=None, defaults=True, presets=None) + AP.set_defaults(inputfile=None, follow=None, patterns=None, defaults=None, presets=None) AP.add_argument('-e', '--pattern', action='append', dest='patterns', metavar='PATTERN:FORMAT', help=pattern_help) AP.add_argument('-z', '--no-defaults', action='store_false', dest='defaults', help=no_defaults_help) AP.add_argument('-d', '--defaults', action='store_true', dest='defaults', help=no_defaults_help) @@ -184,8 +184,14 @@ Si cet argument n'est pas spécifié, l'entrée standard est utilisée comme sou if presets not in PRESETS: raise ValueError("%s: argument invalide" % presets) inputfile, follow, opatterns, odefaults = PRESETS.get(presets) + if o.inputfile is not None: inputfile = o.inputfile + if o.follow is not None: follow = o.follow + if o.patterns is not None: opatterns = o.patterns + if o.defaults is not None: odefaults = o.defaults else: inputfile, follow, opatterns, odefaults = o.inputfile, o.follow, o.patterns, o.defaults + if follow is None: follow = False + if odefaults is None: odefaults = True if opatterns is None: patterns = DEFAULT_PATTERNS