Beispiel #1
0
def command(view, name):
    """Edit commander command: edit.command <command>"""
    parts = name.split('.')

    for mod in sys.modules:
        if commands.is_commander_module(sys.modules[mod]) and (mod == parts[0] or _mod_has_alias(sys.modules[mod], parts[0])):
            if mod == parts[0]:
                ret = _resume_command(view, sys.modules[mod], parts[1:])
            else:
                ret = _resume_command(view, sys.modules[mod], parts)

            if not ret:
                raise commander.commands.exceptions.Execute('Could not find command: ' + name)
            else:
                return commander.commands.result.HIDE

    raise commander.commands.exceptions.Execute('Could not find command: ' + name)
Beispiel #2
0
def command(view, name):
    """Edit commander command: edit.command <command>"""
    parts = name.split('.')

    for mod in sys.modules:
        if commands.is_commander_module(sys.modules[mod]) and (mod == parts[0] or _mod_has_alias(sys.modules[mod], parts[0])):
            if mod == parts[0]:
                ret = _resume_command(view, sys.modules[mod], parts[1:])
            else:
                ret = _resume_command(view, sys.modules[mod], parts)

            if not ret:
                raise commander.commands.exceptions.Execute('Could not find command: ' + name)
            else:
                return commander.commands.result.HIDE

    raise commander.commands.exceptions.Execute('Could not find command: ' + name)
Beispiel #3
0
def _resume_command(view, mod, parts):
    if not parts:
        return _edit_command(view, mod)

    func = parts[0].replace('-', '_')

    if len(parts) == 1 and _mod_has_func(mod, func):
        return _edit_command(view, mod, mod.__dict__[func])
    elif len(parts) == 1 and _mod_has_alias(mod, parts[0]):
        return _edit_command(view, mod)

    if not func in mod.__dict__:
        return False

    if not commands.is_commander_module(mod.__dict__[func]):
        return False

    return _resume_command(view, mod.__dict__[func], parts[1:])
Beispiel #4
0
def _resume_command(view, mod, parts):
    if not parts:
        return _edit_command(view, mod)

    func = parts[0].replace('-', '_')

    if len(parts) == 1 and _mod_has_func(mod, func):
        return _edit_command(view, mod, mod.__dict__[func])
    elif len(parts) == 1 and _mod_has_alias(mod, parts[0]):
        return _edit_command(view, mod)

    if not func in mod.__dict__:
        return False

    if not commands.is_commander_module(mod.__dict__[func]):
        return False

    return _resume_command(view, mod.__dict__[func], parts[1:])