Manual:Pywikipediabot/user-config.py

From MediaWiki.org
Jump to: navigation, search
Wikimedia-logo-meta.png

This page was moved from MetaWiki.
It probably requires cleanup – please feel free to help out. In addition, some links on the page may be red; respective pages might be found at Meta. Remove this template once cleanup is complete.

Crystal Clear action run.svg
Generate pywikipediabot/user-config.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

If you need more help on setting up your pywikipediabot visit the irc channel #pywikipediabotconnect @ freenode server or pywikipediabot mailing list.

Contents

[edit] Configuration

Before you run any of the programs, you need to create a file named user-config.py in your pywikipedia directory either one of two ways:

  1. Create the file manually (it needs at least two or three variables configured, see below) or
  2. run the script login.py by typing python login.py in the command line shell and hit ENTER (which will interactively generate the file in an interactive "wizard" style).

Below are the instructions for editing manually the content of the file.

[edit] For Wikimedia projects

Open a text editor (e.g. Notepad in Windows) and save the text file as user-config.py, in the pywikipedia folder.

If your language uses non-ASCII characters, you should use a Unicode-aware editor such as Notepad++ and save your user-config with Unicode encoding without BOM marks. Don't forget to insert

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

into the first line.

Add the following lines to user-config.py:

Code Explanation
family = 'wikipedia'
mylang = 'en'

xx is the code for the language code you are working on, "en" is English.[1] Family is the project name.[2]

usernames['wikipedia']['en'] = u'ExampleBot'

Your user-config.py file needs to specify the bot's username.

In this example, the user is working on English Wikipedia, and has created a bot account with the username "ExampleBot".[3]

(Optional)

usernames['wikipedia']['de'] = u'BeispielBot'
usernames['wikipedia']['en'] = u'ExampleBot'
usernames['wiktionary']['de'] = u'BeispielBot'

(Optional)

If you are working on more than one Wikimedia project, you can also add several usernames.

(Optional)

console_encoding = 'utf-8'
textfile_encoding = 'unicode_escape'

(Optional, and rarely needed)

If this is the encoding used by your system. Always try without first.

(Optional)

sort_ignore_case = True

(Optional)

Some scripts may use this for sorting, e.g. solve_disambiguation.py. Default is False. Capitalized titles will preceed uncapitalized ones if this key is False or omitted, and capitalization will be disregarded by sorting if True.

Now save user-config.py again.

[edit] For non-Wikimedia wikis

Main Page: Manual:Pywikipediabot/Use on non-WMF wikis

[edit] Notes

  1. If you want to work with more than one language, choose the most common one. You can override this on the command line by using -lang:zh parameter.
  2. Meta uses 'meta' for both language code and wiki family, Commons uses 'commons' for both, and Testwiki uses 'test' for both, the multilingual wikisource uses '-' for the language. You can override this on the command line by using -family:wikibooks.
  3. The 'u' in front of the username stands for Unicode. The 'u' is required if your username contains non-ASCII characters.
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox