Beispiel #1
0
def nvset_dto_to_lines(nvset: CibNvsetDto,
                       with_ids: bool = False) -> List[str]:
    nvset_label = _nvset_type_to_label.get(nvset.type, "Options Set")
    heading_parts = [f"{nvset_label}: {nvset.id}"]
    if nvset.options:
        heading_parts.append(" ".join(
            format_name_value_list(sorted(nvset.options.items()))))

    lines = format_name_value_list(
        sorted([(nvpair.name, nvpair.value) for nvpair in nvset.nvpairs]))
    if nvset.rule:
        lines.extend(
            rule_expression_dto_to_lines(nvset.rule, with_ids=with_ids))

    return [" ".join(heading_parts)] + indent(lines)
Beispiel #2
0
def nvset_dto_to_lines(nvset: CibNvsetDto,
                       nvset_label: str = "Options Set",
                       with_ids: bool = False) -> List[str]:
    in_effect_label = get_in_effect_label(nvset.rule) if nvset.rule else None
    heading_parts = [
        "{label}{in_effect}:{id}".format(
            label=nvset_label,
            in_effect=format_optional(in_effect_label, " ({})"),
            id=format_optional(nvset.id, " {}"),
        )
    ]
    if nvset.options:
        heading_parts.append(" ".join(
            format_name_value_list(sorted(nvset.options.items()))))

    lines = format_name_value_list(
        sorted([(nvpair.name, nvpair.value) for nvpair in nvset.nvpairs]))
    if nvset.rule:
        lines.extend(
            rule_expression_dto_to_lines(nvset.rule, with_ids=with_ids))

    return [" ".join(heading_parts)] + indent(lines)
Beispiel #3
0
 def _export(dto, with_ids):
     return (
         "\n".join(rule.rule_expression_dto_to_lines(dto, with_ids=with_ids))
         + "\n"
     )