예제 #1
0
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)

except(EmergencyError) as err:
    print(err)
예제 #2
0
            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}
\\usepackage[draft=false,final,plainpages=false,pdftex]{hyperref}
\\usepackage{eso-pic}
\\usepackage{fixltx2e}
\\usepackage{graphicx}
\\usepackage{xcolor}
\\usepackage{pdflscape}
예제 #3
0
# 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)

except(EmergencyError) as err:
    print(err)
예제 #4
0
def remove_category_plb(oldtext, fulltitle):
    def repl(match):
        if match.group(1) and match.group(2):
            return match.group(2)
        else:
            return ''

    return re.sub(
        '((?:
)?)\[\[' + fulltitle.replace(' ', '[ _]') +
        '\]\]((?:
)?)', repl, oldtext)


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

try:
    with config.create_wiki_client('VroniPlag') as client:
        client.check_emergency()
        #all_categories_info = client.get_all_categories_info()
        all_categories_info = client.get_all_categories_info('Mm')
        for categoryinfo in all_categories_info:
            client.check_emergency()

            # Check category title
            fulltitle = categoryinfo['title']
            title = client.split_name(categoryinfo['title'])[1]
            if not re.match('^[A-Za-z]{2,3} [0-9]{1,3}$', title):
                continue

            # Check category size
            if categoryinfo['categoryinfo']['size'] == 0:
                if 'missing' not in categoryinfo:
예제 #5
0
            }
            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}
\\usepackage[draft=false,final,plainpages=false,pdftex]{hyperref}
\\usepackage{eso-pic}
\\usepackage{fixltx2e}
\\usepackage{graphicx}
\\usepackage{xcolor}
\\usepackage{pdflscape}