From: Gordon Hecker Date: Mon, 4 Jan 2010 14:27:25 +0000 (+0100) Subject: env: implement get_dict() X-Git-Tag: e2factory-2.3.4pre1~66 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=03d9415399bbfc5afbb35521391cd6d05fec6c0d;p=e2factory.git env: implement get_dict() Signed-off-by: Gordon Hecker --- diff --git a/local/environment.lua b/local/environment.lua index 5642b41..d3a20b4 100644 --- a/local/environment.lua +++ b/local/environment.lua @@ -51,6 +51,15 @@ function iter(env) return _iter, env.sorted end +--- return a (copy of the) dictionary +function get_dict(env) + local dict = {} + for k,v in env:iter() do + dict[k] = v + end + return dict +end + function unittest(env) local function p(...) --print(...) @@ -103,4 +112,7 @@ function unittest(env) p(var, val) end assert(e5:id() == "404AA226CF94A483FD61878682F8E2759998B197") + + local dict = e5:get_dict() + assert(dict['var'] == "val4") end