Exemple #1
0
 def test_get_str(self):
     handler = TemplateHandler()
     handler.set_title(test_title)
     handler.update_parameters(test_list_12)
     self.assertEqual(test_string_12_simple,
                      handler.get_str(str_complex=False))
     self.assertEqual(test_string_12_complex,
                      handler.get_str(str_complex=True))
Exemple #2
0
def substitute_sperrsatz(template):
    handler = TemplateHandler(template.group(0))
    handler.set_title('SperrSchrift')
    parameters = handler.get_parameterlist()
    parameters.append({'key': 'satz', 'value': '1'})
    handler.update_parameters(parameters)
    return handler.get_str(str_complex=False)
Exemple #3
0
 def test_set_title(self):
     test_string_12_test_title = "{{" + test_title_test + "|" \
                                 + test_string_argument_1 + "|" \
                                 + test_string_argument_2 + "}}"
     handler = TemplateHandler(test_string_12_simple)
     handler.set_title(test_title_test)
     self.assertEqual(test_string_12_test_title,
                      handler.get_str(str_complex=False))
 def test_update_parameters(self):
     test_string_345_simple = "{{" + test_title + "|" + test_string_argument_3 + "|" + test_string_argument_4 + "|" + test_string_argument_5 + "}}"
     test_list_345 = [test_dict_argument_3, test_dict_argument_4, test_dict_argument_5]
     handler = TemplateHandler(test_string_12_simple)
     self.assertEqual(test_dict_argument_1, handler.get_parameter("1"))
     self.assertEqual(test_dict_argument_2, handler.get_parameter("2"))
     handler.update_parameters(test_list_345)
     self.assertEqual(test_string_345_simple, handler.get_str(str_complex=False))
    def convert_re_platzhalter(self, template: str):
        template_platzhalter = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_platzhalter.get_parameterlist()
        new_list = self._gemeinfrei_todesjahr(new_list)
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
    def convert_re_nachtrag(template: str):
        template_nachtrag = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_nachtrag.get_parameterlist()
        new_list.append({"key": "NACHTRAG", "value": "ON"})
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
Exemple #7
0
    def convert_re_nachtrag(template: str):
        template_nachtrag = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_nachtrag.get_parameterlist()
        new_list.append({"key": "NACHTRAG", "value": "ON"})
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
Exemple #8
0
 def _get_pre_text(self):
     template_handler = TemplateHandler()
     template_handler.title = RE_DATEN
     list_of_properties = []
     for re_property in self._properties:
         list_of_properties.append({"key": re_property.name,
                                    "value": re_property.value_to_string()})
     template_handler.update_parameters(list_of_properties)
     return template_handler.get_str(str_complex=True)
Exemple #9
0
    def convert_re_platzhalter(self, template: str):
        template_platzhalter = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_platzhalter.get_parameterlist()
        new_list = self._gemeinfrei_todesjahr(new_list)
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
Exemple #10
0
    def convert_re_nachtrag_platzhalter(self, template: str):
        template_platzhalter = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_platzhalter.get_parameterlist()
        new_list.append({"key": "NACHTRAG", "value": "ON"})
        new_list = self._gemeinfrei_todesjahr(new_list)
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
    def convert_re_nachtrag_platzhalter(self, template: str):
        template_platzhalter = TemplateHandler(template)
        template_daten = TemplateHandler()
        new_list = template_platzhalter.get_parameterlist()
        new_list.append({"key": "NACHTRAG", "value": "ON"})
        new_list = self._gemeinfrei_todesjahr(new_list)
        template_daten.update_parameters(new_list)
        template_daten.set_title("REDaten")

        return template_daten.get_str()
Exemple #12
0
 def _get_pre_text(self):
     template_handler = TemplateHandler()
     template_handler.title = RE_DATEN
     list_of_properties = []
     for re_property in self._properties:
         list_of_properties.append({
             "key": re_property.name,
             "value": re_property.value_to_string()
         })
     template_handler.update_parameters(list_of_properties)
     return template_handler.get_str(str_complex=True)
Exemple #13
0
 def test_update_parameters(self):
     test_string_345_simple = "{{" + test_title + "|" \
                              + test_string_argument_3 + "|" \
                              + test_string_argument_4 + "|" \
                              + test_string_argument_5 + "}}"
     test_list_345 = [
         test_dict_argument_3, test_dict_argument_4, test_dict_argument_5
     ]
     handler = TemplateHandler(test_string_12_simple)
     self.assertEqual(test_dict_argument_1, handler.get_parameter("1"))
     self.assertEqual(test_dict_argument_2, handler.get_parameter("2"))
     handler.update_parameters(test_list_345)
     self.assertEqual(test_string_345_simple,
                      handler.get_str(str_complex=False))
