Module:Wikidata: Difference between revisions

Content deleted Content added
Prune more code duplication in code for qualifiers
Prune code duplication of callers of parseInput -- also updates getDateValue to use arbitrary access as a side effect
Line 480:
end
 
local function parseInput(frame, qid)
local qid = frame.args.qid
if qid and (#qid == 0) then qid = nil end
local propertyID = mw.text.trim(frame.args[1] or "")
local input_parm = mw.text.trim(frame.args[2] or "")
Line 562 ⟶ 564:
delim = delimdefault
end
local qidgo, errorOrentity, claims, propertyID = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, claims, propertyID = parseInput(frame, qid)
if not go then
return errorOrentity
Line 573:
-- Same as above, but uses the short name property for label if available.
p.getValueShortName = function(frame)
local go, errorOrentity, claims, propertyID = parseInput(frame, nil)
if not go then
return errorOrentity
Line 658:
-- This is used to get a value like 'male' (for property p21) which won't be linked and numbers without the thousand separators
p.getRawValue = function(frame)
local qidgo, errorOrentity, claims, propertyID = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, claims, propertyID = parseInput(frame, qid)
if not go then
return errorOrentity
Line 676 ⟶ 674:
-- This is used to get the unit name for the numeric value returned by getRawValue
p.getUnits = function(frame)
local qidgo, errorOrentity, claims, propertyID = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, claims, propertyID = parseInput(frame, qid)
if not go then
return errorOrentity
Line 692 ⟶ 688:
-- This is used to get the unit's QID to use with the numeric value returned by getRawValue
p.getUnitID = function(frame)
local qidgo, errorOrentity, claims = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, claims = parseInput(frame, qid)
if not go then
return errorOrentity
Line 731 ⟶ 725:
local date_format = mw.text.trim(frame.args[3] or i18n["datetime"]["default-format"])
local date_addon = mw.text.trim(frame.args[4] or i18n["datetime"]["default-addon"])
local go, errorOrentity, claims = parseInput(frame, nil)
if not go then
return errorOrentity
Line 770 ⟶ 764:
local sep = mw.text.trim(frame.args[3] or " ")
local imgsize = mw.text.trim(frame.args[4] or "frameless")
local qidgo, errorOrentity, claims = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, claims = parseInput(frame, qid)
if not go then
return errorOrentity
Line 893 ⟶ 885:
 
p.getPropertyIDs = function(frame)
local qidgo, errorOrentity, propclaims = parseInput(frame.args.qid)
if qid and (#qid == 0) then qid = nil end
local go, errorOrentity, propclaims = parseInput(frame, qid)
if not go then
return errorOrentity