Пример #1
0
    def table_of_arguments(topic: Topic,
                           properties: list,
                           clickable_links=True):
        """
        ToDo
        Args:
            topic:
            properties:

        Returns:

        """
        formlink = Form.formlink(form=topic.name,
                                 link_text="✎",
                                 target="{{FULLPAGENAME}}",
                                 tooltip="Start editing this " + topic.name)
        table_str = "{| class='wikitable'\n! colspan=2 | " + formlink + topic.get_page_link(
        ) + "\n|-\n"
        sortBySortPos = lambda property: 99999 if "sortPos" not in property.__dict__ or property.__dict__.get(
            "sortPos") is None else int(property.sortPos)
        properties_sorted = sorted(properties, key=sortBySortPos)
        for property in properties_sorted:
            # ToDo: refactor Table definition
            label = property.get_description_page_link(
            ) if clickable_links else property.label
            table_str += "!style=\"text-align:left\" |" + label + "\n"
            table_str += "| {{#if:" + Template.template_arg(
                property.name) + "|" + Template.template_arg(
                    property.name) + "|}}\n"
            table_str += "|-\n"
        return table_str + "|}"
Пример #2
0
 def test_get_page_link(self):
     topic = Topic({"name": "Topic"})
     self.assertEqual("[[Concept:Topic|Topic]]", topic.get_page_link())
     topic.__dict__.update(pageTitle="Concept:Topic")
     self.assertEqual("[[Concept:Topic|Topic]]", topic.get_page_link())