Pybot Wiki
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Introduction
Pywikipediabot
Python installation
Installation
Windows
OS X
Linux
Gateways
Script Library
Parameter Stockhouse
Regex Repository
Fix Files
Operating systems
Windows
OS X
Linux
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Pybot Wiki
58
pages
Explore
Main Page
Discuss
All Pages
Community
Interactive Maps
Introduction
Pywikipediabot
Python installation
Installation
Windows
OS X
Linux
Gateways
Script Library
Parameter Stockhouse
Regex Repository
Fix Files
Operating systems
Windows
OS X
Linux
Editing
User-fix
Back to page
Edit
Edit source
View history
Talk (0)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{you may|Fix Files|n1=our collection of fix files}} {{intro}} {{fix}} A '''user-fix''' is a user-defined bit of [[regex]] that is used by [[replace.py]] to perform some kind of text replacement. It is one of the two ways in which a [[regular expression]] can be introduced into the replace.py [[script]]. It can be contrasted with what, for lack of a better term, we might call "[[inline regex]]" β a piece of regex entered at the command prompt. User-fixes offer at least two significant advantages over inline regex: *they can handle multiple replacements simultaneously *they are saved, and therefore can be called at a later date. == Example of a user-fix == Inline regex is great for the quick fix. But inline regex only offers you the ability to change a ''single'' thing β like a single word that's frequently misspelled, or the removal of a single section that appears on several articles. But what if you want to change several misspellings simultaneously? Or get rid of multiple categories? For that, you need a user-fix. Let's imagine you have an infobox that appears on hundreds of pages on your wiki. This temlate is called, let's say, '''Template:Story infobox'''. It has a couple of navigation variables on it for the previous and next stories in a series. These variables, sensibly, are called "previous story" and "next story", but you come to feel one day that this is just too long. You want to change the variables to "prev" and "next". So you open up [[user-fixes.py]] and you enter this: <pre> fixes['prevnext'] = { 'regex': True, 'msg' : { 'en': u'changing previous story/next story to just prev/next' }, 'replacements': [ (r'[Pp]revious story( *?)=', r'prev\1='), (r'[Nn]ext story( *?)=', r'next\1='), ] } </pre> To run this, you'd type: <pre>ptyhon replace.py -fix:prevnext -transcludes:"Story infobox"</pre> This would run the fix called '''prevnext''' on every page where the template '''Story infobox''' was transcluded. The replacement would take the word "Previous story" (or "previous story"), plus whatever spaces are before the equals sign, plus the equals sign itself, and replace it with {{tt|<nowiki>prev<however many spaces existed before>=</nowiki>}} And while it was replacing the "previous story" bit, it would also replace the "next story" variable. If you were doing this with inline regex, you'd have to make ''two'' runs: one for "prev" and one for "next". There's a lot you can do with user-fixes, and this page won't even attempt to list everything. Instead, go to our [[Fix Files]] and check out all the ready-to-use fixes that we have to offer. == How to employ user-fixes == Fixes are called by the following language: <pre> python replace.py -fix:fixname <parameter defining the pages to work on></pre> Thus, if I wanted to call a user-fix named "spell" and apply it to every page in [[namespace]]:0, I would type the following: <pre> python replace.py -fix:spell -start:! </pre> [[Category:Definitions]]
Summary:
Please note that all contributions to the Pybot Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Fix
(
view source
)
Template:Intro
(
view source
)
Template:Tt
(
view source
)
Template:You may
(
view source
)
Follow on IG
TikTok
Join Fan Lab