Page MenuHomePhabricator

scripts that do not check site correctly
Open, MediumPublic

Description

There are several scripts which run on wikis where they are not configured to run. The configuration for these scripts needs to be overhauled.

Event Timeline

jayvdb raised the priority of this task from to Medium.
jayvdb updated the task description. (Show Details)
jayvdb added a project: Pywikibot.
jayvdb subscribed.
Restricted Application added subscribers: Aklapper, Unknown Object (MLST). · View Herald TranscriptApr 1 2015, 10:08 AM

Okay maybe this could be solved similar to https://gerrit.wikimedia.org/r/#/c/201446/1 . The script just defines a class or so which takes some keyword arguments. Each Wiki has then a MediaWiki:FOO.js JSON content (where FOO could be defined by the script or maybe pywikibot-<scriptname>). It then loads the JSON content and calls whatever is there to initialize the settings. So in the case of my patch the page would contain then on the English Wikipedia:

{
    "name": "Orphan",
    "aliases": ["wi"],
    "parameters": "date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}"
}

And it would do then something like that in the script:

settings_page = 'pywikibot-lonelypages'
pywikibot.bot.load_settings(settings_page, OrphanTemplate)

And then in the library we have a function which does some magic:

def load_settings(page_title, callback, site=None):
    site = site or pywikibot.Site()
    page = pywikibot.Page(site, page_title + '.js', 12)
    if page.exists():
        return callback(**json.loads(page.get()))
    else:
        return False

We could do something similar also to implement some family configuration variables (like where the categories/interwiki links go) like suggested in T89451: Reducing complexity of the Family class.

Change 201446 had a related patch set uploaded (by XZise):
[FEAT] Load the settings from wiki

https://gerrit.wikimedia.org/r/201446