မော်ဂျူး:Check for unknown parameters

Documentation icon မော်ဂျူးမှတ်တမ်းလက်စွဲ
-- This module may be used to compare the arguments passed to the parent-- with a list of arguments, returning a specified result if an argument is-- not on the listlocal p = {}local function isnotempty(s)return s and s:match( '^%s*(.-)%s*$' ) ~= ''endfunction p.check (frame)local args = frame.argslocal pargs = frame:getParent().argslocal ignoreblank = isnotempty(frame.args['ignoreblank'])local checkpos = isnotempty(frame.args['checkpositional'])local knownargs = {}local unknown = 'Found _VALUE_, 'local res = {}local regexps = {}local comments = {}local commentstr = ''-- create the list of known args, regular expressions, and the return stringfor k, v in pairs(args) doif type(k) == 'number' thenv = mw.ustring.gsub(v, '^%s*(.-)%s*$', '%1')knownargs[v] = 1elseif (k == 'unknown' and type(v) == 'string') thenunknown = velseif (mw.ustring.match(k, '^regexp[%d]*$') and type(v) == 'string') thentable.insert(regexps, '^' .. v .. '$')endendend-- loop over the parent args, and make sure they are on the listfor k,v in pairs(pargs) doif (type(k) == 'string' and knownargs[k] == nil) thenlocal knownflag = nilfor r = 1,#regexps doif( mw.ustring.match(k,regexps[r]) ) thenknownflag = 1endendif( (not knownflag) and ( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) ) thenk = mw.ustring.gsub(k, '[^%w\-_ ]', '?')local r = mw.ustring.gsub(unknown, '_VALUE_', k)table.insert(res, r)table.insert(comments, '"' .. k .. '"')endelseif(checkpos and type(k) == 'number' and knownargs[tostring(k)] == nil) thenif( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) thenlocal r = mw.ustring.gsub(unknown, '_VALUE_', k)table.insert(res, r)table.insert(comments, '"' .. k .. '"')endendendif(#comments > 0) thencommentstr = '<!-- Module:Check for unknown parameters results: ' ..table.concat(comments, ', ') .. '-->'endreturn table.concat(res) .. commentstrendreturn p
🔥 Top keywords: ဗဟိုစာမျက်နှာအထူး:ရှာဖွေရန်ဘက္ကရီအီးဒ်အောင်ဆန်းအောင်ဆန်းစုကြည်မြန်မာပြည်ဂျပန်နိုင်ငံဒုတိယ ကမ္ဘာစစ်ပုဂံမြန်မာအမျိုးသမီးများနေ့မြန်မာနိုင်ငံကျန်စစ်သားမူးယစ်ဆေးဝါးမေတ္တသုတ်ကားလိုး ကော်လိုဒီထိုင်းနိုင်ငံပဋ္ဌာန်းမဟာသမယသုတ်ဂေါတမဗုဒ္ဓပီမိုးနင်းသိပ္ပံပညာအလောင်းမင်းတရားအာဇာနည်နေ့စင်ကာပူနိုင်ငံတပ်မတော်ရွှေတိဂုံစေတီတော်မင်းအောင်လှိုင်အနော်ရထာကမ္ဘောဒီးယားနိုင်ငံသောမတ် အက်ဒီဆင်ဘုရင့်နောင်အဲလ်ဘတ် အိုင်းစတိုင်းအော်ကာမြန်မာတိုင်းရင်းသားမျိုးနွယ်များတပ်မတော် (ကြည်း)အပြည်ပြည်ဆိုင်ရာ အမျိုးသမီးများနေ့အရှေ့တောင်အာရှနိုင်ငံများအသင်းသမုဒ္ဒရာကျိုက်ထီးရိုးဘုရား