Search and Replace using XMLRPC

WikiRpc Search-and-replace tool for MoinMoin

Purpose:

Using this script you can search-and-replace in multiple wiki pages at once. {{{ preformatted }}}, `text` and = level 1 titles = are preserved at will.

There are several parameters to be used, some of them set using environment variables (username and password for example). While sometimes one wants to change every occurence of a needle, at times it's very imported not to change just-everything. The user is asked when running if Save replacement should be used or not.

Configuration:

Environment variables:

username
the username to be used for xmlrpc
password

the password to be used for xmlrpc <optional>

moin_url
the hostname of your moinmoin server

Hardcoded:

MOIN_URL
set this to your site's hostname if you don't want to use the environment variable
RPC_URL

normally set using your MOIN_URL, but this allows for complex urls

sever regular expressions used in get_save_regions
regular expressions used to test what lines not to touch

Usage:

  1. Set the username and moin_url environment variables. If you like, set the password variable as well (or retype this at every execution).

  2. start replace_in_wiki.py

  3. enter the expression to select the pages to apply this search-and-replace on

  4. enter the regular expression (FORCED) to search for in the pages

  5. enter the replacement expressions (can use \1 and \2 etc)

  6. enter yes,y or simply hit <enter> to enable SaveReplacer (and keep {{{preformatted}}} {{{text}}} = intact = ) or enter anything else to replace every occurence per page.

  7. Examine the result of diff comparison on the old and new content and decide:
  8. Either accept the change (yes, y, or simply <enter>) and upload this new page to the server, or enter any other value (and enter) to not upload the new version.

Notes:

  1. The regular expression search is performed with re.MULTILINE and re.DOTALL as default options: this allows for multiline matches, as well as using ^ and $ in your expression on a line basis.

Verified to work with:

MoinMoin: SearchAndReplace/FromOutsideTheWiki (last edited 2008-02-27 15:45:00 by RemcoBoerma)