Pywikipediabot/user-config.py

From Meta, a Wikimedia project coordination wiki

< Pywikipediabot(Redirected from User-config.py)
Jump to: navigation, search
Crystal Clear action run.png
Generate pywikipediabot/user-config.py by running generate_user_files.py.
Subversion repository of wikimedia has the file:

Contents

[edit] Configuration

Before you run any of the programs, you need to create a file named user-config.py in your pywikipedia directory. You can create it manually (it needs at least two or three variables configured, see below) or run the script generate_user_files.py by typing python generate_user_files.py in the command line shell and hit ENTER. That helps to complete this process.

[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.

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'

[3]

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".

(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.

Now save user-config.py again.

[edit] For non-Wikimedia wikis

Main Page: Pywikipedia bot on non-Wikimedia projects

[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. 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.