changed widget lib handling, pyload widget now ready to use

This commit is contained in:
don-philipe
2016-02-21 21:58:30 +01:00
parent 2c72f6c941
commit c143aa3f89
7 changed files with 529 additions and 284 deletions

View File

@@ -1,25 +1,10 @@
-- some things copied from vicious' helper
-- helper functions
local rawget = rawget
local helpers = {}
-- {{{ Loader for knorke modules
function helpers.wrequire(table, key)
local module = rawget(table, key)
return module or require(table._NAME .. "." .. key)
-- substitutes parts from format_string of the form ${var} with the value from sub_table with the key "var"
function helpers.sub_format_string(format_string, sub_table)
return string.gsub(format_string, "%${(%w+)}", sub_table)
end
-- }}}
-- {{ Format a string with args
function helpers.format(format, args)
for var, val in pairs(args) do
format = format:gsub("$" .. (tonumber(var) and var or
var:gsub("[-+?*]", function(i) return "%"..i end)),
val)
end
return format
end
-- }}}
return helpers