Skip to content

Instantly share code, notes, and snippets.

@framawiki
Last active May 20, 2018 17:38
Show Gist options
  • Save framawiki/dd225f6c18f4aeca4cf2867d7152fa55 to your computer and use it in GitHub Desktop.
Save framawiki/dd225f6c18f4aeca4cf2867d7152fa55 to your computer and use it in GitHub Desktop.
add infobox at right
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
import re
import pywikibot
from pywikibot import pagegenerators
ajout = '<span style="float: right;">__TOC__</span>\n'
def main(*args):
genFactory = pagegenerators.GeneratorFactory()
local_args = pywikibot.handle_args(args)
for arg in local_args:
genFactory.handleArg(arg)
generator = genFactory.getCombinedGenerator()
if not generator:
pywikibot.output("ereur")
exit()
for page in generator:
pywikibot.output(page.title())
if 'infobox' in page.text.lower() or '/' in page.title():
print('page avec infobox ou sous-page')
continue
page.text = ajout + page.text
print('enregistrement')
page.save("ajout sommaire")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment