Jump to content

Module:Infobox road/errors

Permanently protected module
From Wikipedia, the free encyclopedia
local p = {}
local getArgs = require('Module:Arguments').getArgs
local util = require("Module:Road data/util")
local yesno = require('Module:Yesno')
local routeModule = require("Module:Infobox road/route")
local parserModule = require("Module:Road data/parser")
local parser = parserModule.parser
local format = mw.ustring.format
local frame = mw.getCurrentFrame()

local function country(args)
	local state = args.state or args.province
	local country
	local countryModule = mw.loadData("Module:Road data/countrymask")
	local country = args.country or countryModule[state]
	
	return country
end

local function countries(args)
	if not country(args) then
		if args.countries then
			return "no"
		end
	elseif country(args) == 'EUR' or country(args) == 'AFRICA' or country(args) == 'ASIA' or country(args) == 'SAD' then
		if args.countries then
			return "no"
		end
	end
end

local function states(args)
	if country(args) == 'BRA' or country(args) == 'MEX' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.countries or args.county or args.departments or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function australia(args)
	if country(args) == 'AUS' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function canada(args)
	if country(args) == 'CAN' then
		if args.borough or args.boroughs or args.cantons or args.communes or args.countries or args.departments or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.oblasts or args.okrugs or args.prefectures or args.republics or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions then
			return "yes"
		else
			return "no"
		end
	end
end

local function china(args)
	if country(args) == 'CHN' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.countries or args.departments or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function france(args)
	if country(args) == 'FRA' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function india(args)
	if country(args) == 'IND' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.subcounties or args.subprefectures or args.subregions then
			return "yes"
		else
			return "no"
		end
	end
end

local function netherlands(args)
	if country(args) == 'NLD' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function russia(args)
	if country(args) == 'RUS' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.districts or args.divisions or args.governorates or args.indep_city or args.indep_cities or args.island or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function spain(args)
	if country(args) == 'ESP' then
		if args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.counties or args.countries or args.county or args.departments or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function unitedKingdom(args)
	if country(args) == 'GBR' then
		if args.borough or args.cantons or args.communes or args.communities or args.countries or args.county or args.departments or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then
			return "yes"
		else
			return "no"
		end
	end
end

local function unitedStates(args)
	if country(args) == 'USA' then
		if args.areas or args.cantons or args.cities  or args.communes or args.communities or args.countries or args.departments or args.destinations or args.districts or args.divisions or args.federal_cities or args.governorates or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.oblasts or args.okrugs or args.photo or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.subcounties or args.subprefectures or args.subregions or args.territories or args.towns or args.villages then
			return "yes"
		else
			return "no"
		end
	end
end

local function trigger(args)
	if countries(args) == 'yes' or states(args) == 'yes' or australia(args) == 'yes' or canada(args) == 'yes' or china(args) == 'yes' or france(args) == 'yes' or india(args) == 'yes' or netherlands(args) == 'yes' or russia(args) == 'yes' or spain(args) == 'yes' or unitedKingdom(args) == 'yes' or unitedStates(args) == 'yes' then
		return true
	else
		return false
	end
end

function p.errors(frame)
	local args = getArgs(frame)
	local pagename = frame:getTitle()
	
	if trigger(args) == true then
		return string.format("[[Category:Infobox road transclusion errors|%% %s]]", pagename)
	else
		return nil
	end
end

return p


--args.areas or args.borough or args.boroughs or args.cantons or args.communes or args.communities or args.counties or args.countries or args.county or args.departments or args.districts or args.divisions or args.federal_cities or args.governorates or args.indep_city or args.indep_cities or args.island or args.krais or args.label1 or args.label2 or args.label3 or args.label4 or args.label5 or args.lga or args.location1 or args.location2 or args.location3 or args.location4 or args.location5 or args.locations or args.municipalities or args.municipality or args.oblasts or args.okrugs or args.parish or args.parishes or args.prefectures or args.provinces or args.regions or args.republics or args.rural_municipalities or args.sheadings or args.states or args.subcounties or args.subprefectures or args.subregions or args.territories then