Software / code / prosody
Comparison
tools/migration/main.lua @ 4193:3fecfe58d633
tools/migration/*: Initial commit of a new migration tool. Currently supports Prosody files and Prosody SQL as input and output.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 23 Feb 2011 02:16:19 +0500 |
| child | 4166:3ac90743039b |
comparison
equal
deleted
inserted
replaced
| 4192:c1e4d8326ab0 | 4193:3fecfe58d633 |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 local function loadfilein(file, env) return loadin and loadin(env, io.open(file):read("*a")) or setfenv(loadfile(file), env); end | |
| 5 config = {}; | |
| 6 local config_env = setmetatable({}, { __index = function(t, k) return function(tbl) config[k] = tbl; end; end }); | |
| 7 loadfilein("config.lua", config_env)(); | |
| 8 | |
| 9 package.path = "../../?.lua;"..package.path | |
| 10 package.cpath = "../../?.dll;"..package.cpath | |
| 11 | |
| 12 | |
| 13 assert(config.input, "no input specified") | |
| 14 assert(config.output, "no output specified") | |
| 15 local itype = assert(config.input.type, "no input.type specified"); | |
| 16 local otype = assert(config.output.type, "no output.type specified"); | |
| 17 local reader = require(itype).reader(config.input); | |
| 18 local writer = require(otype).writer(config.output); | |
| 19 | |
| 20 local json = require "util.json"; | |
| 21 | |
| 22 for x in reader do | |
| 23 --print(json.encode(x)) | |
| 24 writer(x); | |
| 25 end | |
| 26 writer(nil); -- close | |
| 27 |