Jump to content

Module:Sandbox/Desb42

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Desb42 (talk | contribs) at 09:34, 28 September 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p.siteinfo(frame)
  return mw.site.siteName .. '--' .. '(' .. mw.site.server .. ')'
end

local dump_table_count = 0;
local function dump_table(o)
  if dump_table_count == 10 then
    return "overflow";
  end
  
  if type(o) == 'table' then
    local s = '{ '
    for k,v in pairs(o) do
      if type(k) == 'table' then
        k = dump_table(k)
      elseif type(k) ~= 'number' then
        k = '"'..k..'"'
      end
      dump_table_count = dump_table_count + 1;
      s = s .. '['..k..'] = ' .. dump_table(v) .. ','
      dump_table_count = dump_table_count - 1;
    end
    return s .. '} '
  else
    return tostring(o)
  end
end

local diagnostic_preprocess_nested_data = ''
function mw.diagnostic_preprocess_nested(o)
  if o == 'clear' then
    diagnostic_preprocess_nested_data = ''
  elseif o == 'exec' then
    diagnostic_preprocess_nested_data = diagnostic_preprocess_nested_data .. 'once';
  end
  return diagnostic_preprocess_nested_data
end

function p.info(frame)
	mw.logObject(frame)
  return dump_table(frame)
end

return p