Module:Introspection utils: Difference between revisions
refactor invocation_exists to search through a table of invokes provided by find_invokes; will momentarily break other modules |
No edit summary |
||
| Line 329: | Line 329: | ||
-- of invocations, from find_invokes, and mod_name is the module name. | -- of invocations, from find_invokes, and mod_name is the module name. | ||
function p.invocation_exists(invokes, mod_name) | function p.invocation_exists(invokes, mod_name) | ||
-- Normalize module name | |||
local normalize = function(name) | |||
name = name or "" | |||
name = name:gsub("_", " ") | |||
name = name:lower() | |||
name = name:gsub("^module:%s*", "") | |||
return name | |||
end | |||
local target_mod = normalize(mod_name) | |||
-- Search | |||
for _, invoke in ipairs(invokes) do | for _, invoke in ipairs(invokes) do | ||
local invoke_mod = normalize(invoke.module) | |||
if invoke_mod == target_mod then | |||
return true | |||
end | end | ||
end | end | ||