Skip to content

Add substitution to string lib #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

wpferguson
Copy link
Member

Added the variable substitution functions used in other scripts to the string library.

Enhanced the substitution functions to be equivalent to the darktable variable substitution functions, including the string manipulations. The darktable variable documentation, https://docs.darktable.org/usermanual/4.2/en/special-topics/variables/, can be used as the reference.

Fixes #386.

                     set library logging level from a user script
                     are equivalent to the darktable variable
                     substitution functions.
@wpferguson
Copy link
Member Author

Needs darktable-org/darktable#14032 and darktable-org/darktable#13965 to supply data for the variables.

@wpferguson
Copy link
Member Author

For those wishing to test/play with substitution I've attached a test script and the image I used to test with is located here, https://drive.google.com/file/d/1xb7AcG_5NSxs4W679K3w61iPqigB5Fts/view?usp=share_link. It's a play raw from pixls.

Put it in a folder and import it into darktable. Get the image id (hover over it and look in the image information panel) and replace the 1 in the dt.database.get_image(1) statement. The script prints to the console with the results.

test_substitution.zip

@wpferguson wpferguson self-assigned this Apr 22, 2023
@wpferguson wpferguson added this to the 4.8 milestone May 19, 2024
                         This makes it feature complete.  Some substitutions
                         aren't implemented since the current use case for
                         this is creating export directories.  The results
                         from the not implemented substitutions wouldn't
                         work well in path/file names (such as comma
                         separated lists or newlines).
                     Fixed VERSION_IF_MULTI.  Added safety check
                     in category to make sure we don't try and
                     read a tag field that doesn't exist.
@wpferguson
Copy link
Member Author

The string substitution is feature complete. Some of the variables aren't implemented since the main purpose of this is for use in generating path and filenames in the exporter.

However, you can use it to create formatted strings for other uses, such as GUI labels, messages, etc. If enough use is made for this purpose, then the rest of the variables can be implemented.

The variables not implemented are:

DARKTABLE.NAME
WIDTH.MAX - Available from the exporter
HEIGHT.MAX - Available from the exporter
EXIF.DATE.REGIONAL 
EXIF.TIME.REGIONAL
IMAGE.EXIF
GPS.LOCATION
RATING.ICONS
LABELS.ICONS
TAGS
SIDECAR.TXT
OPENCL.ACTIVATED
JOBCODE

Some of these are comma separated lists, others are images, and some have no meaning such as jobcode which is used internally.

@wpferguson wpferguson removed WIP Work in Progress dt 4.4 labels May 20, 2024
@wpferguson wpferguson merged commit cbe2c53 into darktable-org:master May 21, 2024
@wpferguson wpferguson deleted the add_substitution_to_string_lib branch June 9, 2024 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move variable substitution functions to a library
1 participant