Use jogobot-framework as submodule to get a specific state (instead of directly use development dir as python module)

Use jogobot.output as wrapper for pywikiot outputs
This commit is contained in:
2016-02-19 16:10:16 +01:00
parent 287942e174
commit 3ed67431cf
3 changed files with 23 additions and 14 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "jogobot"]
path = jogobot
url = ../jogobot

View File

@@ -50,6 +50,8 @@ import locale
import pywikibot import pywikibot
from pywikibot import pagegenerators from pywikibot import pagegenerators
import jogobot
from summarypage import SummaryPage from summarypage import SummaryPage
# This is required for the text that is shown when you run this script # This is required for the text that is shown when you run this script
@@ -87,6 +89,9 @@ class ChartsBot( ):
# Force parsing of countrylist # Force parsing of countrylist
self.force_reload = force_reload self.force_reload = force_reload
# Output Information
jogobot.output( "Chartsbot invoked" )
# Set the edit summary message # Set the edit summary message
self.site = pywikibot.Site() self.site = pywikibot.Site()
self.summary = "Bot: Aktualisiere Übersichtsseite Nummer-eins-Hits" self.summary = "Bot: Aktualisiere Übersichtsseite Nummer-eins-Hits"
@@ -126,7 +131,7 @@ class ChartsBot( ):
text = sumpage.get_new_text() text = sumpage.get_new_text()
if not self.save(text, page, self.summary, False): if not self.save(text, page, self.summary, False):
pywikibot.output(u'Page %s not saved.' % page.title(asLink=True)) jogobot.output(u'Page %s not saved.' % page.title(asLink=True))
def load(self, page): def load(self, page):
"""Load the text of the given page.""" """Load the text of the given page."""
@@ -134,11 +139,11 @@ class ChartsBot( ):
# Load the page # Load the page
text = page.get() text = page.get()
except pywikibot.NoPage: except pywikibot.NoPage:
pywikibot.output(u"Page %s does not exist; skipping." jogobot.output( u"Page %s does not exist; skipping."
% page.title(asLink=True)) % page.title(asLink=True), "ERROR" )
except pywikibot.IsRedirectPage: except pywikibot.IsRedirectPage:
pywikibot.output(u"Page %s is a redirect; skipping." jogobot.output( u"Page %s is a redirect; skipping."
% page.title(asLink=True)) % page.title(asLink=True), "ERROR" )
else: else:
return text return text
return None return None
@@ -154,11 +159,11 @@ class ChartsBot( ):
# Show the title of the page we're working on. # Show the title of the page we're working on.
# Highlight the title in purple. # Highlight the title in purple.
pywikibot.output( u"\n\n>>> \03{lightpurple}%s\03{default} <<<" jogobot.output( u">>> \03{lightpurple}%s\03{default} <<<"
% page.title()) % page.title())
# show what was changed # show what was changed
pywikibot.showDiff(page.get(), text) pywikibot.showDiff(page.get(), text)
pywikibot.output(u'Comment: %s' % comment) jogobot.output(u'Comment: %s' % comment)
if self.always or pywikibot.input_yn( if self.always or pywikibot.input_yn(
u'Do you want to accept these changes?', u'Do you want to accept these changes?',
@@ -169,17 +174,17 @@ class ChartsBot( ):
page.save(summary=comment or self.comment, page.save(summary=comment or self.comment,
minor=minorEdit, botflag=botflag) minor=minorEdit, botflag=botflag)
except pywikibot.LockedPage: except pywikibot.LockedPage:
pywikibot.output(u"Page %s is locked; skipping." jogobot.output( u"Page %s is locked; skipping."
% page.title(asLink=True)) % page.title(asLink=True), "ERROR" )
except pywikibot.EditConflict: except pywikibot.EditConflict:
pywikibot.output( jogobot.output(
u'Skipping %s because of edit conflict' u'Skipping %s because of edit conflict'
% (page.title())) % (page.title()), "ERROR")
except pywikibot.SpamfilterError as error: except pywikibot.SpamfilterError as error:
pywikibot.output( jogobot.output(
u'Cannot change %s because of spam blacklist \ u'Cannot change %s because of spam blacklist \
entry %s' entry %s'
% (page.title(), error.url)) % (page.title(), error.url), "ERROR")
else: else:
return True return True
return False return False

1
jogobot Submodule

Submodule jogobot added at 3721683a28