Module:Convert: Difference between revisions

(update from sandbox per Template talk:Convert#Module version 15)
(update from sandbox per Template talk:Convert#Module version 17)
Line 1,785:
end
end
elseif en_name == 'stylein' or en_name == 'styleout' or en_name == 'qual' or en_name == 'qid' or en_name == 'input' then
en_value = loc_value ~= '' and loc_value or nil -- accept non-empty user text with no validation
if en_name == 'input' then
Line 2,046:
end
 
local function wikidata_call(parms, operation, ...)
-- Return true, s where s is the result of a Wikidata operation,
-- or return false, t where t is an error message table.
Line 2,057:
if success then
return status, result
end
if parms.opt_sortable_debug then
-- Use debug=yes to crash if an error while accessing Wikidata.
error('Error accessing Wikidata: ' .. status, 0)
end
return false, { 'cvt_wd_fail' }
Line 2,088 ⟶ 2,092:
return lookup({}, ucode, 'no_combination')
end
return wikidata_call(parms, '_listunits', ulookup)
end
local success, msg = translate_parms(parms, kv_pairs)
if not success then return false, msg end
if parms.input then
success, msg = wikidata_call(parms, '_adjustparameters', parms, 1)
if not success then return false, msg end
end
Line 2,167 ⟶ 2,171:
end
end
if word and not set_precision(word) then
parms.out_unit = word
if set_precision(strip(parms[i])) then
Line 2,861 ⟶ 2,865:
else
i = 3
end
if i > 1 and varname == 'pl' then
i = i - 1
end
vname = split(unit_table.varname, '!')[i]
Line 3,491 ⟶ 3,498:
local bad_input_mcode = in_unit_table.bad_mcode -- nil if input unit is a valid convert unit
local out_unit = parms.out_unit
if out_unit == nil or out_unit == '' or type(out_unit) == 'function' then
if bad_input_mcode or parms.opt_input_unit_only then
bad_output = ''
else
local getdef = type(out_unit) == 'function' and out_unit or get_default
success, out_unit = get_defaultgetdef(in_unit_table.valinfo[1].value, in_unit_table)
parms.out_unit = out_unit
if not success then
Anonymous user