<commit_before># -*- coding: utf-8 -*-
__author__ = 'eso'
import sys
sys.path.append('../../')
from tools.catscan import CatScan
from tools.template_handler import TemplateHandler
import re
import requests
import pywikibot

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)


searcher_catscan = CatScan()
searcher_catscan.add_namespace(0)
searcher_catscan.add_namespace('Seite')
searcher_catscan.add_yes_template('Sperrsatz')
sites = searcher_catscan.run()
site = pywikibot.Site()

for lemma in sites:
    if lemma['a']['nstext'] == '(Article)':
        page = pywikibot.Page(site, lemma['a']['title'])
    else:
        page = pywikibot.Page(site, lemma['a']['nstext'] + ':' + lemma['a']['title'])
    test_for_fit = re.search('Sperrsatz', page.text)
    if test_for_fit:
        page.text = re.sub('\{\{Sperrsatz(?:\{\{.*?\}\}|.)*?\}\}', substitute_sperrsatz, page.text)
        page.save(summary='bot edit: Vereinheitlichung der Vorlage Sperrsatz zu SperrSchrift', botflag=True, )<commit_msg>some fixes in der SperrSatz-Ersetzung<commit_after># -*- coding: utf-8 -*-
__author__ = 'eso'
import sys
sys.path.append('../../')
from tools.catscan import CatScan
from tools.template_handler import TemplateHandler
import re
import requests
import pywikibot

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)


searcher_catscan = CatScan()
searcher_catscan.add_namespace(0)
searcher_catscan.add_namespace('Seite')
searcher_catscan.add_namespace('Index')
searcher_catscan.add_yes_template('Sperrsatz')
sites = searcher_catscan.run()
site = pywikibot.Site()

for lemma in sites:
    if lemma['a']['nstext'] == '(Article)':
        page = pywikibot.Page(site, lemma['a']['title'])
    else:
        page = pywikibot.Page(site, lemma['a']['nstext'] + ':' + lemma['a']['title'])
    test_for_fit = re.search('Sperrsatz', page.text)
    if test_for_fit:
        try:
            page.text = re.sub('\{\{Sperrsatz(?:\{\{.*?\}\}|.)*?\}\}', substitute_sperrsatz, page.text)
            page.save(summary='bot edit: Vereinheitlichung der Vorlage Sperrsatz zu SperrSchrift', botflag=True, )
        except:
            print(lemma)
{'fraction_non_alphanumeric': 0.16021260440394836, 'fraction_numerical': 0.0030372057706909645, 'mean_word_length': 4.5473684210526315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1555223', 'n_tokens_mistral': 903, 'n_tokens_neox': 905, 'n_words': 164}