Exemplo n.º 1
0
import pprint
import re

def ask_user(prompt, default=None):
    while True:
        inp = raw_input(prompt).strip()
        if inp == '' and default is not None:
            return default
        if inp.lower() == 'y' or inp.lower() == 'yes':
            return True
        if inp.lower() == 'n' or inp.lower() == 'no':
            return False
        print('Sorry, response \'' + inp + '\' not understood.')


config = Config(os.path.dirname(os.path.abspath(__file__)) + '/../config')

try:
    with config.create_wiki_client('VroniPlag') as client:
        client.check_emergency()

        summary = 'PlagWiki-Bot - test von action=edit'
        for page in ('Benutzer:Kahrlbot/Test', 'Benutzer:Kahrlbot/Test2'):
            oldtext = client.get_page_text(page)
            if oldtext is None:
                print('Page does not exist: ' + page)
                oldtext = ''
            newtext = oldtext + "\nDieser Text stammt von Kahrlbot"
            print('Editing page: ' + page)
            client.check_emergency()
            client.edit(page, newtext, summary)
Exemplo n.º 2
0
                '\u2011': '---',  # non-breaking hyphen
                '\u2012': '---',  # figure dash
                '\u2013': '---',  # en dash
                '\u2014': '---',  # em dash
                '\u2015': '---',  # horizontal bar
            }
            self._fixup_pattern = re.compile('(' + '|'.join(
                re.escape(x) for x in self._fixup_dict) + ')')
            self._fixup_repl = lambda match: self._fixup_dict[match.group(1)]
        return self._fixup_pattern.sub(self._fixup_repl, text)

    def _tex_fixup_url(self, url):
        return re.sub('([%#&])', r'\\\1', url)


config = Config(os.path.dirname(os.path.abspath(__file__)) + '/../config')
page = 'Mm/Bericht-Entwurf'
#page = 'Benutzer:Kahrl/Bericht'
#page = 'Benutzer:Kahrl/Sandbox/Table'

with open('report.tex', 'w') as output_file:
    with config.create_wiki_client('VroniPlag', login=False) as client:
        output_file.write(
            """\\documentclass[ngerman,final,fontsize=12pt,paper=a4,twoside,bibliography=totoc,BCOR=8mm,draft=false]{scrartcl}

\\usepackage[T1]{fontenc}
\\usepackage{babel}
\\usepackage[utf8]{inputenx}
\\usepackage[sort&compress,square]{natbib}
\\usepackage[babel]{csquotes}
\\usepackage[hyphens]{url}
Exemplo n.º 3
0
# -*- coding: utf-8 -*-

# This bot finds all categories in VroniPlag of form <prefix>_<number>
# and removes pages from them

# ease eventual Python 3 transition
from __future__ import division, print_function, unicode_literals

import os, sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../pym')

from plagwiki.config import Config
from plagwiki.loaders.emergencyerror import EmergencyError
import pprint

config = Config(os.path.dirname(os.path.abspath(__file__)) + '/../config')

try:
    with config.create_wiki_client('GuttenPlag') as client:
        client.check_emergency()

        summary = 'PlagWiki-Bot - testing action=edit'
        for page in ('Benutzer:Kahrl/Fragment',):
            oldtext = client.get_page_text(page)
            if oldtext is None:
                print('Page does not exist: ' + page)
                oldtext = ''
            newtext = oldtext.replace('bacon', 'spam')
            print('Editing page: ' + page)
            client.check_emergency()
            client.edit(page, newtext, summary)
Exemplo n.º 4
0
# -*- coding: utf-8 -*-

# This bot finds pages that are not in the barcode.

# ease eventual Python 3 transition
from __future__ import division, print_function, unicode_literals

import os, sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../pym')

from plagwiki.config import Config
from plagwiki.loaders.emergencyerror import EmergencyError
import pprint
import re

config = Config(os.path.dirname(os.path.abspath(__file__)) + '/../config')

plagnames = []
for arg in sys.argv[1:]:
    if arg[0:1] == '-':
        print('Unknown option: ' + arg, file=sys.stdout)
        sys.exit(1)
    elif config.has_plag(arg):
        plagnames.append(arg)
    else:
        print('Unknown plag: ' + arg, file=sys.stdout)
        sys.exit(1)

try:
    for plagname in plagnames:
        print(plagname)
Exemplo n.º 5
0
                "\u2010": "---",  # hyphen
                "\u2011": "---",  # non-breaking hyphen
                "\u2012": "---",  # figure dash
                "\u2013": "---",  # en dash
                "\u2014": "---",  # em dash
                "\u2015": "---",  # horizontal bar
            }
            self._fixup_pattern = re.compile("(" + "|".join(re.escape(x) for x in self._fixup_dict) + ")")
            self._fixup_repl = lambda match: self._fixup_dict[match.group(1)]
        return self._fixup_pattern.sub(self._fixup_repl, text)

    def _tex_fixup_url(self, url):
        return re.sub("([%#&])", r"\\\1", url)


config = Config(os.path.dirname(os.path.abspath(__file__)) + "/../config")
page = "Mm/Bericht-Entwurf"
# page = 'Benutzer:Kahrl/Bericht'
# page = 'Benutzer:Kahrl/Sandbox/Table'

with open("report.tex", "w") as output_file:
    with config.create_wiki_client("VroniPlag", login=False) as client:
        output_file.write(
            """\\documentclass[ngerman,final,fontsize=12pt,paper=a4,twoside,bibliography=totoc,BCOR=8mm,draft=false]{scrartcl}

\\usepackage[T1]{fontenc}
\\usepackage{babel}
\\usepackage[utf8]{inputenx}
\\usepackage[sort&compress,square]{natbib}
\\usepackage[babel]{csquotes}
\\usepackage[hyphens]{url}