From 8b714edb6755c73289c352ceff5cd9a2b6995d01 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Wed, 20 Feb 2019 00:22:05 -0500 Subject: [PATCH] Changed check_min_api_version() to print error messages and throw an error if the minimum api is not satisfied. Updated the scripts to reflect the changed check_min_api_version(). --- contrib/LabelsToTags.lua | 5 +---- contrib/OpenInExplorer.lua | 5 +---- contrib/autostyle.lua | 5 +---- contrib/clear_GPS.lua | 5 +---- contrib/copy_attach_detach_tags.lua | 5 +---- contrib/cr2hdr.lua | 5 +---- contrib/enfuseAdvanced.lua | 5 +---- contrib/fujifilm_ratings.lua | 5 +---- contrib/geoJSON_export.lua | 5 +---- contrib/geoToolbox.lua | 5 +---- contrib/gimp.lua | 5 +---- contrib/gpx_export.lua | 5 +---- contrib/hugin.lua | 5 +---- contrib/image_stack.lua | 5 +---- contrib/kml_export.lua | 5 +---- contrib/passport_guide.lua | 5 +---- contrib/pdf_slideshow.lua | 5 +---- contrib/quicktag.lua | 5 +---- contrib/rate_group.lua | 5 +---- contrib/rename-tags.lua | 5 +---- contrib/select_untagged.lua | 5 +---- contrib/slideshowMusic.lua | 5 +---- contrib/video_mencoder.lua | 5 +---- examples/gettextExample.lua | 5 +---- examples/hello_world.lua | 5 +---- examples/moduleExample.lua | 5 +---- examples/multi_os.lua | 5 +---- examples/preferenceExamples.lua | 5 +---- examples/printExamples.lua | 5 +---- examples/running_os.lua | 5 +---- lib/dtutils.lua | 30 +++++++++++++++-------------- lib/dtutils/file.lua | 4 +--- official/check_for_updates.lua | 5 +---- official/copy_paste_metadata.lua | 5 +---- official/delete_long_tags.lua | 5 +---- official/delete_unused_tags.lua | 5 +---- official/enfuse.lua | 5 +---- official/generate_image_txt.lua | 5 +---- official/image_path_in_ui.lua | 5 +---- official/save_selection.lua | 5 +---- official/selection_to_pdf.lua | 5 +---- tools/executable_manager.lua | 2 ++ tools/gen_i18n_mo.lua | 2 ++ tools/get_lib_manpages.lua | 5 +---- tools/get_libdoc.lua | 5 +---- tools/plugin_manager.lua | 1 + tools/script_manager.lua | 5 +---- 47 files changed, 64 insertions(+), 185 deletions(-) create mode 120000 tools/plugin_manager.lua diff --git a/contrib/LabelsToTags.lua b/contrib/LabelsToTags.lua index 15a44f3..044e920 100644 --- a/contrib/LabelsToTags.lua +++ b/contrib/LabelsToTags.lua @@ -50,10 +50,7 @@ local darktable = require("darktable") 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 +du.check_min_api_version("3.0.0", "LabelsToTags") -- Lua 5.3 no longer has "unpack" but "table.unpack" unpack = unpack or table.unpack diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index b223c71..380838b 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -38,10 +38,7 @@ 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 +du.check_min_api_version("5.0.0", "OpenInExplorer") --Detect OS and modify accordingly-- local proper_install = false diff --git a/contrib/autostyle.lua b/contrib/autostyle.lua index 34b95f0..0b3891f 100644 --- a/contrib/autostyle.lua +++ b/contrib/autostyle.lua @@ -44,10 +44,7 @@ local filelib = require "lib/dtutils.file" 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 -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 +du.check_min_api_version("2.0.2", "autostyle") -- Receive the event triggered function autostyle_apply_one_image_event(event,image) diff --git a/contrib/clear_GPS.lua b/contrib/clear_GPS.lua index 5d3fdf7..3172495 100644 --- a/contrib/clear_GPS.lua +++ b/contrib/clear_GPS.lua @@ -43,10 +43,7 @@ local gettext = dt.gettext -- not a number local NaN = 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 +du.check_min_api_version("3.0.0", "clear_GPS") -- Tell gettext where to find the .mo file translating messages for a particular domain diff --git a/contrib/copy_attach_detach_tags.lua b/contrib/copy_attach_detach_tags.lua index 3f60d9e..2fb8330 100644 --- a/contrib/copy_attach_detach_tags.lua +++ b/contrib/copy_attach_detach_tags.lua @@ -42,10 +42,7 @@ local debug = require "darktable.debug" local gettext = dt.gettext -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 +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/") diff --git a/contrib/cr2hdr.lua b/contrib/cr2hdr.lua index 5705751..7f7a5bc 100644 --- a/contrib/cr2hdr.lua +++ b/contrib/cr2hdr.lua @@ -36,10 +36,7 @@ local darktable = require "darktable" local du = require "lib/dtutils" -- Tested with darktable 2.0.1 -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 +du.check_min_api_version("2.0.0", "cr2hdr") local queue = {} local processed_files = {} diff --git a/contrib/enfuseAdvanced.lua b/contrib/enfuseAdvanced.lua index 377db49..f24a6d0 100644 --- a/contrib/enfuseAdvanced.lua +++ b/contrib/enfuseAdvanced.lua @@ -67,10 +67,7 @@ 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 -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 +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/") diff --git a/contrib/fujifilm_ratings.lua b/contrib/fujifilm_ratings.lua index 294623e..6cf92c9 100644 --- a/contrib/fujifilm_ratings.lua +++ b/contrib/fujifilm_ratings.lua @@ -28,10 +28,7 @@ local du = require "lib/dtutils" local df = require "lib/dtutils.file" local gettext = dt.gettext -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 +du.check_min_api_version("4.0.0", "fujifilm_ratings") gettext.bindtextdomain("fujifilm_ratings", dt.configuration.config_dir.."/lua/locale/") diff --git a/contrib/geoJSON_export.lua b/contrib/geoJSON_export.lua index 99edc31..4834bb0 100644 --- a/contrib/geoJSON_export.lua +++ b/contrib/geoJSON_export.lua @@ -38,10 +38,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/contrib/geoToolbox.lua b/contrib/geoToolbox.lua index 0092289..19e3c7c 100644 --- a/contrib/geoToolbox.lua +++ b/contrib/geoToolbox.lua @@ -31,10 +31,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/contrib/gimp.lua b/contrib/gimp.lua index 0210e01..d7528d1 100644 --- a/contrib/gimp.lua +++ b/contrib/gimp.lua @@ -70,10 +70,7 @@ local dtsys = require "lib/dtutils.system" local gettext = dt.gettext local gimp_widget = nil -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 +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/") diff --git a/contrib/gpx_export.lua b/contrib/gpx_export.lua index b137d58..b6fed82 100644 --- a/contrib/gpx_export.lua +++ b/contrib/gpx_export.lua @@ -27,10 +27,7 @@ local df = require "lib/dtutils.file" local dl = require "lib/dtutils" local gettext = dt.gettext -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 +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/") diff --git a/contrib/hugin.lua b/contrib/hugin.lua index 8b9887d..83ec3be 100644 --- a/contrib/hugin.lua +++ b/contrib/hugin.lua @@ -55,10 +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 -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 +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/") diff --git a/contrib/image_stack.lua b/contrib/image_stack.lua index ebf87dd..de3e0c0 100644 --- a/contrib/image_stack.lua +++ b/contrib/image_stack.lua @@ -71,10 +71,7 @@ local job = nil local PS = dt.configuration.running_os == "windows" and "\\" or "/" -- works with LUA API 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 +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/") diff --git a/contrib/kml_export.lua b/contrib/kml_export.lua index 2b932da..0f83f6d 100644 --- a/contrib/kml_export.lua +++ b/contrib/kml_export.lua @@ -42,10 +42,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/contrib/passport_guide.lua b/contrib/passport_guide.lua index 442a28f..72611eb 100644 --- a/contrib/passport_guide.lua +++ b/contrib/passport_guide.lua @@ -39,10 +39,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local gettext = dt.gettext -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 +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/") diff --git a/contrib/pdf_slideshow.lua b/contrib/pdf_slideshow.lua index eae9141..f01b014 100644 --- a/contrib/pdf_slideshow.lua +++ b/contrib/pdf_slideshow.lua @@ -57,10 +57,7 @@ if not df.check_if_bin_exists("pdflatex") then return end -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 +du.check_min_api_version("4.0.0", "pdf_slideshow") dt.preferences.register ("pdf_slideshow","open with","string", diff --git a/contrib/quicktag.lua b/contrib/quicktag.lua index cfc072c..31a4b79 100644 --- a/contrib/quicktag.lua +++ b/contrib/quicktag.lua @@ -50,10 +50,7 @@ local debug = require "darktable.debug" local gettext = dt.gettext -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 +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/") diff --git a/contrib/rate_group.lua b/contrib/rate_group.lua index 8d5019f..d820d94 100644 --- a/contrib/rate_group.lua +++ b/contrib/rate_group.lua @@ -42,10 +42,7 @@ local dt = require "darktable" local du = require "lib/dtutils" -- added version check -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 +du.check_min_api_version("3.0.0", "rate_group") local function apply_rating(rating) local images = dt.gui.action_images diff --git a/contrib/rename-tags.lua b/contrib/rename-tags.lua index c839b6b..a0c70be 100644 --- a/contrib/rename-tags.lua +++ b/contrib/rename-tags.lua @@ -33,10 +33,7 @@ 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 +du.check_min_api_version("3.0.0", "rename-tags") -- GUI entries local old_tag = darktable.new_widget("entry") { tooltip = "Enter old tag" } diff --git a/contrib/select_untagged.lua b/contrib/select_untagged.lua index 8ab4508..2db6dae 100644 --- a/contrib/select_untagged.lua +++ b/contrib/select_untagged.lua @@ -22,10 +22,7 @@ local dt = require "darktable" local du = require "lib/dtutils" local gettext = dt.gettext -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 +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/") diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 5563617..90d6bc3 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -30,10 +30,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/contrib/video_mencoder.lua b/contrib/video_mencoder.lua index ec90ffc..1ad71d8 100644 --- a/contrib/video_mencoder.lua +++ b/contrib/video_mencoder.lua @@ -36,10 +36,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/examples/gettextExample.lua b/examples/gettextExample.lua index 788911e..c6eda49 100644 --- a/examples/gettextExample.lua +++ b/examples/gettextExample.lua @@ -56,10 +56,7 @@ local dt = require "darktable" local du = require "lib/dtutils" --check API version -if not du.check_min_api_version("3.0.0") then - dt.print("ERROR:gettextExample failed to load. Lua API version 3.0.0 or greater required.") - return -end +du.check_min_api_version("3.0.0", "gettextExample") -- Not translated Text dt.print_error("Hello World!") diff --git a/examples/hello_world.lua b/examples/hello_world.lua index 23d9027..11a287e 100644 --- a/examples/hello_world.lua +++ b/examples/hello_world.lua @@ -29,10 +29,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("2.0.0") then - dt.print("ERROR:hello_world failed to load. Lua API version 2.0.0 or greater required.") - return -end +du.check_min_api_version("2.0.0", "hello_world") dt.print("hello, world") diff --git a/examples/moduleExample.lua b/examples/moduleExample.lua index 4dec3fd..ecc2ac3 100644 --- a/examples/moduleExample.lua +++ b/examples/moduleExample.lua @@ -33,10 +33,7 @@ https://www.darktable.org/lua-api/index.html.php#darktable_new_widget local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("3.0.0") then - dt.print("ERROR:moduleExample failed to load. Lua API version 3.0.0 or greater required.") - return -end +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} diff --git a/examples/multi_os.lua b/examples/multi_os.lua index ac429a8..96b60c2 100644 --- a/examples/multi_os.lua +++ b/examples/multi_os.lua @@ -86,10 +86,7 @@ end screen stating that you couldn't load because the minimum api version wasn't met. ]] -if not du.check_min_api_version("5.0.0") then - dt.print("ERROR:mulit_os failed to load: Lua API version 5.0.0 or greater required.") - return -end +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 diff --git a/examples/preferenceExamples.lua b/examples/preferenceExamples.lua index 5abb76a..9710b95 100644 --- a/examples/preferenceExamples.lua +++ b/examples/preferenceExamples.lua @@ -24,10 +24,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("2.0.1") then - dt.print("ERROR:preferenceExamples failed to load. Lua API version 2.0.1 or greater required.") - return -end +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 diff --git a/examples/printExamples.lua b/examples/printExamples.lua index a37e9e1..074a5db 100644 --- a/examples/printExamples.lua +++ b/examples/printExamples.lua @@ -22,10 +22,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("5.0.0") then - dt.print("ERROR:printExamples failed to load. Lua API version 5.0.0 or greater required.") - return -end +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). diff --git a/examples/running_os.lua b/examples/running_os.lua index 0879a73..632c033 100644 --- a/examples/running_os.lua +++ b/examples/running_os.lua @@ -28,10 +28,7 @@ prints the operating system local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("5.0.0") then - dt.print("ERROR:running_os not loaded. Lua API version 5.0.0 or greater required.") - return -end +du.check_min_api_version("5.0.0", "running_os") dt.print("You are running: "..dt.configuration.running_os) diff --git a/lib/dtutils.lua b/lib/dtutils.lua index fc077be..f64998d 100644 --- a/lib/dtutils.lua +++ b/lib/dtutils.lua @@ -37,33 +37,35 @@ dtutils.libdoc.functions["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) - min_api - string - the api version that the application was written for (example: "5.0.0")]], + 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 to the log. + 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 + 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 = [[]], - Example = [[check_min_api_version("5.0.0") returns true if the api is greater or equal to 5.0.0 otherwise an - error message is printed to the log and false is returned.]], + 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) +function dtutils.check_min_api_version(min_api, script_name) local current_api = dt.configuration.api_version_string - if min_api <= current_api then - return true - else + 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) - return false + 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 diff --git a/lib/dtutils/file.lua b/lib/dtutils/file.lua index 5c4a114..69bf932 100644 --- a/lib/dtutils/file.lua +++ b/lib/dtutils/file.lua @@ -25,9 +25,7 @@ dtutils_file.libdoc = { local gettext = dt.gettext -if not du.check_min_api_version("5.0.0") then - return -end +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/") diff --git a/official/check_for_updates.lua b/official/check_for_updates.lua index cfcf914..712daab 100644 --- a/official/check_for_updates.lua +++ b/official/check_for_updates.lua @@ -32,10 +32,7 @@ local du = require "lib/dtutils" local https = require "ssl.https" local cjson = require "cjson" -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 +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, diff --git a/official/copy_paste_metadata.lua b/official/copy_paste_metadata.lua index e417f61..ca7ccae 100644 --- a/official/copy_paste_metadata.lua +++ b/official/copy_paste_metadata.lua @@ -28,10 +28,7 @@ USAGE local dt = require "darktable" local du = require "lib/dtutils" -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 +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 diff --git a/official/delete_long_tags.lua b/official/delete_long_tags.lua index cf4ebfd..9ab1a28 100644 --- a/official/delete_long_tags.lua +++ b/official/delete_long_tags.lua @@ -31,10 +31,7 @@ all tags longer than the given length will be automatically deleted at every res local dt = require "darktable" 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 +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", diff --git a/official/delete_unused_tags.lua b/official/delete_unused_tags.lua index 8ceaa7e..4c11423 100644 --- a/official/delete_unused_tags.lua +++ b/official/delete_unused_tags.lua @@ -29,10 +29,7 @@ all tags that are not used will be automatically deleted at every restart local dt = require "darktable" local du = require "lib/dtutils" -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 +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 = {} diff --git a/official/enfuse.lua b/official/enfuse.lua index 8f960f5..2bc4161 100644 --- a/official/enfuse.lua +++ b/official/enfuse.lua @@ -38,10 +38,7 @@ local df = require "lib/dtutils.file" require "official/yield" local gettext = dt.gettext -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 +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/") diff --git a/official/generate_image_txt.lua b/official/generate_image_txt.lua index 2e0d13b..a214a2a 100644 --- a/official/generate_image_txt.lua +++ b/official/generate_image_txt.lua @@ -39,10 +39,7 @@ local du = require "lib/dtutils" require "darktable.debug" require "official/yield" -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 +du.check_min_api_version("2.1.0", "generate_image_txt") dt.preferences.register("generate_image_txt", "enabled", diff --git a/official/image_path_in_ui.lua b/official/image_path_in_ui.lua index 074bb6a..18e57ca 100644 --- a/official/image_path_in_ui.lua +++ b/official/image_path_in_ui.lua @@ -31,10 +31,7 @@ This plugin will add a widget at the bottom of the left column in lighttable mod local dt = require "darktable" 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 +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"} diff --git a/official/save_selection.lua b/official/save_selection.lua index 32555a2..1d71ea9 100644 --- a/official/save_selection.lua +++ b/official/save_selection.lua @@ -36,10 +36,7 @@ increase it if you need more temporary selection buffers local dt = require "darktable" 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 +du.check_min_api_version("2.0.0", "save_selection") local buffer_count = 5 diff --git a/official/selection_to_pdf.lua b/official/selection_to_pdf.lua index dcc797f..f6fbfe8 100644 --- a/official/selection_to_pdf.lua +++ b/official/selection_to_pdf.lua @@ -37,10 +37,7 @@ local dt = require "darktable" local du = require "lib/dtutils" require "official/yield" -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 +du.check_min_api_version("2.0.0", "selection_to_pdf") dt.preferences.register ("selection_to_pdf","Open with","string", diff --git a/tools/executable_manager.lua b/tools/executable_manager.lua index 4c8f68d..5f79074 100644 --- a/tools/executable_manager.lua +++ b/tools/executable_manager.lua @@ -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 diff --git a/tools/gen_i18n_mo.lua b/tools/gen_i18n_mo.lua index d3b5b5b..d032484 100644 --- a/tools/gen_i18n_mo.lua +++ b/tools/gen_i18n_mo.lua @@ -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 "/" diff --git a/tools/get_lib_manpages.lua b/tools/get_lib_manpages.lua index 6e21bba..9ea2f69 100644 --- a/tools/get_lib_manpages.lua +++ b/tools/get_lib_manpages.lua @@ -10,10 +10,7 @@ local df = require "lib/dtutils.file" local log = require "lib/dtutils.log" local libname = nil -if not du.check_min_api_version("3.0.0") then - dt.print("ERROR: get_lib_manpages failed to load. Lua API version 3.0.0 or greater required.") - return -end +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"} diff --git a/tools/get_libdoc.lua b/tools/get_libdoc.lua index 47689cf..ed0813a 100644 --- a/tools/get_libdoc.lua +++ b/tools/get_libdoc.lua @@ -7,10 +7,7 @@ local dt = require "darktable" local du = require "lib/dtutils" -if not du.check_min_api_version("3.0.0") then - dt.print("ERROR: get_libdoc failed to load. Lua API version 3.0.0 or greater required.") - return -end +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"} diff --git a/tools/plugin_manager.lua b/tools/plugin_manager.lua new file mode 120000 index 0000000..bc0e1bf --- /dev/null +++ b/tools/plugin_manager.lua @@ -0,0 +1 @@ +/home/bill/src/plugins/lua-scripts/tools/plugin_manager.lua \ No newline at end of file diff --git a/tools/script_manager.lua b/tools/script_manager.lua index d0aabd2..e16b0cc 100644 --- a/tools/script_manager.lua +++ b/tools/script_manager.lua @@ -455,10 +455,7 @@ end -- api check -if not du.check_min_api_version("5.0.0") then - dt.print("ERROR:script_manager failed to load. Lua API version 5.0.0 or greater required.") - return -end +du.check_min_api_version("5.0.0") -- set up tables to contain all the widgets and choices