Jump to content

Module:Convert/makeunits/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Johnuniq (talk | contribs) at 09:45, 4 September 2013 (update: now requires Module:Convert/text). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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/User:Johnuniq/Conversion_data?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.