From 646f6bd0ae8f2dc83439a57b404c879e1c81bb81 Mon Sep 17 00:00:00 2001 From: marco44 Date: Tue, 10 Feb 2015 18:23:05 +0100 Subject: [PATCH] Corrections per discussion on the github merge --- contrib/autostyle.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 2a0f2fb..d8086a5 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -49,9 +49,18 @@ function autostyle_apply_one_image (image) local tag,value,style_name=string.match(darktable.preferences.read("autostyle","exif_tag","string"),"(%g+)%s*=%s*(%g+)%s*=>%s*(%g+)") -- check they all exist (correct syntax) - assert (tag,"EXIF TAG not found in " .. darktable.preferences.read("autostyle","exif_tag","string")); - assert (value,"value to match not found in " .. darktable.preferences.read("autostyle","exif_tag","string")); - assert (style_name,"style name not found in " .. darktable.preferences.read("autostyle","exif_tag","string")); + if (not tag) then + darktable.print("EXIF TAG not found in " .. darktable.preferences.read("autostyle","exif_tag","string")) + return + end + if (not value) then + darktable.print("value to match not found in " .. darktable.preferences.read("autostyle","exif_tag","string")) + return + end + if (not style_name) then + darktable.print("style name not found in " .. darktable.preferences.read("autostyle","exif_tag","string")) + return + end -- First find the style (we have its name) local styles= darktable.styles @@ -61,6 +70,9 @@ function autostyle_apply_one_image (image) style=s end end + if (not style) then + darktable.print("style not found for autostyle: " .. style_name) + end -- Apply the style to image, if it is tagged local auto_dr_attr= exiftool_attribute(image.path .. '/' .. image.filename,tag); @@ -92,6 +104,8 @@ end function get_stdout(cmd) -- Open the command, for reading local fd = assert(io.popen(cmd, 'r')) + -- yield to other lua threads until data is ready to be read + coroutine.yield("FILE_READABLE",fd) -- slurp the whole file local data = assert(fd:read('*a'))