Added check_min_api_function to dtutils.lua to check the minimum version of the lua API required for a script to run. This is intended to replace the API check done with darktable.configuration.check_version(), which requires changing each time the API version changes. check_min_api_version should work for all API version changes unless backward compatibility is broken. All the scripts using darktable.configuration.check_version() were changed to use check_min_api_version().

This commit is contained in:
Bill Ferguson
2019-02-18 19:46:11 -05:00
parent 391b3b9e4f
commit 451c7fb956
44 changed files with 262 additions and 45 deletions

View File

@@ -48,7 +48,12 @@
]]
local darktable = require("darktable")
darktable.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
local du = require "lib/dtutils"
if not du.check_min_api_version("3.0.0") then
darktable.print("ERROR:LabelsToTags failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Lua 5.3 no longer has "unpack" but "table.unpack"
unpack = unpack or table.unpack

View File

@@ -34,8 +34,15 @@ A file explorer window will be opened for each selected file at the file's locat
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local dsys = require "lib/dtutils.system"
--Check API version
if not du.check_min_api_version("5.0.0") then
dt.print("ERROR:OpenInExplorer failed to load. Lua API version 5.0.0 or greater required.")
return
end
--Detect OS and modify accordingly--
local proper_install = false
if dt.configuration.running_os == "windows" then

View File

@@ -37,13 +37,17 @@ GPLv2
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
local filelib = require "lib/dtutils.file"
-- Forward declare the functions
local autostyle_apply_one_image,autostyle_apply_one_image_event,autostyle_apply,exiftool_attribute,capture
-- Tested it with darktable 1.6.1 and darktable git from 2014-01-25
darktable.configuration.check_version(...,{2,0,2},{2,1,0},{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("2.0.2") then
darktable.print("ERROR:autostyle failed to load. Lua API version 2.0.2 or later required.")
return
end
-- Receive the event triggered
function autostyle_apply_one_image_event(event,image)

View File

@@ -37,12 +37,16 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
-- not a number
local NaN = 0/0
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:clear_GPS failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain

View File

@@ -37,10 +37,15 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:copy_attach_detach_tags failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("copy_attach_detach_tags",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -33,9 +33,13 @@ USAGE
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
-- Tested with darktable 2.0.1
darktable.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("2.0.0") then
darktable.print("ERROR:cr2hdr failed to load. Lua API version 2.0.0 or later required.")
return
end
local queue = {}
local processed_files = {}

View File

@@ -60,13 +60,17 @@ Pops up multiple CMD windows on windows machienes
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dsys = require "lib/dtutils.system"
local gettext = dt.gettext
local preferences_version = 1 --When releasing an update increment this number by one if changes have been made to the preferences structure that would require a re-initialization
-- works with LUA API version 5.0.0
dt.configuration.check_version(...,{5,0,0})
if not du.check_min_api_version("5.0.0") then
dt.print("ERROR:enfuseAdvanced failed to load. Lua API version 5.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("enfuseAdvanced",dt.configuration.config_dir.."/lua/")

View File

@@ -24,10 +24,14 @@ Dependencies:
--]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local gettext = dt.gettext
dt.configuration.check_version(...,{4,0,0},{5,0,0})
if not du.check_min_api_version("4.0.0") then
dt.print("ERROR:fujifilm_ratings failed to load. Lua API version 4.0.0 or later required.")
return
end
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")

View File

@@ -33,11 +33,15 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:geoJSON_export failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoJSON_export",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -26,11 +26,15 @@ require "geoToolbox"
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:geoToolbox failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("geoToolbox",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -64,12 +64,16 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local dtsys = require "lib/dtutils.system"
local gettext = dt.gettext
local gimp_widget = nil
dt.configuration.check_version(...,{5,0,0})
if not du.check_min_api_version("5.0.0") then
dt.print("ERROR:gimp failed to load. Lua API version 5.0.0 or greater required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gimp",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -27,7 +27,10 @@ local df = require "lib/dtutils.file"
local dl = require "lib/dtutils"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not dl.check_min_api_version("3.0.0") then
dt.print("ERROR:gpx-export failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("gpx_export",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -36,6 +36,7 @@ This plugin will add a new storage option and calls hugin after export.
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
local dtsys = require "lib/dtutils.system"
@@ -54,7 +55,10 @@ local executable_table = {"hugin", "hugin_executor", "pto_gen"}
local PQ = dt.configuration.running_os == "windows" and '"' or "'"
-- works with darktable API version from 5.0.0 on
dt.configuration.check_version(...,{5,0,0})
if not du.check_min_api_version("5.0.0") then
dt.print("ERROR:hugin failed to load. Lua API version 5.0.0 or greater required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("hugin",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -71,7 +71,10 @@ local job = nil
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
-- works with LUA API version 5.0.0
dt.configuration.check_version(...,{5,0,0})
if not du.check_min_api_version("5.0.0") then
dt.print("ERROR:image_stack failed to load. Lua API version 5.0.0 or greater required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("image_stack",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -37,11 +37,15 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:kml_export failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("kml_export",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -36,9 +36,13 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("2.0.0") then
dt.print("ERROR:passport_guide failed to load. Lua API version 2.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("passport_guide",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -39,6 +39,7 @@ format (all fields can be the empty string):
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
@@ -56,7 +57,10 @@ if not df.check_if_bin_exists("pdflatex") then
return
end
dt.configuration.check_version(...,{4,0,0},{5,0,0})
if not du.check_min_api_version("4.0.0") then
dt.print("ERROR:pdf_slideshow failed to load. Lua API version 4.0.0 or greater required.")
return
end
dt.preferences.register
("pdf_slideshow","open with","string",

View File

@@ -44,12 +44,16 @@ USAGE
local dt = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:quicktag failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("quicktag",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -39,9 +39,13 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
-- added version check
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:rate_group failed to load. Lua API version 3.0.0 or later required.")
return
end
local function apply_rating(rating)
local images = dt.gui.action_images

View File

@@ -29,8 +29,15 @@ Changes
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
-- check API version
if not du.check_min_api_version("3.0.0") then
darktable.print("ERROR:rename_tags failed to load. Lua API version 3.0.0 or later required.")
return
end
-- GUI entries
local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" }
local new_tag = darktable.new_widget("entry") { tooltip = "Enter new tag" }

View File

@@ -19,9 +19,13 @@ Enable selection of untagged images (darktable|* tags are ignored)
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local gettext = dt.gettext
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("3.0.0") then
dt.print("ERROR:select_untagged failed to load. Lua API version 3.0.0 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("select_untagged",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -25,11 +25,15 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
dt.configuration.check_version(...,{2,0,2},{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("2.0.2") then
dt.print("ERROR:slideshowMusic failed to load. Lua API version 2.0.2 or greater required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("slideshowMusic",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -31,11 +31,15 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
require "official/yield"
local gettext = dt.gettext
dt.configuration.check_version(...,{2,0,1},{3,0,0},{4,0,0},{5,0,0})
if not du.check_min_api_version("2.0.1") then
dt.print("ERROR:video_mencoder failed to load. Lua API version 2.0.1 or later required.")
return
end
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("video_mencoder",dt.configuration.config_dir.."/lua/locale/")