Module:Sandbox/Mensis

local population = {} local args = {} local data_module_prefix = "Module:Sandbox/Mensis/db/1" --local converter = require("Module:Sandbox/Mensis/Numeral converter")

local function ifexist(page) if not page then return false end if mw.title.new(page).exists then return true end return false end

local function loadpopulationdb(frame, s, p, year) local codestr = s--:match('^%s*([%d][%d][%d][%d][%d][%d])%s*$') or '' facodestr = codestr--converter.convert("fa", codestr) year = year--converter.convert("en", year) pfa = p--converter.convert("en", year) local function setarg(k, v)		if(v and v ~= '') then args[k] = v end end if( codestr ~= '' ) then local dbpage = data_module_prefix --.. tostring(pfa) --		if (ifexist(dbpage)) then local data = mw.loadData(dbpage) local dargs = data[facodestr] if (year == '85') then setarg('pop', dargs['pop85']) setarg('year', '85') elseif (year =='95') then setarg('pop', dargs['pop95']) setarg('year', '95') end --		end end end

local function printpop(frame) return (args['pop']) end

function population.main(frame) local args = require('Module:Arguments').getArgs(frame)--, { --	wrappers = 'Template:Iran population' --	})	return population._main(args) end

function population._main(args)

if(args.code and args.code ~=  and args.province and args.province ~= ) then if( args.year and args.year ~= '') then loadpopulationdb(frame,args.code, args.province, args.year) else loadpopulationdb(frame,args.code, args.province, '95') end end return printpop(frame)--(args['pop']) end

return population