User:Firefly/code/insertat
< User:Firefly | code
(Redirected from User:Richard0612/code/insertat)<source lang=python>
- !/usr/bin/python
- -*- coding: utf-8 -*-
import wikipedia
- Inserts text directly before interlanguage links/categories if they exist, else it appends the text to the end of the article
def endofprose(pagetext, addition):
site = wikipedia.getSite() interwiki = wikipedia.getLanguageLinks(pagetext, site) categories = wikipedia.getCategoryLinks(pagetext, site) pagetext = wikipedia.removeLanguageLinks(pagetext, site) pagetext = wikipedia.removeCategoryLinks(pagetext, site) pagetext += '\n\n' + addition pagetext = wikipedia.replaceLanguageLinks(pagetext,interwiki) pagetext = wikipedia.replaceCategoryLinks(pagetext,categories) return pagetext