User:JVbot/WFB Flags/Method

Input
The raw content of ../ is split into two files using sed.

articles.txt
This file is comprised of the first column of the table and looks like:

CIA World Fact Book, 2004/Afghanistan CIA World Fact Book, 2004/Akrotiri CIA World Fact Book, 2004/Albania CIA World Fact Book, 2004/Algeria CIA World Fact Book, 2004/American Samoa CIA World Fact Book, 2004/Andorra CIA World Fact Book, 2004/Angola CIA World Fact Book, 2004/Anguilla CIA World Fact Book, 2004/Antigua and Barbuda CIA World Fact Book, 2004/Argentina CIA World Fact Book, 2004/Armenia CIA World Fact Book, 2004/Aruba

params.txt
This file is comprised of the second two columns of the table, with the first converted to a regular expression in order to handle the different ways the images have been specified in the articles:

\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

Command
$ (IFS=' ' && python replace.py -regex -file:articles.txt $(cat params.txt) )

Note: setting the IFS to a new line character tells bash to parse params.txt as one argument per line, irrespective of spaces on the line.

Result
A test run has the following output: Checked for running processes. 1 processes currently running, including the current process. Getting 50 pages from wikisource:en...

>>> CIA World Fact Book, 2004/Afghanistan <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Akrotiri <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Albania <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Algeria <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/American Samoa <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Andorra <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Angola <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Anguilla <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Antigua and Barbuda <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll) M Do you want to accept these changes? ([y]es, [N]o, [a]ll) N

>>> CIA World Fact Book, 2004/Argentina <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll)

>>> CIA World Fact Book, 2004/Armenia <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll)

>>> CIA World Fact Book, 2004/Aruba <<< - |width="24%" align="center" bgcolor="#CCCCCC"| + |width="24%" align="center" bgcolor="#CCCCCC"|

Do you want to accept these changes? ([y]es, [N]o, [a]ll)