Skip to content
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
This repository was archived by the owner on Nov 25, 2019. It is now read-only.

MediaWiki metadata does not always contain server; use base if so #9

@GreenReaper

Description

@GreenReaper

In wiki.py the server name is extracted from JSON metadata:

server = general_siteinfo['server']

However, in versions of MediaWiki prior to 1.16, the general metadata does not contain the name of the server as a variable. For example:

{"query":{"general":{"mainpage":"Huvudsida","base":"http:\/\/www.wikilurv.se\/wiki\/Huvudsida","sitename":"WikiLurv","generator":"MediaWiki 1.15.4","case":"first-letter","rights":"GNU Free Documentation License","lang":"sv","fallback8bitEncoding":"windows-1252","writeapi":"","timezone":"UTC","timeoffset":0}}}

The lack of this variable causes failure of the script.

A more robust approach is to extract the server name from base if server is not available.

server = general_siteinfo['server'] if 'server' in general_siteinfo else general_siteinfo['base'].split("/")[2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions