Merge pull request #166 from wpferguson/check_min_api_version

check_min_api_version
This commit is contained in:
wpferguson
2019-02-20 11:50:36 -05:00
committed by GitHub
47 changed files with 141 additions and 45 deletions

View File

@@ -48,7 +48,9 @@
]]
local darktable = require("darktable")
darktable.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
local du = require "lib/dtutils"
du.check_min_api_version("3.0.0", "LabelsToTags")
-- Lua 5.3 no longer has "unpack" but "table.unpack"
unpack = unpack or table.unpack

View File

@@ -34,8 +34,12 @@ 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
du.check_min_api_version("5.0.0", "OpenInExplorer")
--Detect OS and modify accordingly--
local proper_install = false
if dt.configuration.running_os == "windows" then

View File

@@ -37,13 +37,14 @@ 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})
du.check_min_api_version("2.0.2", "autostyle")
-- Receive the event triggered
function autostyle_apply_one_image_event(event,image)

View File

@@ -37,12 +37,13 @@
]]
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})
du.check_min_api_version("3.0.0", "clear_GPS")
-- Tell gettext where to find the .mo file translating messages for a particular domain

View File

@@ -37,10 +37,12 @@ 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})
du.check_min_api_version("3.0.0", "copy_attach_detach_tags")
-- 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,10 @@ 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})
du.check_min_api_version("2.0.0", "cr2hdr")
local queue = {}
local processed_files = {}

View File

@@ -60,13 +60,14 @@ 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})
du.check_min_api_version("5.0.0", "enfuseAdvanced")
-- 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,11 @@ 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})
du.check_min_api_version("4.0.0", "fujifilm_ratings")
gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/")

View File

@@ -33,11 +33,12 @@ 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})
du.check_min_api_version("3.0.0", "geoJSON_export")
-- 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,12 @@ 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})
du.check_min_api_version("3.0.0", "geoToolbox")
-- 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,13 @@
]]
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})
du.check_min_api_version("5.0.0", "gimp")
-- 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,7 @@ 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})
dl.check_min_api_version("3.0.0", "gpx-export")
-- 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,7 @@ 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})
du.check_min_api_version("5.0.0", "hugin")
-- 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,7 @@ 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})
du.check_min_api_version("5.0.0", "image_stack")
-- 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,12 @@ 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})
du.check_min_api_version("3.0.0", kml_export)
-- 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,10 @@ 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})
du.check_min_api_version("2.0.0", "passport_guide")
-- 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,7 @@ if not df.check_if_bin_exists("pdflatex") then
return
end
dt.configuration.check_version(...,{4,0,0},{5,0,0})
du.check_min_api_version("4.0.0", "pdf_slideshow")
dt.preferences.register
("pdf_slideshow","open with","string",

View File

@@ -44,12 +44,13 @@ 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})
du.check_min_api_version("3.0.0", "quicktag")
-- 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,10 @@
]]
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})
du.check_min_api_version("3.0.0", "rate_group")
local function apply_rating(rating)
local images = dt.gui.action_images

View File

@@ -29,8 +29,12 @@ Changes
]]
local darktable = require "darktable"
local du = require "lib/dtutils"
local debug = require "darktable.debug"
-- check API version
du.check_min_api_version("3.0.0", "rename-tags")
-- 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,10 @@ 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})
du.check_min_api_version("3.0.0", "select_untagged")
-- 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,12 @@ 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})
du.check_min_api_version("2.0.2", "slideshowMusic")
-- 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,12 @@ 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})
du.check_min_api_version("2.0.1", "video_mencoder")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("video_mencoder",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -53,7 +53,10 @@ LUA ERROR Hallo Welt!
]]
local dt = require "darktable"
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}))
local du = require "lib/dtutils"
--check API version
du.check_min_api_version("3.0.0", "gettextExample")
-- Not translated Text
dt.print_error("Hello World!")

View File

@@ -27,7 +27,9 @@ USAGE
]]
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"
du.check_min_api_version("2.0.0", "hello_world")
dt.print("hello, world")

View File

