Manual:Pywikipediabot/user-fixes.py

From MediaWiki.org
Jump to: navigation, search
Crystal Clear action run.svg
Generate pywikipediabot/user-fixes.py by running generate_user_files.py.
Subversion repository of wikimedia has the file:
Bote Boas Vindas2.png
Pywikipediabot
Quick overview
Quick Start Guide
Installation
Installation (Mac)
Configuration
user-config.py
Non-Wikimedia wikis
Basic use
Scripts
Development
Further help

v  d  e

user-fixes.py adds some custom fixes in the pyWikipediabot user file. It is created by running generate_user_files.py if User-fixes.py doesn't already exist. To call your fixes you use replace.py.

[edit] Example

To call your fixes:

python replace.py -fix:example -page:MainPage

Which looks for 'example' in user-fixes.py, and applies the fixes to the main page.

When first created, User-fixes.py looks like this:

# -*- coding: utf-8  -*-

#
# This is only an example. Don't use it.
#

fixes['example'] = {
    'regex': True,
    'msg': {
        '_default':u'no summary specified',
    },
    'replacements': [
        (ur'\bword\b', u'two words'),
    ]
}

Modified file:

# -*- coding: utf-8  -*-

#
# This is only an example. Don't use it.
#

fixes['example'] = {
    'regex': True,
    'msg': {
        '_default':u'no summary specified',
    },
    'replacements': [
        (ur'\bword\b', u'two words'),
    ]
}
 
#
# Add wikilinks. 
# This fix is used with command:
# python replace.py -fix:wikilinks [-nocase] -subcat (or -xml)

fixes['wikilinks'] = {
        'regex': True,
        'msg': { '_default':u'adding wikilinks', },
        'replacements': [
                (r'(?i)\b(barrettes)', r"[[\1]]"), # barrettes will be changed to [[barrettes]]
                (r'(?i)\b(barrette)', r"[[\1]]"),               
        ]
}

[edit] Advanced use of fixes

To learn how to use your own functions in fixes.py and user-fixes.py and what is this good for, see.

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox
In other languages