Module:BaseModule

local getArgs = require("Module:Arguments").getArgs local mw = mw local base = { __data_sets = {} }

-- Creates wrapper function -- -- funcName: name of function to proxy -- a_args: same args as passed to https://en.wikipedia.org/wiki/Module:Arguments -- function base:makeInvokeFunc(func_name, a_args) return function(frame) local args = getArgs(frame, a_args) return self[func_name](args, frame) end end

-- Get data for an entire data module or a single entry within it function base:getModuleData(module_name, item_name) -- If data is loaded then use it; if not then load it   self.__data_sets[module_name] = self.__data_sets[module_name] or mw.loadData(module_name)

local data

if item_name == nil then data = self.__data_sets[module_name] else data = (self.__data_sets[module_name] or {})[item_name] end

return data end

-- Create new object using either passed in table or auto-create one function base:newModule(t) t = t or {} self.__index = self setmetatable(t, self) return t end

return base