Normalize article titles with anchors

In our db article titles with anchors are stored with underscores in
anchor string. Therefore we need to replace spaces in anchor string
given by pywikibot.Page.title().

Related Task: [FS#151](https://fs.golderweb.de/index.php?do=details&task_id=151)
This commit is contained in:
2017-08-25 18:11:41 +02:00
parent 49a8230d76
commit 8a26b6d92a

View File

@@ -186,25 +186,32 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat()
# None if change was not accepted by user # None if change was not accepted by user
save_ret = self.put_current( self.new_text, summary=summary ) save_ret = self.put_current( self.new_text, summary=summary )
# Normalize title with anchor (replace spaces in anchor)
article = self.current_page.title(withNamespace=False)
article_parts = article.split("#", 1)
if len(article_parts) == 2:
article_parts[1] = article_parts[1].replace(" ", "_")
article = "#".join(article_parts)
# Status # Status
if add_ret is None or ( add_ret and save_ret ): if add_ret is None or ( add_ret and save_ret ):
self.current_page.redfam.article_remove_status( self.current_page.redfam.article_remove_status(
"note_rej", "note_rej",
title=self.current_page.title(withNamespace=False)) title=article)
self.current_page.redfam.article_remove_status( self.current_page.redfam.article_remove_status(
"sav_err", "sav_err",
title=self.current_page.title(withNamespace=False)) title=article)
self.current_page.redfam.article_add_status( self.current_page.redfam.article_add_status(
"marked", "marked",
title=self.current_page.title(withNamespace=False)) title=article)
elif save_ret is None: elif save_ret is None:
self.current_page.redfam.article_add_status( self.current_page.redfam.article_add_status(
"note_rej", "note_rej",
title=self.current_page.title(withNamespace=False)) title=article)
else: else:
self.current_page.redfam.article_add_status( self.current_page.redfam.article_add_status(
"sav_err", "sav_err",
title=self.current_page.title(withNamespace=False)) title=article)
def add_disc_notice_template( self ): def add_disc_notice_template( self ):
""" """