Manual:Pywikibot/user-fixes.py
Appearance
From mediawiki.org
(Redirected from Manual:Pywikibot/User-fixes.py)
generate_user_files.py
Pywikibot logo |
Pywikibot |
---|
|
v · d · e |
User-fixes.py adds some custom fixes to the Pywikibot text replacement utility, replace.py. It is created by running generate_user_files.py
if it doesn't already exist. To call your fixes you use replace.py.
User-fixes.py is very similar to fixes.py. For detailed explanation and comparison, see fixes.py.
Example
[edit ]To call your fixes:
$ pythonpwb.pyreplace-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. # from__future__import unicode_literals fixes['example'] = { 'regex': True, 'msg': { '_default':'no summary specified', }, 'replacements': [ (r'\bword\b', 'two words'), ] }
Modified file:
# -*- coding: utf-8 -*- # # This is only an example. Don't use it. # from__future__import unicode_literals fixes['example'] = { 'regex': True, 'msg': { '_default':'no summary specified', }, 'replacements': [ (r'\bword\b', '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': 'adding wikilinks', }, 'replacements': [ (r'(?i)\b(barrettes)', r'[[1円]]'), # barrettes will be changed to [[barrettes]] (r'(?i)\b(barrette)', r'[[1円]]'), ] }
Advanced use of fixes
[edit ]To learn how to use your own functions in fixes.py and user-fixes.py and what this is good for, see hu:Szerkesztő:Bináris/Fixes and functions HOWTO.