diff --git a/wikibot.py b/wikibot.py index 5b66fd146c5a9d68bfbfb03d0edb44397291c6d6..10298500c31d7ec7b602f31afb750c654c52a38a 100644 --- a/wikibot.py +++ b/wikibot.py @@ -5,6 +5,17 @@ import re import datetime +def strip_namespace(full_name): + """Returns the pure pagename without namespace + If a namespace withoput pagename is given like "n1:n2:" then the last namespace is returned + """ + split = full_name.split(":") + if len(split) > 1 and split[-1] == "": + return split[-2] + else: + return split[-1] + + def move_page(original_page, new_page, delete=False): """Moves a page, updates link to new page and flags or deletes the old one""" with Proxy(config.WIKI_API_URL) as proxy: @@ -37,7 +48,7 @@ def move_pages(original_name_regex, new_name_func, delete=False): page_content = proxy.wiki.getPage(old) proxy.wiki.putPage(new, page_content, {"sum": "Moved from " + old}) # bulk update for links # - update_backlink_sites = {} + update_backlink_sites = {} for page in update_pages.keys(): for link in proxy.wiki.getBackLinks(page): if update_backlink_sites.get(link):