Module:Module sandbox
Appearance
require ('strict');
local get_args = require ('Module:Arguments').getArgs; -- function to fetch frame and parent frame arguments
--[[--------------------------< D E F I N E S >----------------------------------------------------------------
]]
local institutions_t = { -- map institution abbreviation to wikidata qid
COR = 'Q205203',
EC = 'Q8880',
EP = 'Q8889',
EUCO = 'Q8886'
}
local parties_t = { -- map party abbreviation to wikidata qid
ALDE = 'Q25079',
ECPM = 'Q1377279',
ECR = 'Q1577483',
EDP = 'Q734792',
EFA = 'Q639383',
EGP = 'Q950179',
EL = 'Q202649',
ELA = 'Q130219314',
ESN = 'Q130269264',
EPP = 'Q208242',
Patriots = 'Q18907386',
PES = 'Q220945'
}
--[[--------------------------< S E A T S >--------------------------------------------------------------------
expands {{wikidata}} templates:
{{wikidata|property|Q208242|P1410|P208=Q8880}} → '11'
{{wikidata|property|Q55|P395}} → 'NL'
]]
local function seats (frame)
local args_t = get_args (frame); -- get arguments; empty string or whitespace positional parameters set to nil
local institution = args_t[1] and args_t[1]:upper(); -- force to upper case
local party = args_t[2] and args_t[2]:upper();
if not party then -- party not specified
return institutions_t[institution] and frame:expandTemplate ({title='wikidata', args = {'property', institutions_t[institution], 'P1342'}}) or 'error';
elseif party == "IND" and institution == "EC" then
return institutions_t[institution] and frame:expandTemplate ({title='wikidata', args = {'property', 'Q327591', 'P1410', P208 = institutions_t[institution]}}) or 'error';
elseif party == "NONE" then
if institution == "EC" then
return institutions_t[institution]
and frame:expandTemplate ({title='wikidata', args = {'property', institutions_t[institution], 'P1342'}})
- (frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ALDE"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECPM"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECR"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EDP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EFA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EGP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EL"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ELA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EPP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ESN"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["Patriots"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["PES"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', 'Q327591', 'P1410', P208 = institutions_t[institution]}})) or 'error';
elseif institution == "EUCO" then
return institutions_t[institution]
and frame:expandTemplate ({title='wikidata', args = {'property', institutions_t[institution], 'P1342'}})
- (frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ALDE"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECPM"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECR"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EDP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EFA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EGP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EL"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ELA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EPP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ESN"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["Patriots"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["PES"], 'P1410', P208 = institutions_t[institution]}})) or 'error';
elseif institution == "EP" or institution == "COR" then
return institutions_t[institution]
and frame:expandTemplate ({title='wikidata', args = {'property', institutions_t[institution], 'P1342'}})
- (frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ALDE"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECPM"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECR"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EDP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EFA"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EGP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EL"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ELA"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EPP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ESN"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["Patriots"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["PES"], 'P1410', P194 = institutions_t[institution]}})) or 'error';
end
elseif party == "ALL" then
if institution == "EC" or institution == "EUCO" then
return institutions_t[institution]
and frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ALDE"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECPM"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECR"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EDP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EFA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EGP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EL"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ELA"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EPP"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ESN"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["Patriots"], 'P1410', P208 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["PES"], 'P1410', P208 = institutions_t[institution]}}) or 'error';
elseif institution == "EP" or institution == "COR" then
return institutions_t[institution]
and frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ALDE"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECPM"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ECR"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EDP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EFA"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EGP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EL"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ELA"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["EPP"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["ESN"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["Patriots"], 'P1410', P194 = institutions_t[institution]}})
+ frame:expandTemplate ({title='wikidata', args = {'property', parties_t["PES"], 'P1410', P194 = institutions_t[institution]}}) or 'error';
end
else
if institution == "EC" or institution == "EUCO" then
return institutions_t[institution] and frame:expandTemplate ({title='wikidata', args = {'property', parties_t[party], 'P1410', P208 = institutions_t[institution]}}) or 'unknown party';
elseif institution == "EP" or institution == "COR" then
return institutions_t[institution] and frame:expandTemplate ({title='wikidata', args = {'property', parties_t[party], 'P1410', P194 = institutions_t[institution]}}) or 'unknown party';
end
end
end
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return {
seats = seats,
}