Modulo:Quorum: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
m fix |
correggo |
||
(3 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1:
local p = {}
local function set_error(msg, ...)
Line 10 ⟶ 11:
msg = mw.message.newRawMessage(messages[msg], ...):plain()
return string.format('<span class="error">%s</span>', msg)
end
function p.listpage()
return string.format('[[%s]]', page)
end
function p.main()
▲ local page = 'Wikipedia:Amministratori/Sistema di voto/Quorum'
local source = mw.title.new(page):getContent()
local quorum = 0
local elections, candidates, votes = {}, {}, {}
for election in string.gmatch(source or '', pattern) do
if not source or #candidates == 8 then
return set_error('bad_list', page)
elseif elections[election] then
Line 31 ⟶ 36:
local candidate = election:match('Elezioni/([^/]+)')
table.insert(candidates, string.format('[[User:%s|%s]]', candidate, candidate))
votes[#candidates] = 0
for heading, section in string.gmatch(content, '\n==+ *([^\n]-) *==+(.-)\r') do
if heading == 'Pro' or heading == 'Contro' then
local _, count = section:gsub('\n#[^#:*\n][^\n]-%a', '')
quorum = quorum + count
votes[#candidates] =
end
end
|