<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeam_appearances_list</id>
	<title>Module:Team appearances list - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATeam_appearances_list"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Team_appearances_list&amp;action=history"/>
	<updated>2026-06-13T00:22:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Team_appearances_list&amp;diff=479699&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Team_appearances_list&amp;diff=479699&amp;oldid=prev"/>
		<updated>2021-07-16T07:33:46Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements [[Template:Team appearances list]].&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local data_competitions&lt;br /&gt;
local data_old_names&lt;br /&gt;
local function load_data(frame)&lt;br /&gt;
	-- Load data module (or its sandbox) and set variables from its exported data.&lt;br /&gt;
	if not data_competitions then&lt;br /&gt;
		frame = frame or mw.getCurrentFrame()&lt;br /&gt;
		local sandbox = frame:getTitle():find('sandbox', 1, true) and '/sandbox' or ''&lt;br /&gt;
		local datamod = mw.loadData('Module:Team appearances list/data' .. sandbox)&lt;br /&gt;
		data_competitions = datamod.competitions&lt;br /&gt;
		data_old_names = datamod.old_names&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function strip_to_nil(text)&lt;br /&gt;
	-- If text is a string, return its trimmed content, or nil if empty.&lt;br /&gt;
	-- Otherwise return text (which may, for example, be nil).&lt;br /&gt;
	if type(text) == 'string' then&lt;br /&gt;
		text = text:match('(%S.-)%s*$')&lt;br /&gt;
	end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function make_options(args)&lt;br /&gt;
	-- Return table of options from validated args or throw error.&lt;br /&gt;
	local options = {}&lt;br /&gt;
	local function valid_integer(name, min, max, is_optional)&lt;br /&gt;
		local arg = args[name]&lt;br /&gt;
		if arg == nil or arg == '' then&lt;br /&gt;
			if is_optional then&lt;br /&gt;
				return nil&lt;br /&gt;
			end&lt;br /&gt;
			error('Parameter ' .. name .. ' is missing')&lt;br /&gt;
		end&lt;br /&gt;
		arg = tonumber(arg)&lt;br /&gt;
		if type(arg) ~= 'number' then&lt;br /&gt;
			error('Parameter ' .. name .. ' is not a number')&lt;br /&gt;
		end&lt;br /&gt;
		if math.floor(arg) ~= arg then&lt;br /&gt;
			error('Parameter ' .. name .. ' is not an integer')&lt;br /&gt;
		end&lt;br /&gt;
		if not (min &amp;lt;= arg and arg &amp;lt;= max) then&lt;br /&gt;
			error('Parameter ' .. name .. ' is not valid')&lt;br /&gt;
		end&lt;br /&gt;
		return arg&lt;br /&gt;
	end&lt;br /&gt;
	local function valid_text(name)&lt;br /&gt;
		local arg = args[name]&lt;br /&gt;
		if arg == nil or arg == '' then&lt;br /&gt;
			error('Parameter ' .. name .. ' is missing')&lt;br /&gt;
		end&lt;br /&gt;
		if type(arg) ~= 'string' then&lt;br /&gt;
			error('Parameter ' .. name .. ' is not a string')&lt;br /&gt;
		end&lt;br /&gt;
		return arg&lt;br /&gt;
	end&lt;br /&gt;
	options.competition = valid_text('competition')&lt;br /&gt;
	options.team = valid_text('team')&lt;br /&gt;
	options.competitions = data_competitions[options.competition] or data_competitions[data_old_names[options.competition]]&lt;br /&gt;
	local begin_optional&lt;br /&gt;
	if options.competitions then&lt;br /&gt;
		begin_optional = true&lt;br /&gt;
	else&lt;br /&gt;
		options.interval = valid_integer('interval', 1, 30)&lt;br /&gt;
	end&lt;br /&gt;
	options.begin_year = valid_integer('begin_year', 1800, 2100, begin_optional)&lt;br /&gt;
	options.end_year = valid_integer('end_year', 1800, 2100, true)&lt;br /&gt;
	if options.begin_year and options.end_year then&lt;br /&gt;
		if options.begin_year &amp;gt; options.end_year then&lt;br /&gt;
			error('Parameter end_year must not be before begin_year')&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	options.disqualified_year = valid_integer('disqualified_year', 1800, 2100, true)&lt;br /&gt;
	return options&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function extract_range(text)&lt;br /&gt;
	-- Return first (if text is a single year), or first, last if a range.&lt;br /&gt;
	-- The returned values are numbers.&lt;br /&gt;
	-- Return nothing if text is invalid.&lt;br /&gt;
	local year = text:match('^(%d+)$')&lt;br /&gt;
	if year then&lt;br /&gt;
		if #year == 4 then&lt;br /&gt;
			return tonumber(year)&lt;br /&gt;
		end&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	local first, dash, last = text:match('^(%d+)(%D+)(%d+)$')&lt;br /&gt;
	if not (first and #first == 4) then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	dash = strip_to_nil(dash)&lt;br /&gt;
	if not (dash == '-' or dash == '–') then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	if #last ~= 4 then&lt;br /&gt;
		if #last == 2 then&lt;br /&gt;
			last = first:sub(1, 2) .. last&lt;br /&gt;
		else&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	first = tonumber(first)&lt;br /&gt;
	last = tonumber(last)&lt;br /&gt;
	if first &amp;lt; last then&lt;br /&gt;
		return first, last&lt;br /&gt;
	elseif first == last then&lt;br /&gt;
		return first&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function competition_absences(data)&lt;br /&gt;
	-- Return two tables with absent years and absent year ranges.&lt;br /&gt;
	-- Parameter data is an array of strings from template parameters, or&lt;br /&gt;
	-- numbers or strings from built-in data.&lt;br /&gt;
	-- Parameters that are blank or not numbers or strings are ignored.&lt;br /&gt;
	local absent_years, absent_ranges = {}, {}&lt;br /&gt;
	for _, item in ipairs(data) do&lt;br /&gt;
		if type(item) == 'number' then&lt;br /&gt;
			absent_years[item] = true&lt;br /&gt;
		else&lt;br /&gt;
			item = strip_to_nil(item)&lt;br /&gt;
			if type(item) == 'string' then&lt;br /&gt;
				local first, last = extract_range(item)&lt;br /&gt;
				if not first then&lt;br /&gt;
					error('Year ' .. item .. ' is not valid')&lt;br /&gt;
				end&lt;br /&gt;
				if last then&lt;br /&gt;
					table.insert(absent_ranges, {first, last})&lt;br /&gt;
				else&lt;br /&gt;
					absent_years[first] = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return absent_years, absent_ranges&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function competition_information(args)&lt;br /&gt;
	-- Return four tables with competition and team information:&lt;br /&gt;
	-- * List of competition years that the team attended or could have attended.&lt;br /&gt;
	-- * Table of disqualified years (the team was absent, but there is an&lt;br /&gt;
	--   article regarding the absent year).&lt;br /&gt;
	-- * Table of absent years (when the team did not attend).&lt;br /&gt;
	-- * List of pairs of years (absent for each year in range, inclusive).&lt;br /&gt;
	local options = make_options(args)&lt;br /&gt;
	local absences&lt;br /&gt;
	local comp_years = {}&lt;br /&gt;
	local begin_year = options.begin_year&lt;br /&gt;
	local end_year = options.end_year&lt;br /&gt;
	local competitions = options.competitions&lt;br /&gt;
	if competitions then&lt;br /&gt;
		absences = competitions[options.team] or competitions[data_old_names[options.team]]&lt;br /&gt;
		begin_year = begin_year or (absences and absences.begin_year) or 0&lt;br /&gt;
		end_year = end_year or (absences and absences.end_year) or 9999&lt;br /&gt;
		for _, y in ipairs(competitions) do&lt;br /&gt;
			if y &amp;gt; end_year then&lt;br /&gt;
				break&lt;br /&gt;
			elseif y &amp;gt;= begin_year then&lt;br /&gt;
				table.insert(comp_years, y)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		end_year = end_year or (os.date('!*t').year + options.interval)&lt;br /&gt;
		for y = begin_year, end_year, options.interval do&lt;br /&gt;
			table.insert(comp_years, y)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local disqualified_years = {}&lt;br /&gt;
	if options.disqualified_year then&lt;br /&gt;
		-- Input currently only allows entry of a single disqualified year.&lt;br /&gt;
		-- However processing works for any number of such years.&lt;br /&gt;
		disqualified_years[options.disqualified_year] = true&lt;br /&gt;
	end&lt;br /&gt;
	return comp_years, disqualified_years, competition_absences(absences or args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function gameName(year, inputName)&lt;br /&gt;
	-- Modifies output of display being sent back to the hlist&lt;br /&gt;
	--  for games that have had a name change but are still considered&lt;br /&gt;
	--  the same competition.&lt;br /&gt;
	if inputName==&amp;quot;World Athletics Championships&amp;quot; or inputName==&amp;quot;World Championships in Athletics&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 2017 then&lt;br /&gt;
			return &amp;quot;World Championships in Athletics&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;World Athletics Championships&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif (inputName==&amp;quot;British Empire Games&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;British Empire and Commonwealth Games&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;British Commonwealth Games&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;Commonwealth Games&amp;quot;) then&lt;br /&gt;
			if year &amp;lt;= 1950 then&lt;br /&gt;
				return &amp;quot;British Empire Games&amp;quot;&lt;br /&gt;
			elseif year &amp;lt;= 1966 then&lt;br /&gt;
				return &amp;quot;British Empire and Commonwealth Games&amp;quot;&lt;br /&gt;
			elseif year &amp;lt;= 1974 then&lt;br /&gt;
				return &amp;quot;British Commonwealth Games&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				return &amp;quot;Commonwealth Games&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
	elseif inputName==&amp;quot;Southeast Asian Peninsular Games&amp;quot; or inputName==&amp;quot;Southeast Asian Games&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 1975 then&lt;br /&gt;
			return &amp;quot;Southeast Asian Peninsular Games&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;Southeast Asian Games&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;Asian Indoor Games&amp;quot; or inputName==&amp;quot;Asian Indoor and Martial Arts Games&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 2009 then&lt;br /&gt;
			return &amp;quot;Asian Indoor Games&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;Asian Indoor and Martial Arts Games&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;Southern Cross Games&amp;quot; or inputName==&amp;quot;South American Games&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 1982 then&lt;br /&gt;
			return &amp;quot;Southern Cross Games&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;South American Games&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;All-Africa Games&amp;quot; or inputName==&amp;quot;African Games&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 2011 then&lt;br /&gt;
			return &amp;quot;All-Africa Games&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;African Games&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return inputName&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function teamName(year, inputName)&lt;br /&gt;
	-- Modifies output of display being sent back to the hlist&lt;br /&gt;
	--  for games that have had a name change but are still considered&lt;br /&gt;
	--  the same competition.&lt;br /&gt;
	if inputName==&amp;quot;Eswatini&amp;quot; or inputName==&amp;quot;Swaziland&amp;quot; then&lt;br /&gt;
		if year &amp;lt;= 2018 then&lt;br /&gt;
			return &amp;quot;Swaziland&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;Eswatini&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;Upper Volta&amp;quot; or inputName==&amp;quot;Burkina Faso&amp;quot; then&lt;br /&gt;
			if year &amp;lt;= 1983 then&lt;br /&gt;
				return &amp;quot;Upper Volta&amp;quot;&lt;br /&gt;
			else&lt;br /&gt;
				return &amp;quot;Burkina Faso&amp;quot;&lt;br /&gt;
			end&lt;br /&gt;
	elseif inputName==&amp;quot;Democratic Republic of the Congo&amp;quot; or inputName==&amp;quot;Zaire&amp;quot; then&lt;br /&gt;
		if year &amp;gt;= 1984 and year &amp;lt;=1996 then&lt;br /&gt;
			return &amp;quot;Zaire&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;Democratic Republic of the Congo&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif (inputName==&amp;quot;Individual Olympic Athletes&amp;quot; &lt;br /&gt;
		or inputName==&amp;quot;Independent Olympic Athletes&amp;quot; &lt;br /&gt;
		or inputName==&amp;quot;Independent Olympic Participants&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;Olympic Athletes from Russia&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;ROC&amp;quot;) then&lt;br /&gt;
		if year == 1992 or year==2014 then&lt;br /&gt;
			return &amp;quot;Independent Olympic Participants&amp;quot;&lt;br /&gt;
		elseif year == 2000 then&lt;br /&gt;
			return &amp;quot;Individual Olympic Athletes&amp;quot;&lt;br /&gt;
		elseif year == 2012 or year==2016 then&lt;br /&gt;
			return &amp;quot;Independent Olympic Athletes&amp;quot;&lt;br /&gt;
		elseif year == 2018 then&lt;br /&gt;
			return &amp;quot;Olympic Athletes from Russia&amp;quot;&lt;br /&gt;
		elseif year == 2020 or year==2022 then&lt;br /&gt;
			return &amp;quot;ROC&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return inputName&lt;br /&gt;
		end&lt;br /&gt;
	elseif (inputName==&amp;quot;Independent Paralympic Participants&amp;quot; &lt;br /&gt;
		or inputName==&amp;quot;Individual Paralympic Athletes&amp;quot; &lt;br /&gt;
		or inputName==&amp;quot;Independent Paralympic Athletes&amp;quot;&lt;br /&gt;
		or inputName==&amp;quot;RPC&amp;quot;) then&lt;br /&gt;
		if year == 1992 then&lt;br /&gt;
			return &amp;quot;Independent Paralympic Participants&amp;quot;&lt;br /&gt;
		elseif year == 2000 then&lt;br /&gt;
			return &amp;quot;Individual Paralympic Athletes&amp;quot;&lt;br /&gt;
		elseif year==2016 then&lt;br /&gt;
			return &amp;quot;Independent Paralympic Athletes&amp;quot;&lt;br /&gt;
		elseif year == 2020 or year==2022 then&lt;br /&gt;
			return &amp;quot;RPC&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return inputName&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;North Macedonia&amp;quot; or inputName==&amp;quot;Macedonia&amp;quot; then&lt;br /&gt;
		if year &amp;lt; 2019 then&lt;br /&gt;
			return &amp;quot;Macedonia&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;North Macedonia&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	elseif inputName==&amp;quot;Malaysia&amp;quot; or inputName==&amp;quot;Malaya&amp;quot; then&lt;br /&gt;
		if year &amp;lt; 1963 then&lt;br /&gt;
			return &amp;quot;Malaya&amp;quot;&lt;br /&gt;
		else&lt;br /&gt;
			return &amp;quot;Malaysia&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		return inputName&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	load_data()  -- in case this function is called by another module&lt;br /&gt;
	local hlist = require('Module:List').horizontal&lt;br /&gt;
	local competitions, disqualified_years, absent_years, absent_ranges = competition_information(args)&lt;br /&gt;
	local current_year = os.date('!*t').year&lt;br /&gt;
	local function is_absent(y)&lt;br /&gt;
		if absent_years[y] then&lt;br /&gt;
			return true&lt;br /&gt;
		end&lt;br /&gt;
		for _, range in ipairs(absent_ranges) do&lt;br /&gt;
			if range[1] &amp;lt;= y and y &amp;lt;= range[2] then&lt;br /&gt;
				return true&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	local appearances = {}&lt;br /&gt;
	local absent_first, absent_last&lt;br /&gt;
	for i = 1, #competitions + 1 do  -- +1 to handle any trailing absences&lt;br /&gt;
		local y = competitions[i]&lt;br /&gt;
		if y and is_absent(y) then&lt;br /&gt;
			if absent_first then&lt;br /&gt;
				absent_last = y&lt;br /&gt;
			else&lt;br /&gt;
				absent_first = y&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			if absent_first then&lt;br /&gt;
				table.insert(appearances,&lt;br /&gt;
					'&amp;lt;span style=&amp;quot;color:gray&amp;quot;&amp;gt;' ..&lt;br /&gt;
					(absent_last and (absent_first .. '–' .. absent_last) or absent_first) ..&lt;br /&gt;
					'&amp;lt;/span&amp;gt;')&lt;br /&gt;
				absent_first, absent_last = nil, nil&lt;br /&gt;
			end&lt;br /&gt;
			if y then&lt;br /&gt;
				local display = tostring(y)&lt;br /&gt;
				if y &amp;gt; current_year then&lt;br /&gt;
					display = '&amp;lt;i&amp;gt;' .. display .. '&amp;lt;/i&amp;gt;'&lt;br /&gt;
				end&lt;br /&gt;
				if disqualified_years[y] then&lt;br /&gt;
					display = '&amp;lt;del&amp;gt;' .. display .. '&amp;lt;/del&amp;gt;'&lt;br /&gt;
				end&lt;br /&gt;
				local compName = gameName(y, args.competition)&lt;br /&gt;
				local teamOut = teamName(y, args.team)&lt;br /&gt;
				if compName == 'FIS Alpine World Ski Championships' then&lt;br /&gt;
					table.insert(appearances, string.format(&lt;br /&gt;
					'[[%s at the %s %d|%s]]',&lt;br /&gt;
					teamOut, compName, y, display&lt;br /&gt;
					))&lt;br /&gt;
				else&lt;br /&gt;
					table.insert(appearances, string.format(&lt;br /&gt;
						'[[%s at the %d %s|%s]]',&lt;br /&gt;
						teamOut, y, compName, display&lt;br /&gt;
					))&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return hlist(appearances)&lt;br /&gt;
end&lt;br /&gt;
				&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	load_data(frame)&lt;br /&gt;
	return p._main(frame:getParent().args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>