FANDOM


This page describes a script. In general, it refers to the script in its current form, but pywikpedia coders tend only to add functions, not take them away. Chances are that you'll be able to use most of the information on the page, regardless of the age of your installation.

Replace.py
Creator: Daniel Herding & the Pywikipedia team
Code location: wikimedia repository
What it does: Text replacement
Complexity: Basic

Replace.py is a script that allows you to quickly replace strings of text with another string. This script can be used in conjunction with user-fixes.py to replace large amounts of text.

This will use the user-fixes file:

python replace.py -fix:(insert the name of the fix)

Command line examples Edit

In its most basic form, replacy.py is formatted like so:

python replace.py "text to be replaced" "text to replace with"

Of course, this will do nothing without a range of pages set. You can use multiple parameters to achieve this.

For example, should you want to replace all links to [[Exapmle]] with [[Example]], you might want to use a command line like this:

python replace.py "[[Exapmle" "[[Example" -ref:Exapmle

-ref here will restrict the search to pages that link to Exapmle.

If you want to include lower case links too, though, the easiest way to do this without the use of regex is to simply put two replacements in the same line. This is achieved by adding them in after the first two terms, also with quotation marks. Like so:

python replace.py "[[Exapmle" "[[Example" "[[exapmle" "[[example" -ref:Exapmle

Full list of available parameters Edit

  • -cat
  • -catr
  • -file
  • -subcats
  • -subcatsr
  • -transcludes
  • -page
  • -ref
  • -filelinks
  • -links
  • -start
  • -prefixindex
  • -titleregex
  • -search
  • -save
  • -savenew
  • -excepttitle
  • -excepttext
  • -exceptinside
  • -exceptinsidetag
  • -summary
  • -fix
  • -replacementfile
  • -ns (or -namespace)
  • -always
  • -recursive
  • -nocase
  • -allowoverlap
  • -regex
  • -dotall
  • -multiline

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.