Content deleted Content added
No edit summary |
Increased efficiency a bit |
||
Line 134:
function State:getShortName(itemID)
return p.
end
Line 517:
function State:appendOutput(value, rankPos)
local done = false
if rankPos == 1 then
self.outPreferred[#self.outPreferred + 1] = value
if self.singleValue then
done = true
end
elseif rankPos == 2 then
self.outNormal[#self.outNormal + 1] = value
if self.singleValue and not self.bestRank and self.maxRank == 2 then
done = true
end
elseif rankPos == 3 then
self.outDeprecated[#self.outDeprecated + 1] = value
if self.singleValue and not self.bestRank and self.maxRank == 3 then
done = true
end
end
return done
end
Line 592 ⟶ 608:
local _ = State.new()
local entity, propertyID, claims, rankPos, value, done
local nextArg = mw.text.trim(args[1] or "")
local nextIndex = 2
Line 615 ⟶ 631:
if _:rankMatches(rankPos) then
value = _:getValue(v.mainsnak, _.withUnit, _.linked)
if value then
done = _:appendOutput(value, rankPos) if done then
break
end
end
end
end
Line 631 ⟶ 652:
_ = _ or State.new()
local entity, propertyID, propertyValue, qualifierID, claims, qualifiers, rankPos, outValue, outInter, outQualifier, done
local nextArg = mw.text.trim(args[1] or "")
local nextIndex = 2
Line 681 ⟶ 702:
if _.propertyWithQualifier then
-- get the property value first
outValue = _:getValue(v.mainsnak, _.withUnit, _.linked)
end
Line 686 ⟶ 708:
if v.qualifiers then qualifiers = v.qualifiers[qualifierID] end
if (not _.propertyWithQualifier or outValue) and qualifiers then
-- get bare qualifier, or qualifier connected to the property if it had a value
for k2, v2 in pairs(v.qualifiers[qualifierID]) do
outInter = _:getValue(v2, _.withUnit, _.linked)
if outInter then
if not _.propertyWithQualifier then
done = _:appendOutput(outInter, rankPos)
if done then
break
end
else
outQualifier[#outQualifier + 1] = outInter
Line 698 ⟶ 724:
end
if
outQualifier = table.concat(outQualifier, ", ")
Line 706 ⟶ 732:
end
done = _:appendOutput(outValue, rankPos)
end
if done then
break
end
end
|