This module provides a "safe" version of mw.title
's .fileExists
method, that does not raise an error when the expensive parser function limit is exceeded.
Использование[]
local fileExists = require('Module:FileExists')
-- ...
local file
if fileExists('File:My example file.png') then
file = 'File:My example file.png'
end
local libraryUtil = require('libraryUtil')
return function(file)
libraryUtil.checkTypeMulti('fileExists', 1, file, { 'string', 'table' })
if type(file) == 'string' then
file = mw.title.new(file)
end
local success, result = pcall(function(x) return x.fileExists end, file)
return (success and result)
end