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:
@@ -28,10 +28,14 @@ USAGE
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
local https = require "ssl.https"
|
||||
local cjson = require "cjson"
|
||||
|
||||
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:check_for_updates not loaded. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- compare two version strings of the form "major.minor.patch"
|
||||
-- returns -1, 0, 1 if the first version is smaller, equal, greater than the second version,
|
||||
|
||||
@@ -26,8 +26,12 @@ USAGE
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
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_paste_metadata not loaded. Lua API version 3.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- set this to "false" if you don't want to overwrite metadata fields
|
||||
-- (title, description, creator, publisher and rights) that are already set
|
||||
|
||||
@@ -29,7 +29,12 @@ all tags longer than the given length will be automatically deleted at every res
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("2.0.0") then
|
||||
dt.print("ERROR:delete_long_tags not loaded. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.preferences.register("delete_long_tags", "length", "integer",
|
||||
"maximum length of tags to keep",
|
||||
|
||||
@@ -27,8 +27,12 @@ all tags that are not used will be automatically deleted at every restart
|
||||
]]
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
dt.configuration.check_version(...,{5,0,0})
|
||||
if not du.check_min_api_version("5.0.0") then
|
||||
dt.print("ERROR:delete_unused_tags not loaded. Lua API version 5.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- deleting while iterating the tags list seems to break the iterator!
|
||||
local unused_tags = {}
|
||||
|
||||
@@ -33,11 +33,15 @@ TODO
|
||||
]]
|
||||
|
||||
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:enfuse not loaded. Lua API version 3.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Tell gettext where to find the .mo file translating messages for a particular domain
|
||||
gettext.bindtextdomain("enfuse",dt.configuration.config_dir.."/lua/locale/")
|
||||
|
||||
@@ -35,10 +35,14 @@ USAGE
|
||||
-- * make filenames with double quotes (") work
|
||||
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
require "darktable.debug"
|
||||
require "official/yield"
|
||||
|
||||
dt.configuration.check_version(...,{2,1,0},{3,0,0},{4,0,0},{5,0,0})
|
||||
if not du.check_min_api_version("2.1.0") then
|
||||
dt.print("ERROR:generate_image_txt not loaded. Lua API version 2.1.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.preferences.register("generate_image_txt",
|
||||
"enabled",
|
||||
|
||||
@@ -29,7 +29,12 @@ This plugin will add a widget at the bottom of the left column in lighttable mod
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("2.0.0") then
|
||||
dt.print("ERROR:image_path_in_ui not loaded. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"}
|
||||
|
||||
|
||||
@@ -34,7 +34,12 @@ increase it if you need more temporary selection buffers
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
dt.configuration.check_version(...,{2,0,0},{3,0,0},{4,0,0},{5,0,0})
|
||||
local du = require "lib/dtutils"
|
||||
|
||||
if not du.check_min_api_version("2.0.0") then
|
||||
dt.print("ERROR:save_selection not loaded. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
local buffer_count = 5
|
||||
|
||||
|
||||
@@ -34,9 +34,13 @@ Plugin allows you to choose how many thumbnails you need per row
|
||||
|
||||
]]
|
||||
local dt = require "darktable"
|
||||
local du = require "lib/dtutils"
|
||||
require "official/yield"
|
||||
|
||||
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:selection_to_pdf not loaded. Lua API version 2.0.0 or greater required.")
|
||||
return
|
||||
end
|
||||
|
||||
dt.preferences.register
|
||||
("selection_to_pdf","Open with","string",
|
||||
|
||||
Reference in New Issue
Block a user