Manual:Pywikibot/makecat.py

makecat.py is a script which lets you easily add pages to a category of your choosing, based upon an investigation of links in existing articles. Its potential applications are diverse, but it would be especially helpful on wkis that do not yet have well-established category trees. Used properly, it could create a number of fully populated categories much more quickly than by manual editing.

This script is a standard part of the pywikipediabot installation, and should be available to all users who have installed pywikipediabot properly.

Error correction
The version which is part of the standard pywikipedia script library as of 2012 is 7336, dated 2009-09-29. This code has a small syntax error that needs to be corrected before the script can be used.
 * 1) Navigate to makecat.py within your library. (On Macs, this is typically at  )
 * 2) Open makecat.py by double-clicking on it. Unless you have a very barebones setup, your computer should automatically find a program capable of editing it. (On Macs, IDLE should instantly start on double click.)
 * 3) Navigate down to the area just below the explanatory text at the top of the file. You'll see a raft of different translations of a one-line message.  In English, this message says "creation or update of category". (If you're lost, just use your editor's search function to look for that phrase.)
 * 4) If you know a bit about javascript coding, you'll be able to instantly see some glaring syntax errors at the end of the 'nn' and 'no' lines.   and   are the source of the problem.
 * 5) Change the final colons to commas. The lines should read:   and
 * 6) Save your file (Ctrl-S; or, if Mac, Command-S)

makecat.py will now work properly.

Help text
The following is the standard help text for this script. This bot takes as its argument (or, if no argument is given, asks for it), the name of a new or existing category. It will then try to find new articles for this category (pages linked to and from pages already in the category), asking the user which pages to include and which not.

Arguments: -nodates automatically skip all pages that are years or dates (years             only work AD, dates only for certain languages) -forward only check pages linked from pages already in the category, not pages linking to them. Is less precise but quite a bit faster. -exist   only ask about pages that do actually exist; drop any titles of non-existing pages silently. If -forward is chosen, -exist is automatically implied. -keepparent do not remove parent categories of the category to be             worked on. -all     work on all pages (default: only main namespace)

When running the bot, you will get one by one a number by pages. You can choose: Y(es) - include the page N(o) - do not include the page or I(gnore) - do not include the page, but if you meet it again, ask again. X - add the page, but do not check links to and from it Other possiblities: A(dd) - add another page, which may have been one that was included before C(heck) - check links to and from the page, but do not add the page itself R(emove) - remove a page that is already in the list L(ist) - show current list of pages to include or to check