Module:MOS intervals: Difference between revisions

Sintel (talk | contribs)
import gcd from utils
Ganaram inukshuk (talk | contribs)
Added mos prefix lookup
Line 43: Line 43:
end
end
return return_string
return return_string
end
-- Helper function
-- Extracts the prefix from the mos module, without the dash and without any text after that
-- May need to revisit to clean up code since this splits text at the "-"
function p.get_mos_prefix(scale_sig)
local unparsed = mos.tamnams_prefix[scale_sig]
local parsed = {}
for entry in string.gmatch(unparsed, '([^-]+)') do
local trimmed = entry:gsub("^%s*(.-)%s*$", "%1")
table.insert(parsed, trimmed) -- Add to array
end
return parsed[1]
end
end


Line 65: Line 80:
local scale_sig = mos.as_string(input_mos)
local scale_sig = mos.as_string(input_mos)
-- Is there a mos prefix?
-- Default param for mos prefix
-- If "NONE" is given, no prefix will be used
-- If left blank, try to find the appropriate mos prefix, or else defualt to "mos"
-- If not left blank, use the prefix passed in instead
local mos_prefix = "mos"
local mos_prefix = "mos"
if frame.args['MOS Prefix'] == "NONE" then
if frame.args['MOS Prefix'] == "NONE" then
mos_prefix = ""
mos_prefix = ""
elseif string.len(frame.args['MOS Prefix']) > 0 then
elseif string.len(frame.args['MOS Prefix']) == 0 then
mos_prefix = frame.args['MOS Prefix']
mos_prefix_lookup = get_mos_prefix(scale_sig)
if string.len(mos_prefix_lookup) ~= 0 then
mos_prefix = mos_prefix_lookup
end
else
mos_prefix = farme.args['MOS Prefix']
end
end