@@ -31,8 +31,9 @@ https://www.darktable.org/lua-api/index.html.php#darktable_new_widget
]]
local dt = require "darktable"
local du = require "lib/dtutils"
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
du.check_min_api_version("3.0.0", "moduleExample")
-- add a new lib
local check_button = dt.new_widget("check_button"){label = "MyCheck_button", value = true}

View File

@@ -80,12 +80,13 @@ local function _(msgid)
end
--[[
Specify the version(s) of the lua API that this script is compatible with. This script uses new
features released in the latest version of darktable and is only compatible with the latest API version.
Multiple API versions may be specified, seperated by commas.
Check that the current api version is greater than or equal to the specified minimum. If it's not
then du.check_min_api_version will print an error to the log and return false. If the minimum api is
not met, then just refuse to load and return. Optionally, you could print an error message to the
screen stating that you couldn't load because the minimum api version wasn't met.
]]
dt.configuration.check_version(...,{5,0,0})
du.check_min_api_version("5.0.0", "multi_os")
--[[
copy_image_attributes is a local subroutine to copy image attributes in the database from the raw image

View File

@@ -22,7 +22,9 @@ USAGE
* require this script from your main lua file
]]
local dt = require "darktable"
dt.configuration.check_version(...,{2,0,1},{3,0,0},{4,0,0},{5,0,0})
local du = require "lib/dtutils"
du.check_min_api_version("2.0.1", "preferenceExamples")
dt.preferences.register("preferenceExamples", -- script: This is a string used to avoid name collision in preferences (i.e namespace). Set it to something unique, usually the name of the script handling the preference.
"preferenceExamplesString", -- name

View File

@@ -20,7 +20,9 @@ USAGE
* require this file from your main lua config file:
]]
local dt = require "darktable"
dt.configuration.check_version(...,{5,0,0})
local du = require "lib/dtutils"
du.check_min_api_version("5.0.0", "printExamples")
-- Will print a string to the darktable control log (the long
-- overlayed window that appears over the main panel).

View File

@@ -26,7 +26,9 @@ prints the operating system
]]
local dt = require "darktable"
dt.configuration.check_version(...,{5,0,0})
local du = require "lib/dtutils"
du.check_min_api_version("5.0.0", "running_os")
dt.print("You are running: "..dt.configuration.running_os)

View File

@@ -32,7 +32,42 @@ local dt = require "darktable"
local log = require "lib/dtutils.log"
dt.configuration.check_version(...,{5,0,0})
dtutils.libdoc.functions["check_min_api_version"] = {
Name = [[check_min_api_version]],
Synopsis = [[check the minimum required api version against the current api version]],
Usage = [[local du = require "lib/dtutils"
local result = du.check_min_api_version(min_api, script_name)
min_api - string - the api version that the application was written for (example: "5.0.0")
script_name - string - the name of the script]],
Description = [[check_min_api_version compares the minimum api required for the appllication to
run against the current api version. The minimum api version is typically the api version that
was current when the application was created. If the minimum api version is not met, then an
error message is printed saying the script_name failed to load, then an error is thrown causing the
program to stop executing.
This function is intended to replace darktable.configuration.check_version(). The application code
won't have to be updated each time the api changes because this only checks the minimum version required.]],
Return_Value = [[result - true if the minimum api version is available, false if not.]],
Limitations = [[When using the default handler on a script being executed from the luarc file, the error thrown
will stop the luarc file from executing any remaining statements. This limitation does not apply to script_manger.]],
Example = [[check_min_api_version("5.0.0") does nothing if the api is greater or equal to 5.0.0 otherwise an
error message is printed and an error is thrown stopping execution of the script.]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils.check_min_api_version(min_api, script_name)
local current_api = dt.configuration.api_version_string
if min_api > current_api then
dt.print_error("This application is written for lua api version " .. min_api .. " or later.")
dt.print_error("The current lua api version is " .. current_api)
dt.print("ERROR: " .. script_name .. " failed to load. Lua API version " .. min_api .. " or later required.")
error("Minimum API " .. min_api .. " not met for " .. script_name .. ".", 0)
end
end
dtutils.libdoc.functions["split"] = {
Name = [[split]],

View File

@@ -1,5 +1,6 @@
local dtutils_file = {}
local dt = require "darktable"
local du = require "lib/dtutils"
local ds = require "lib/dtutils.string"
local log = require "lib/dtutils.log"
@@ -24,7 +25,7 @@ dtutils_file.libdoc = {
local gettext = dt.gettext
dt.configuration.check_version(...,{5,0,0})
du.check_min_api_version("5.0.0", "dtutils.file")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("dtutils.file",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -28,10 +28,11 @@ 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})
du.check_min_api_version("2.0.0", "check_for_updates")
-- 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,

View File

@@ -26,8 +26,9 @@ USAGE
]]
local dt = require "darktable"
local du = require "lib/dtutils"
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
du.check_min_api_version("3.0.0", "copy_paste_metadata")
-- set this to "false" if you don't want to overwrite metadata fields
-- (title, description, creator, publisher and rights) that are already set

View File

@@ -29,7 +29,9 @@ 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"
du.check_min_api_version("2.0.0", "delete_long_tags")
dt.preferences.register("delete_long_tags", "length", "integer",
"maximum length of tags to keep",

View File

@@ -27,8 +27,9 @@ 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})
du.check_min_api_version("5.0.0", "delete_unused_tags")
-- deleting while iterating the tags list seems to break the iterator!
local unused_tags = {}

View File

@@ -33,11 +33,12 @@ 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})
du.check_min_api_version("3.0.0", "enfuse")
-- Tell gettext where to find the .mo file translating messages for a particular domain
gettext.bindtextdomain("enfuse",dt.configuration.config_dir.."/lua/locale/")

