Last active
May 20, 2018 17:38
-
-
Save framawiki/dd225f6c18f4aeca4cf2867d7152fa55 to your computer and use it in GitHub Desktop.
add infobox at right
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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