Exemple #1
0
def store_list(directory):
    """List known Stores."""
    context = toolkit.load_data_context_with_error_handling(directory)

    try:
        stores = context.list_stores()

        if len(stores) == 0:
            cli_message("No Stores found")
            send_usage_message(data_context=context,
                               event="cli.store.list",
                               success=True)
            return
        elif len(stores) == 1:
            list_intro_string = "1 Store found:"
        else:
            list_intro_string = "{} Stores found:".format(len(stores))

        cli_message(list_intro_string)

        for store in stores:
            cli_message("")
            cli_message_dict(store)

        send_usage_message(data_context=context,
                           event="cli.store.list",
                           success=True)
    except Exception as e:
        send_usage_message(data_context=context,
                           event="cli.store.list",
                           success=False)
        raise e
def validation_operator_list(directory):
    """List known Validation Operators."""
    try:
        context = DataContext(directory)
    except ge_exceptions.ConfigNotFoundError as err:
        cli_message("<red>{}</red>".format(err.message))
        return

    try:
        validation_operators = context.list_validation_operators()

        if len(validation_operators) == 0:
            cli_message("No Validation Operators found")
            return
        elif len(validation_operators) == 1:
            list_intro_string = "1 Validation Operator found:"
        else:
            list_intro_string = "{} Validation Operators found:".format(
                len(validation_operators))

        cli_message(list_intro_string)
        for validation_operator in validation_operators:
            cli_message("")
            cli_message_dict(validation_operator)
        send_usage_message(data_context=context,
                           event="cli.validation_operator.list",
                           success=True)
    except Exception as e:
        send_usage_message(data_context=context,
                           event="cli.validation_operator.list",
                           success=False)
        raise e
def store_list(directory):
    """List known Stores."""
    try:
        context = DataContext(directory)
    except ge_exceptions.ConfigNotFoundError as err:
        cli_message("<red>{}</red>".format(err.message))
        return

    try:
        stores = context.list_stores()

        if len(stores) == 0:
            cli_message("No Stores found")
            send_usage_message(data_context=context,
                               event="cli.store.list",
                               success=True)
            return

        if len(stores) == 1:
            list_intro_string = "1 Store found:"

        if len(stores) > 1:
            list_intro_string = "{} Stores found:".format(len(stores))

        cli_message(list_intro_string)

        for store in stores:
            cli_message("")
            cli_message_dict(store)

        send_usage_message(data_context=context,
                           event="cli.store.list",
                           success=True)
    except Exception as e:
        send_usage_message(data_context=context,
                           event="cli.store.list",
                           success=False)
        raise e