New in PyXLL 5.11
A few pre-defined functions can be used within the config to simplify some scenarios.
Function calls are made using the same syntax as variable substition, but with arguments added.
A function call is specified using the form %(function arg1, arg2, ...)s. Note the trailing s
which is the same as for substituted variables.
The available functions are:
Functions can be nested, and substitution and environment variables can be used as arguments. For example:
[SECTION]
; Get the directory of the absulte path of some file.
; The environment variable 'USER_OVERRIDE_PATH' can be set, otherwise ./default.txt is used.
abs_dir = %(dirname %(abspath %(USER_OVERRIDE_PATH:./default.txt)s)s)s
Converts a relative path (relative to the config file being parsed) to an absolute path.
Example:
[SECTION]
option = %(abspath ./file.txt)s
Gets the directory component of a path.
Example:
[SECTION]
; option will be set to `C:\path\to`
option = %(dirname C:\path\to\file.txt)s
Gets the base name of a path. The base name is the full file name, including any extension.
Combine with filename if the file extension is not required.
Example:
[SECTION]
; option will be set to 'file.txt'
option = %(basename C:\path\to\file.txt)s
Strips any file extension from a path and returns only the filename component (including any directory).
Combine with basename if only the file name without any path component is required.
Example:
[SECTION]
; option will be set to 'file'
option = %(filename %(basename C:\path\to\file.txt)s)s