View File

@@ -35,10 +35,11 @@ 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})
du.check_min_api_version("2.1.0", "generate_image_txt")
dt.preferences.register("generate_image_txt",
"enabled",

View File

@@ -29,7 +29,9 @@ 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"
du.check_min_api_version("2.0.0", "image_path_in_ui")
local main_label = dt.new_widget("label"){selectable = true, ellipsize = "middle", halign = "start"}

View File

@@ -34,7 +34,9 @@ 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"
du.check_min_api_version("2.0.0", "save_selection")
local buffer_count = 5

View File

@@ -34,9 +34,10 @@ 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})
du.check_min_api_version("2.0.0", "selection_to_pdf")
dt.preferences.register
("selection_to_pdf","Open with","string",

View File

@@ -32,6 +32,8 @@ local dt = require "darktable"
local du = require "lib/dtutils"
local df = require "lib/dtutils.file"
du.check_min_api_version("5.0.0", "executable_manager")
local PS = dt.configuration.running_os == "windows" and "\\" or "/"
local gettext = dt.gettext

View File

@@ -30,6 +30,8 @@ local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
local dtsys = require "lib/dtutils.system"
du.check_min_api_version("5.0.0", "gen_I18n_mo")
-- figure out the path separator
local PS = dt.configuration.running_os == "windows" and "\\" or "/"

View File

@@ -10,7 +10,7 @@ local df = require "lib/dtutils.file"
local log = require "lib/dtutils.log"
local libname = nil
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
du.check_min_api_version("3.0.0", "get_lib_manpages")
local keys = {"Name", "Synopsis", "Usage", "Description", "Return_Value", "Limitations",
"Example", "See_Also", "Reference", "License", "Copyright"}

View File

@@ -5,8 +5,9 @@
]]
local dt = require "darktable"
local du = require "lib/dtutils"
dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0})
du.check_min_api_version("3.0.0", "get_libdoc")
local keys = {"Name", "Synopsis", "Usage", "Description", "Return_Value", "Limitations",
"Example", "See_Also", "Reference", "License", "Copyright"}

1
tools/plugin_manager.lua Symbolic link
View File

@@ -0,0 +1 @@
/home/bill/src/plugins/lua-scripts/tools/plugin_manager.lua

View File

@@ -455,7 +455,7 @@ end
-- api check
dt.configuration.check_version(...,{5,0,0})
du.check_min_api_version("5.0.0")
-- set up tables to contain all the widgets and choices