Exemple #14
0
    }, {
        "key": "KAPITEL",
        "value": "{}.".format(titles[idx])
    }, {
        "key":
        "VORIGER",
        "value":
        "[[../{}|{}.]]".format(titles[idx - 1], titles[idx - 1])
    }, {
        "key":
        "NÄCHSTER",
        "value":
        "[[../{}|{}.]]".format(titles[idx + 1], titles[idx + 1])
    }, {
        "key": "JAHR",
        "value": "1658"
    }, {
        "key": "ANMERKUNG",
        "value": ""
    }, {
        "key": "STATUS",
        "value": status
    }]

    handler.set_title("Navigation2")
    handler.update_parameters(parameter_dict)
    page.text = handler.get_str(
    ) + '\n__notoc__\n\n<pages index="Orbis sensualium pictus" from=OrbisPictus_{}.jpg to=OrbisPictus_{}.jpg />\n\n[[Kategorie:Orbis sensualium pictus]]'.format(
        add_zeros(i, 3), add_zeros(i + 1, 3))

    page.save(summary="automatische Seitenerstellung", botflag=True)
    'key':
    'ARTIKEL',
    'value':
    '[[Venus Urania. Ueber die Natur der Liebe, über ihre Veredelung und Verschönerung|Venus Urania]]'
})
list_navigation.append({'key': 'KAPITEL', 'value': list_textdaten[3]['value']})
list_navigation.append({'key': 'VORIGER', 'value': list_textdaten[0]['value']})
list_navigation.append({
    'key': 'NÄCHSTER',
    'value': list_textdaten[1]['value']
})
list_navigation.append({'key': 'STATUS', 'value': 'fertig'})

list_nav_reduce = copy.deepcopy(list_navigation)
list_nav_reduce.pop(0)
list_nav_reduce.pop(0)
list_nav_reduce.pop(0)
list_nav_reduce.pop(2)
list_nav_reduce.append({'key': 'TOP', 'value': 'x'})

template_navigation1.update_parameters(list_navigation)
template_navigation2.update_parameters(list_nav_reduce)

print(page.text)

page.text = re.sub('\{\{Textdaten(?:\{\{.*?\}\}|.)*?\}\}',
                   template_navigation1.get_str(), page.text)
page.text = page.text + template_navigation2.get_str()

pass
 def test_set_title(self):
     test_string_12_test_title = "{{" + test_title_test + "|" + test_string_argument_1 + "|" + test_string_argument_2 + "}}"
     handler = TemplateHandler(test_string_12_simple)
     handler.set_title(test_title_test)
     self.assertEqual(test_string_12_test_title, handler.get_str(str_complex=False))
    first_page = proofreadpage.ProofreadPage(site, "Seite:OrbisPictus {}.jpg".format(add_zeros(i, 3)))
    second_page = proofreadpage.ProofreadPage(site, "Seite:OrbisPictus {}.jpg".format(add_zeros(i + 1, 3)))

    status_1 = first_page.status
    status_2 = second_page.status

    if status_1 == "Fertig" and status_2 == "Fertig":
        status = "Fertig"
    elif status_1 == "Unkorrigiert" or status_2 == "Unkorrigiert":
        status = "Unkorrigiert"
    else:
        status = "Korrigiert"

    print(status_1, status_2, status)

    parameter_dict = [{"key": "AUTOR", "value": "[[Johann Amos Comenius]]"},
                      {"key": "ÜBERSETZER", "value": ""},
                      {"key": "ARTIKEL", "value": "[[Orbis sensualium pictus]]"},
                      {"key": "KAPITEL", "value": "{}.".format(titles[idx])},
                      {"key": "VORIGER", "value": "[[../{}|{}.]]".format(titles[idx - 1], titles[idx - 1])},
                      {"key": "NÄCHSTER", "value": "[[../{}|{}.]]".format(titles[idx + 1], titles[idx + 1])},
                      {"key": "JAHR", "value": "1658"},
                      {"key": "ANMERKUNG", "value": ""},
                      {"key": "STATUS", "value": status}]

    handler.set_title("Navigation2")
    handler.update_parameters(parameter_dict)
    page.text = handler.get_str() + '\n__notoc__\n\n<pages index="Orbis sensualium pictus" from=OrbisPictus_{}.jpg to=OrbisPictus_{}.jpg />\n\n[[Kategorie:Orbis sensualium pictus]]'.format(add_zeros(i, 3), add_zeros(i + 1, 3))

    page.save(summary= "automatische Seitenerstellung", botflag= True)
 def test_get_str(self):
     handler = TemplateHandler()
     handler.set_title(test_title)
     handler.update_parameters(test_list_12)
     self.assertEqual(test_string_12_simple, handler.get_str(str_complex=False))
     self.assertEqual(test_string_12_complex, handler.get_str(str_complex=True))