DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


from __future__ import absolute_import, unicode_literals


class CommandContext(object):
    """Holds run-time state so it can easily be passed to command providers."""
    """Holds run-time state so it can easily be passed to command providers."""
    def __init__(self, cwd=None, settings=None, log_manager=None, commands=None, **kwargs):
        self.cwd = cwd
        self.settings = settings
        self.log_manager = log_manager
        self.commands = commands
        self.commands = commands
        self.command_attrs = {}

        for k, v in kwargs.items():
            setattr(self, k, v)



class MachError(Exception):
class MachError(Exception):
    """Base class for all errors raised by mach itself."""


class NoCommandError(MachError):
class NoCommandError(MachError):
    """No command was passed into mach."""

    def __init__(self, namespace):
        MachError.__init__(self)
        self.namespace = namespace
        self.namespace = namespace


class UnknownCommandError(MachError):
    """Raised when we attempted to execute an unknown command."""


    def __init__(self, command, verb, suggested_commands=None):
        MachError.__init__(self)

        self.command = command
        self.verb = verb
        self.verb = verb
        self.suggested_commands = suggested_commands or []


class UnrecognizedArgumentError(MachError):
    """Raised when an unknown argument is passed to mach."""


    def __init__(self, command, arguments):
        MachError.__init__(self)

        self.command = command
        self.arguments = arguments
        self.arguments = arguments


class FailedCommandError(Exception):
    """Raised by commands to signal a handled failure to be printed by mach


    When caught by mach a FailedCommandError will print message and exit
    with ''exit_code''. The optional ''reason'' is a string in cases where
    other scripts may wish to handle the exception, though this is generally
    intended to communicate failure to mach.
    """
    """

    def __init__(self, message, exit_code=1, reason=''):
        Exception.__init__(self, message)
        self.exit_code = exit_code
        self.reason = reason
        self.reason = reason


class MissingFileError(MachError):
class MissingFileError(MachError):
    """Attempted to load a mach commands file that doesn't exist."""