Beispiel #1
0
 def title(self) -> str:
     rsc_type = self._relation_entity.type
     metadata = self._relation_entity.metadata
     if rsc_type == "primitive":
         rsc_type = "{_class}{_provider}{_type}".format(
             _class=format_optional(metadata.get("class"), "{}:"),
             _provider=format_optional(metadata.get("provider"), "{}:"),
             _type=metadata.get("type"),
         )
     return f"{self._relation_entity.id} (resource: {rsc_type})"
Beispiel #2
0
 def get_title(self, verbose: bool) -> str:
     rsc_type = self._relation_entity.type
     metadata = self._relation_entity.metadata
     if rsc_type == "primitive":
         rsc_type = "{_class}{_provider}{_type}".format(
             _class=format_optional(metadata.get("class"), "{}:"),
             _provider=format_optional(metadata.get("provider"), "{}:"),
             _type=metadata.get("type"),
         )
     detail = f" (resource: {rsc_type})" if verbose else ""
     return f"{self._relation_entity.id}{detail}"
Beispiel #3
0
def booth_config_accepted_by_node(info):
    desc = ""
    if info["name_list"] and info["name_list"] not in [["booth"]]:
        desc = "{_s} {_list}".format(
            _s=("s" if len(info["name_list"]) > 1 else ""),
            _list=format_list(info["name_list"]))
    return "{_node_info}Booth config{_desc} saved".format(
        _node_info=format_optional(info["node"], "{0}: "),
        _desc=desc,
    )
Beispiel #4
0
def booth_config_accepted_by_node(info):
    desc = ""
    if info["name_list"] and info["name_list"] not in [["booth"]]:
        desc = "{_s} {_list}".format(
            _s=("s" if len(info["name_list"]) > 1 else ""),
            _list=format_list(info["name_list"])
        )
    return "{_node_info}Booth config{_desc} saved".format(
        _node_info=format_optional(info["node"], "{0}: "),
        _desc=desc,
    )
Beispiel #5
0
 def test_info_key_is_not_falsy(self):
     self.assertEqual("A: ", format_optional("A", "{0}: "))
Beispiel #6
0
 def test_default_value(self):
     self.assertEqual("DEFAULT", format_optional("", "{0}: ", "DEFAULT"))
Beispiel #7
0
    ,

    codes.BOOTH_EVEN_PEERS_NUM: lambda info:
        "odd number of peers is required (entered {number} peers)"
        .format(**info)
    ,

    codes.BOOTH_ADDRESS_DUPLICATION: lambda info:
        "duplicate address for booth configuration: {0}"
        .format(", ".join(info["addresses"]))
    ,

    codes.BOOTH_CONFIG_UNEXPECTED_LINES: lambda info:
        "unexpected {_line_pl} in booth config{_file_path}:\n{_line_list}"
        .format(
            _file_path=format_optional(info["file_path"], " '{0}'"),
            _line_pl=format_plural(info["line_list"], "line"),
            _line_list="\n".join(info["line_list"]),
            **info
        )
    ,

    codes.BOOTH_INVALID_NAME: lambda info:
        "booth name '{name}' is not valid ({reason})"
        .format(**info)
    ,

    codes.BOOTH_TICKET_NAME_INVALID: lambda info:
        "booth ticket name '{0}' is not valid, use alphanumeric chars or dash"
        .format(info["ticket_name"])
    ,
 def test_default_value(self):
     self.assertEqual("DEFAULT", format_optional("", "{0}: ", "DEFAULT"))
 def test_info_key_is_not_falsy(self):
     self.assertEqual("A: ", format_optional("A", "{0}: "))