Comparison

tools/ejabberd2prosody.lua @ 547:265c4b8f0a8a

Changed the ejabberd import script to use util.serialization
author Waqas Hussain <waqas20@gmail.com>
date Thu, 04 Dec 2008 23:40:15 +0500
parent 519:cccd610a0ef9
child 606:f8f1534a4e06
comparison
equal deleted inserted replaced
546:1e65f64dfabf 547:265c4b8f0a8a
19 -- 19 --
20 20
21 21
22 22
23 require "erlparse"; 23 require "erlparse";
24 require "serialize";
25 24
26 package.path = package.path ..";../?.lua"; 25 package.path = package.path ..";../?.lua";
26 local serialize = require "util.serialization".serialize;
27 local st = require "util.stanza"; 27 local st = require "util.stanza";
28 package.loaded["util.logger"] = {init = function() return function() end; end} 28 package.loaded["util.logger"] = {init = function() return function() end; end}
29 local dm = require "util.datamanager" 29 local dm = require "util.datamanager"
30 local data_path = "data"; 30 local data_path = "data";
31 dm.set_data_path(data_path); 31 dm.set_data_path(data_path);
72 for _, a in ipairs(tuple[4]) do build_stanza(a, stanza); end 72 for _, a in ipairs(tuple[4]) do build_stanza(a, stanza); end
73 if up then stanza:up(); else return stanza end 73 if up then stanza:up(); else return stanza end
74 elseif tuple[1] == "xmlcdata" then 74 elseif tuple[1] == "xmlcdata" then
75 stanza:text(tuple[2]); 75 stanza:text(tuple[2]);
76 else 76 else
77 error("unknown element type: "..serialize.serialize(tuple)); 77 error("unknown element type: "..serialize(tuple));
78 end 78 end
79 end 79 end
80 function build_time(tuple) 80 function build_time(tuple)
81 local Megaseconds,Seconds,Microseconds = unpack(tuple); 81 local Megaseconds,Seconds,Microseconds = unpack(tuple);
82 return Megaseconds * 1000000 + Seconds; 82 return Megaseconds * 1000000 + Seconds;
188 local t = {}; 188 local t = {};
189 for item in erlparse.parseFile(arg) do 189 for item in erlparse.parseFile(arg) do
190 count = count + 1; 190 count = count + 1;
191 local name = item[1]; 191 local name = item[1];
192 t[name] = (t[name] or 0) + 1; 192 t[name] = (t[name] or 0) + 1;
193 --print(count, serialize.serialize(item)); 193 --print(count, serialize(item));
194 if filters[name] then filters[name](item); end 194 if filters[name] then filters[name](item); end
195 end 195 end
196 --print(serialize.serialize(t)); 196 --print(serialize(t));