Skip to content
Snippets Groups Projects
Commit 5d2eeb1e authored by Magnus Giesbert's avatar Magnus Giesbert
Browse files

Update wikibot.py

parent f9f30d5a
No related branches found
No related tags found
No related merge requests found
...@@ -12,10 +12,10 @@ def move_page(original_page, new_page, delete=False): ...@@ -12,10 +12,10 @@ def move_page(original_page, new_page, delete=False):
proxy.wiki.putPage(new_page, page_content, {"sum":"Moved from " + original_page}) proxy.wiki.putPage(new_page, page_content, {"sum":"Moved from " + original_page})
# update back links to new page # # update back links to new page #
backLinks = proxy.wiki.getBackLinks(original_page) back_links = proxy.wiki.getBackLinks(original_page)
reg = rf"\[\[\s*{original_page}\s*\|(.*?)\]\]" # regex for dokuwiki links we want to replace reg = rf"\[\[\s*{original_page}\s*\|(.*?)\]\]" # regex for dokuwiki links we want to replace
_replacer = lambda matched : "[[" + new_page + "|" + matched.group(1) + "]]" _replacer = lambda matched : "[[" + new_page + "|" + matched.group(1) + "]]"
for page in backLinks: for page in back_links:
content = proxy.wiki.getPage(page) content = proxy.wiki.getPage(page)
content = re.sub(reg, _replacer, content) content = re.sub(reg, _replacer, content)
proxy.wiki.putPage(page, content, {"sum":"Update links from " +original_page+ " to " + new_page}) proxy.wiki.putPage(page, content, {"sum":"Update links from " +original_page+ " to " + new_page})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment