Jump to content

Module:Convert/makeunits/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
update: now requires Module:Convert/text
m update link
Line 4: Line 4:


This script reads wikitext defining units, and outputs a Lua script with tables containing that data:
This script reads wikitext defining units, and outputs a Lua script with tables containing that data:
*The input is the wikitext at [[User:Johnuniq/Conversion data]].
*The input is the wikitext at [[Module:Convert/documentation/conversion data/doc]].
*Additional input for localization is read from [[Module:Convert/text]].
*Additional input for localization is read from [[Module:Convert/text]].
*The output is manually copied to [[Module:Convert/data]] to replace its current contents.
*The output is manually copied to [[Module:Convert/data]] to replace its current contents.
Line 14: Line 14:
<pre>
<pre>
wget -O makeunits.lua http://en.wikipedia.org/wiki/Module:Convert/makeunits?action=raw
wget -O makeunits.lua http://en.wikipedia.org/wiki/Module:Convert/makeunits?action=raw
wget -O wikidata.txt http://en.wikipedia.org/wiki/User:Johnuniq/Conversion_data?action=raw
wget -O wikidata.txt http://en.wikipedia.org/wiki/Module:Convert/documentation/conversion_data/doc?action=raw
wget -O converttext.lua http://en.wikipedia.org/wiki/Module:Convert/text?action=raw
wget -O converttext.lua http://en.wikipedia.org/wiki/Module:Convert/text?action=raw
lua makeunits.lua converttext wikidata.txt
lua makeunits.lua converttext wikidata.txt

Revision as of 09:19, 4 October 2013

The purpose of this module is to prepare the data used by Module:Convert to allow conversion between units of measurement.

This module is run on a stand-alone computer—it currently will not run as a module because it uses loadstring() to evaluate expressions, and that is not allowed in Scribunto.

This script reads wikitext defining units, and outputs a Lua script with tables containing that data:

The specials table is used to insert a small amount of "built-in" data that is not currently defined in the input wikitext.

To run the script, edit the above conversion data page and copy its wikitext to a local file, say wikidata.txt. Alternatively, the wget command can be used to get the wikitext, as shown below. With the script saved in file makeunits.lua, use the command line to run.

wget -O makeunits.lua http://en.wikipedia.org/wiki/Module:Convert/makeunits?action=raw
wget -O wikidata.txt http://en.wikipedia.org/wiki/Module:Convert/documentation/conversion_data/doc?action=raw
wget -O converttext.lua http://en.wikipedia.org/wiki/Module:Convert/text?action=raw
lua makeunits.lua converttext wikidata.txt

On some systems, "lua" is not needed.

By default, the script creates output file makeunits.tmp. Use that file to replace the contents of Module:Convert/data.