Plugin Interface¶
Contract¶
Plugins are simply an object that implements the appropriate contract, which is a build method that follows the following signature:
Types¶
The following types are passed to plugins during the build.
-
class
pysmith.
BuildInfo
[source]¶ Contains information for the current build.
-
metadata
: dict(str, object)¶ The global metadata for the build.
-
files
: dict(str, FileInfo)¶ The files uses the file path relative to the source folder as the key and
FileInfo
objects as the values. Keys can be added or removed by the plugin, and files can be modified. At the end of the processing pipeline, files will be written based on the keys relative to the destination directory.
-
get_files_by_pattern
(match_pattern)[source]¶ Retrieves files from the
files
object using the given glob pattern.- Parameters
match_pattern (str) – The pattern to pass to
fnmatch.filter()
.
-
get_files_by_regex
(regex)[source]¶ Retrieves files from the
files
object using the given regex.- Parameters
regex (
re.Pattern
) – The regular expression to use, compiled usingre.compile()
.
-
Logging¶
If plugins wish to log message, they should create a logger using logging.getLogger()
, passing
pysmith.plugin.<plugin_name>
as the logger name. enable_logging()
configures logging
under the pysmith
namespace, so plugins should use this name for logging to be configured correctly.
Utils¶
The following utilities are also available for plugins to use.