示例#1
0
def pformat_all_layers(config, sections=None):
    # type: (DbndConfig, Optional[Iterable[str]]) -> str
    tb = TextBanner("Configs")

    layers = config.config_layer.get_all_layers()

    # start from the first one
    for layer in reversed(layers):
        layer_values = layer.layer_config.as_value_dict(sections=sections)
        tb.column("LAYER {}".format(layer.config_layer_path),
                  tb.f_struct(layer_values))
    return tb.get_banner_str()
示例#2
0
def pformat_current_config(config, as_table=False, sections=None):
    # type: (DbndConfig, bool, Optional[Iterable[str]]) -> str
    config_layer = config.config_layer
    tb = TextBanner("Config {}".format(config_layer.name))
    tb.column("LAYERS", config_layer.config_layer_path)
    if as_table:
        view_str = pformat_config_store_as_table(
            config_store=config_layer.config, sections=sections)
    else:
        value_dict = config_layer.config.as_value_dict(sections=sections)
        view_str = tb.f_struct(value_dict)

    tb.column("CONFIG", view_str)
    return tb.get_banner_str()