From eff8e7a63ff77e80fff0ce53fe56f5a010f55ab5 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Wed, 14 Apr 2021 20:20:46 -0700 Subject: [PATCH] Added template_function.py to examples --- examples/template_function.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/template_function.py diff --git a/examples/template_function.py b/examples/template_function.py new file mode 100644 index 00000000..a1c203b4 --- /dev/null +++ b/examples/template_function.py @@ -0,0 +1,26 @@ +""" Example showing how to use a custom function for osxphotos {function} template """ + +import pathlib +from typing import List, Union + +import osxphotos + + +def example(photo: osxphotos.PhotoInfo, **kwargs) -> Union[List, str]: + """ example function for {function} template + + Args: + photo: osxphotos.PhotoInfo object + **kwargs: not currently used, placeholder to keep functions compatible with possible changes to {function} + + Returns: + str or list of str of values that should be substituted for the {function} template + """ + + filename = pathlib.Path(photo.original_filename).stem + if photo.hasadjustments: + filename += "#" + if photo.favorite: + filename += "!" + + return filename