Skip to content

Commit 453d744

Browse files
authored
Merge pull request #588 from wpferguson/18366_fix_apply_style_camera_decoding
fix apply_camera_style style decoding
2 parents 62e9329 + b9cc0dc commit 453d744

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

official/apply_camera_style.lua

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ local log = require "lib/dtutils.log"
5252
local MODULE <const> = "apply_camera_style"
5353
local DEFAULT_LOG_LEVEL <const> = log.info
5454
local TMP_DIR <const> = dt.configuration.tmp_dir
55-
local STYLE_PREFIX <const> = "_l10n_darktable camera styles|"
55+
local STYLE_PREFIX <const> = "_l10n_darktable|_l10n_camera styles|"
56+
local MAKER = 3
57+
local STYLE = 4
5658

5759
-- path separator
5860
local PS <const> = dt.configuration.running_os == "windows" and "\\" or "/"
@@ -165,6 +167,8 @@ local function process_pattern(pattern)
165167
pattern = string.gsub(pattern, " ", " ?")
166168
-- escape dashes
167169
pattern = string.gsub(pattern, "%-", "%%-")
170+
-- make spaces optional
171+
pattern = string.gsub(pattern, " ", " ?")
168172
-- until we end up with a set, I'll defer set processing, i.e. [...]
169173
-- anchor the pattern to ensure we don't short match
170174
pattern = "^" .. pattern .. "$"
@@ -223,25 +227,25 @@ local function get_camera_styles()
223227
log.msg(log.debug, "got " .. style.name)
224228

225229
local parts = du.split(style.name, "|")
226-
parts[2] = string.lower(parts[2])
227-
log.msg(log.debug, "maker is " .. parts[2])
230+
parts[MAKER] = string.lower(parts[MAKER])
231+
log.msg(log.debug, "maker is " .. parts[MAKER])
228232

229-
if not acs.styles[parts[2]] then
230-
acs.styles[parts[2]] = {}
231-
acs.styles[parts[2]]["styles"] = {}
232-
acs.styles[parts[2]]["patterns"] = {}
233+
if not acs.styles[parts[MAKER]] then
234+
acs.styles[parts[MAKER]] = {}
235+
acs.styles[parts[MAKER]]["styles"] = {}
236+
acs.styles[parts[MAKER]]["patterns"] = {}
233237
end
234-
if parts[3] then
235-
if not string.match(parts[3], "]") then
236-
table.insert(acs.styles[parts[2]].styles, style)
238+
if parts[STYLE] then
239+
if not string.match(parts[STYLE], "]") then
240+
table.insert(acs.styles[parts[MAKER]].styles, style)
237241
local processed_pattern = process_pattern(parts[#parts])
238-
table.insert(acs.styles[parts[2]].patterns, processed_pattern)
242+
table.insert(acs.styles[parts[MAKER]].patterns, processed_pattern)
239243
log.msg(log.debug, "pattern for " .. style.name .. " is " .. processed_pattern)
240244
else
241-
local processed_patterns = process_set(parts[3])
245+
local processed_patterns = process_set(parts[STYLE])
242246
for _, pat in ipairs(processed_patterns) do
243-
table.insert(acs.styles[parts[2]].styles, style)
244-
table.insert(acs.styles[parts[2]].patterns, pat)
247+
table.insert(acs.styles[parts[MAKER]].styles, style)
248+
table.insert(acs.styles[parts[MAKER]].patterns, pat)
245249
log.msg(log.debug, "pattern for " .. style.name .. " is " .. pat)
246250
end
247251
end

0 commit comments

Comments
 (0)