Beispiel #1
0
def get_routes():
    """
    This function contains the dictionary of possible commands.
    :return: `dict` of possible commands, with the format: `name -> class`
    """

    # Dynamic load:
    # def class_filter(klass):
    #     return inspect.isclass(klass) \
    #            and klass.__module__ == BaseCommand.__module__ \
    #            and issubclass(klass, BaseCommand) \
    #            and klass is not BaseCommand
    #
    # routes = inspect.getmembers(
    #     sys.modules[BaseCommand.__module__],
    #     class_filter
    # )
    # return dict((route.label(), route) for _, route in routes)

    return {
        ListCommand.label(): ListCommand,
        DoneCommand.label(): DoneCommand,
        UndoneCommand.label(): UndoneCommand,
        NewCommand.label(): NewCommand,
        ExitCommand.label(): ExitCommand,
    }
Beispiel #2
0
def get_routes():
    return {
        ListCommand.label(): ListCommand,
        NewCommand.label(): NewCommand,
        DoneCommand.label(): DoneCommand,
        UndoneCommand.label(): UndoneCommand,
        ExitCommand.label(): ExitCommand,
    }
Beispiel #3
0
def get_routes():
    """`Эта функция содержит словарь возможных команд.
    Возвращает словарь возможных команд в формате:` name -> class`
    """
    return {
        ListCommand.label(): ListCommand,
        NewCommand.label(): NewCommand,
        DoneCommand.label(): DoneCommand,
        UndoneCommand.label(): UndoneCommand,
        ExitCommand.label(): ExitCommand,
    }
Beispiel #4
0
def get_routes():
    """
    This function contains the dictionary of possible commands.
    :return: `dict` of possible commands, with the format: `name -> class`
    """

    return {
        ListCommand.label(): ListCommand,
        NewCommand.label(): NewCommand,
        DoneCommand.label(): DoneCommand,
        UndoneCommand.label(): UndoneCommand,
        ExitCommand.label(): ExitCommand,
    }
Beispiel #5
0
def parse_user_input():

    input_function = input

    message = 'Input your command: (%s): ' % '|'.join(
        {
            ListCommand.label(): ListCommand,
            NewCommand.label(): NewCommand,
            DoneCommand.label(): DoneCommand,
            UndoneCommand.label(): UndoneCommand,
            ExitCommand.label(): ExitCommand,
        }.keys())
    return input_function(message)
Beispiel #6
0
def parse_user_input():
    """
    Gets the user input.
    :return: `str` with the user input.
    """

    input_function = input

    message = 'Input your command: (%s): ' % '|'.join(
        {
            ListCommand.label(): ListCommand,
            NewCommand.label(): NewCommand,
            ExitCommand.label(): ExitCommand,
        }.keys())
    return input_function(message)
Beispiel #7
0
def parse_user_input():
    """
    Получает пользовательский ввод.
    Возвращает: строку с пользовательским вводом.
    """
    input_function = input

    message = 'Input your command: (%s): ' % '|'.join(
        {
            ListCommand.label(): ListCommand,
            NewCommand.label(): NewCommand,
            DoneCommand.label(): DoneCommand,
            UndoneCommand.label(): UndoneCommand,
            ExitCommand.label(): ExitCommand,
        }.keys())
    return input_function(message)
def get_routes():
    # Dynamic load
    # def class_filter(klass):
    #     return inspect.isclass(klass) \
    #            and klass.__module__ == BaseCommand.__module__ \
    #            and issubclass(klass, BaseCommand) \
    #            and klass is not BaseCommand

    # routes = inspect.getmembers(
    #     sys.modules[BaseCommand.__module__],
    #     class_filter
    # )
    # return dict((route.label(), route) for _, route in routes)

    from commands import ListCommand, NewCommand, ExitCommand
    return {
        ListCommand.label(): ListCommand,
        NewCommand.label(): NewCommand,
        ExitCommand.label(): ExitCommand,
        # DoneCommand.label(): DoneCommand,
    }