wmflabs is a simple Python 3 library to help with some common tasks that Labs users might encounter. Source code is published on Github. Patches welcome.
pip install "wmflabs>=3".
An example how to connect to a replicating database without needing to remember all the various options.
import wmflabs conn = wmflabs.connect('enwiki') # You can also use "enwiki_p" # conn is a pymysql.connection object. with conn.cursor() as cur: cur.execute(query) # Or something....
import requests import wmflabs wmflabs.set_user_agent('mycooltool') # Sets user-agent to: # mycooltool (https://tools.wmflabs.org/mycooltool; email@example.com) python-requests/2.13.0 requests.get('...')