User talk:Jpatokal/post.py

post.py is a Pywikipediabot script for automated uploading of skeleton articles.

Installation
This script is intended for Pywikipediabot, which must be installed and configured first. Configure your account in user-config.py and run python2 login.py before attempting to run the bot.

Known issue: The default Pywikipediabot login.py can't recognize a successful login to Wikivoyage, as Wikivoyage returns three cookies, not four on successful login. Change the line that says

if len(L) == 4:

to

if len(L) > 1:

Note that Pywikipediabot's interface is not particularly stable and you will probably need to hand-hack the script a little to make it work with newer versions. Please update the script here after any changes.

Configuration
post.py works by reading .dat files, injecting the content into a template and posting the merged document to a specified Wikivoyage version.

The .dat file consists of key-value pairs like this:

NAME Akita LCASE akita JAPANESE 秋田 CAPITAL Akita

Keys should use alphabetic characters in the range A-Z only. The special key NAME is used as the title of the article to be created. Values can contain anything, including UTF-8 characters (which should be used for any non-ASCII characters) and continue until the end of the line. Generating the dat files is left up to you!

The template is simply a plain text file containing the skeleton Wiki article and variables flagged by '$':

$NAME prefecture ($JAPANESE $NAME-ken) is in Japan.

Cities

 * $CAPITAL &mdash; The prefectural capital

Variable substitutions are performed against all variables listed in the dat file. Any variables not found in the dat file are ignored.

The command to actually run post.py is:

python2 post.py -uusername -ttemplate.wiki -nfile.date -e/bin/true

Once you have perfected the automated entry of a single file, you can use a shell loop to upload everything:

for i in dat-directory/*; do  python2 post.py  -uusername -ttemplate.wiki -n$i -e/bin/true done

Questions and bug reports
This may be a stupid question but... Where do you enter the title for each new page or .dat file?


 * Very good question! The parameter NAME is automatically used as the title. (WT-en) Jpatokal 11:59, 19 March 2007 (EDT)

Mac
Sorry for being ignamoorse, but can Pywikipediabot be used on a Mac? -- (WT-en) Sapphire • (Talk) • 01:55, 23 February 2008 (EST)
 * Yes. -- (WT-en) Colin 11:35, 23 February 2008 (EST)


 * BTW, I'm fairly sure that post.py in its present form is not going to work with current versions of pywikipediabot, which is revised continually and regularly breaks old code. Sigh. (WT-en) Jpatokal 14:21, 23 February 2008 (EST)