From a6f8436ceb723e5d86b0abe47d86f0d1a1e687d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Fri, 20 Nov 2015 15:01:29 -0500 Subject: [PATCH] move toggle action to beginning of class so it can be reused --- borg/archiver.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 479d5a854..3e334ec57 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -35,6 +35,20 @@ from .remote import RepositoryServer, RemoteRepository has_lchflags = hasattr(os, 'lchflags') +class ToggleAction(argparse.Action): + """argparse action to handle "toggle" flags easily + + toggle flags are in the form of ``--foo``, ``--no-foo``. + + the ``--no-foo`` argument still needs to be passed to the + ``add_argument()`` call, but it simplifies the ``--no`` + detection. + """ + def __call__(self, parser, ns, values, option): + """set the given flag to true unless ``--no`` is passed""" + setattr(ns, self.dest, not option.startswith('--no-')) + + class Archiver: def __init__(self, verbose=False): @@ -764,19 +778,6 @@ class Archiver: See the output of the "borg help patterns" command for more help on exclude patterns. """) - class ToggleAction(argparse.Action): - """argparse action to handle "toggle" flags easily - - toggle flags are in the form of ``--foo``, ``--no-foo``. - - the ``--no-foo`` argument still needs to be passed to the - ``add_argument()`` call, but it simplifies the ``--no`` - detection. - """ - def __call__(self, parser, ns, values, option): - """set the given flag to true unless ``--no`` is passed""" - setattr(ns, self.dest, not option.startswith('--no-')) - subparser = subparsers.add_parser('create', parents=[common_parser], description=self.do_create.__doc__, epilog=create_epilog,