Merge pull request #600 from geigerzaehler/after-write-hook

Add after_write plugin event
This commit is contained in:
geigerzaehler 2014-03-10 17:31:12 +01:00
commit 4a5a203907
3 changed files with 7 additions and 0 deletions

View file

@ -392,6 +392,7 @@ class Item(LibModel):
# The file has a new mtime.
self.mtime = self.current_mtime()
plugins.send('after_write', item=self)
# Files themselves.

View file

@ -25,6 +25,7 @@ New stuff:
* :doc:`/plugins/echonest`: Echo Nest similarity now weights the tempo in
better proportion to other metrics. Also, options were added to specify
custom thresholds and output formats. Thanks to Adam M.
* Added the :ref:`after_write <plugin_events>` plugin event.
Fixes:

View file

@ -90,6 +90,8 @@ You can add command-line options to your new command using the ``parser`` member
of the ``Subcommand`` class, which is an ``OptionParser`` instance. Just use it
like you would a normal ``OptionParser`` in an independent script.
.. _plugin_events:
Listen for Events
^^^^^^^^^^^^^^^^^
@ -141,6 +143,9 @@ currently available are:
* *write*: called with an ``Item`` object just before a file's metadata is
written to disk (i.e., just before the file on disk is opened).
* *after_write*: called with an ``Item`` object after a file's metadata is
written to disk (i.e., just after the file on disk is closed).
* *import_task_start*: called when before an import task begins processing.
Parameters: ``task`` (an `ImportTask`) and ``session`` (an `ImportSession`).