/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/commands.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-12 01:41:38 UTC
  • mto: (7143.16.20 even-more-cleanups)
  • mto: This revision was merged to the branch mainline in revision 7175.
  • Revision ID: jelmer@jelmer.uk-20181112014138-3b0zyx91cu3wdq3k
More PEP8 fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
import breezy
40
40
from breezy import (
41
 
    config,
42
41
    cleanup,
43
42
    cmdline,
44
43
    debug,
177
176
def register_command(cmd, decorate=False):
178
177
    """Register a plugin command.
179
178
 
180
 
    Should generally be avoided in favor of lazy registration. 
 
179
    Should generally be avoided in favor of lazy registration.
181
180
    """
182
181
    global plugin_cmds
183
182
    return plugin_cmds.register(cmd, decorate)
211
210
def _list_bzr_commands(names):
212
211
    """Find commands from bzr's core and plugins.
213
212
 
214
 
    This is not the public interface, just the default hook called by all_command_names.
 
213
    This is not the public interface, just the default hook called by
 
214
    all_command_names.
215
215
    """
216
216
    # to eliminate duplicates
217
217
    names.update(builtin_command_names())
677
677
            if line.startswith(':') and line.endswith(':') and len(line) > 2:
678
678
                save_section(sections, order, label, section)
679
679
                label, section = line[1:-1], ''
680
 
            elif (label is not None) and len(line) > 1 and not line[0].isspace():
 
680
            elif (label is not None and len(line) > 1 and
 
681
                    not line[0].isspace()):
681
682
                save_section(sections, order, label, section)
682
683
                label, section = None, line
683
684
            else:
797
798
        shell error code if not.  It's OK for this method to allow
798
799
        an exception to raise up.
799
800
 
800
 
        This method is automatically wrapped by Command.__init__ with a 
 
801
        This method is automatically wrapped by Command.__init__ with a
801
802
        cleanup operation, stored as self._operation. This can be used
802
803
        via self.add_cleanup to perform automatic cleanups at the end of
803
804
        run().
829
830
    def name(self):
830
831
        """Return the canonical name for this command.
831
832
 
832
 
        The name under which it was actually invoked is available in invoked_as.
 
833
        The name under which it was actually invoked is available in invoked_as
833
834
        """
834
835
        return _unsquish_command_name(self.__class__.__name__)
835
836
 
851
852
        notified.
852
853
        """
853
854
        Hooks.__init__(self, "breezy.commands", "Command.hooks")
854
 
        self.add_hook('extend_command',
855
 
                      "Called after creating a command object to allow modifications "
856
 
                      "such as adding or removing options, docs etc. Called with the "
857
 
                      "new breezy.commands.Command object.", (1, 13))
858
 
        self.add_hook('get_command',
859
 
                      "Called when creating a single command. Called with "
860
 
                      "(cmd_or_None, command_name). get_command should either return "
861
 
                      "the cmd_or_None parameter, or a replacement Command object that "
862
 
                      "should be used for the command. Note that the Command.hooks "
863
 
                      "hooks are core infrastructure. Many users will prefer to use "
864
 
                      "breezy.commands.register_command or plugin_cmds.register_lazy.",
865
 
                      (1, 17))
866
 
        self.add_hook('get_missing_command',
867
 
                      "Called when creating a single command if no command could be "
868
 
                      "found. Called with (command_name). get_missing_command should "
869
 
                      "either return None, or a Command object to be used for the "
870
 
                      "command.", (1, 17))
871
 
        self.add_hook('list_commands',
872
 
                      "Called when enumerating commands. Called with a set of "
873
 
                      "cmd_name strings for all the commands found so far. This set "
874
 
                      " is safe to mutate - e.g. to remove a command. "
875
 
                      "list_commands should return the updated set of command names.",
876
 
                      (1, 17))
877
 
        self.add_hook('pre_command',
878
 
                      "Called prior to executing a command. Called with the command "
879
 
                      "object.", (2, 6))
880
 
        self.add_hook('post_command',
881
 
                      "Called after executing a command. Called with the command "
882
 
                      "object.", (2, 6))
 
855
        self.add_hook(
 
856
            'extend_command',
 
857
            "Called after creating a command object to allow modifications "
 
858
            "such as adding or removing options, docs etc. Called with the "
 
859
            "new breezy.commands.Command object.", (1, 13))
 
860
        self.add_hook(
 
861
            'get_command',
 
862
            "Called when creating a single command. Called with "
 
863
            "(cmd_or_None, command_name). get_command should either return "
 
864
            "the cmd_or_None parameter, or a replacement Command object that "
 
865
            "should be used for the command. Note that the Command.hooks "
 
866
            "hooks are core infrastructure. Many users will prefer to use "
 
867
            "breezy.commands.register_command or plugin_cmds.register_lazy.",
 
868
            (1, 17))
 
869
        self.add_hook(
 
870
            'get_missing_command',
 
871
            "Called when creating a single command if no command could be "
 
872
            "found. Called with (command_name). get_missing_command should "
 
873
            "either return None, or a Command object to be used for the "
 
874
            "command.", (1, 17))
 
875
        self.add_hook(
 
876
            'list_commands',
 
877
            "Called when enumerating commands. Called with a set of "
 
878
            "cmd_name strings for all the commands found so far. This set "
 
879
            " is safe to mutate - e.g. to remove a command. "
 
880
            "list_commands should return the updated set of command names.",
 
881
            (1, 17))
 
882
        self.add_hook(
 
883
            'pre_command',
 
884
            "Called prior to executing a command. Called with the command "
 
885
            "object.", (2, 6))
 
886
        self.add_hook(
 
887
            'post_command',
 
888
            "Called after executing a command. Called with the command "
 
889
            "object.", (2, 6))
883
890
 
884
891
 
885
892
Command.hooks = CommandHooks()
905
912
    # option name is given.  See http://bugs.python.org/issue2931
906
913
    try:
907
914
        options, args = parser.parse_args(args)
908
 
    except UnicodeEncodeError as e:
 
915
    except UnicodeEncodeError:
909
916
        raise errors.BzrCommandError(
910
917
            gettext('Only ASCII permitted in option names'))
911
918
 
1007
1014
    """
1008
1015
    try:
1009
1016
        return the_callable(*args, **kwargs)
1010
 
    except (KeyboardInterrupt, Exception) as e:
 
1017
    except (KeyboardInterrupt, Exception):
1011
1018
        # used to handle AssertionError and KeyboardInterrupt
1012
1019
        # specially here, but hopefully they're handled ok by the logger now
1013
1020
        exc_info = sys.exc_info()
1090
1097
        Generate code coverage report
1091
1098
 
1092
1099
    --concurrency
1093
 
        Specify the number of processes that can be run concurrently (selftest).
 
1100
        Specify the number of processes that can be run concurrently
 
1101
        (selftest).
1094
1102
    """
1095
1103
    trace.mutter("breezy version: " + breezy.__version__)
1096
1104
    argv = _specified_or_unicode_argv(argv)
1285
1293
    """Run a bzr command with parameters as described by argv.
1286
1294
 
1287
1295
    This function assumed that that UI layer is setup, that symbol deprecations
1288
 
    are already applied, and that unicode decoding has already been performed on argv.
 
1296
    are already applied, and that unicode decoding has already been performed
 
1297
    on argv.
1289
1298
    """
1290
1299
    # done here so that they're covered for every test run
1291
1300
    install_bzr_command_hooks()