Module pyinotify :: Class ProcessEvent
[hide private]
[frames] | no frames]

Class ProcessEvent

source code


Process events objects, can be specialized via subclassing, thus its behavior can be overriden:

Note: you should not override __init__ in your subclass instead define a my_init() method, this method will be called from the constructor of this class with its optional parameters.

  1. Provide specialized individual methods, e.g. process_IN_DELETE for processing a precise type of event (e.g. IN_DELETE in this case).
  2. Or/and provide methods for processing events by 'family', e.g. process_IN_CLOSE method will process both IN_CLOSE_WRITE and IN_CLOSE_NOWRITE events (if process_IN_CLOSE_WRITE and process_IN_CLOSE_NOWRITE aren't defined though).
  3. Or/and override process_default for catching and processing all the remaining types of events.
Instance Methods [hide private]
 
__init__(self, pevent=None, **kargs)
Enable chaining of ProcessEvent instances.
source code
 
my_init(self, **kargs)
This method is called from base constructor ProcessEvent.__init__().
source code
bool
__call__(self, event)
To behave like a functor the object must be callable.
source code
 
nested_pevent(self) source code
 
process_IN_Q_OVERFLOW(self, event)
By default this method only reports warning messages, you can overredide it by subclassing ProcessEvent and implement your own process_IN_Q_OVERFLOW method.
source code
 
process_default(self, event)
Default processing event method.
source code

Inherited from _ProcessEvent: __repr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  pevent = None
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, pevent=None, **kargs)
(Constructor)

source code 

Enable chaining of ProcessEvent instances.

Parameters:
  • pevent (callable) - Optional callable object, will be called on event processing (before self).
  • kargs (dict) - This constructor is a implemented as a template method delegating its optionals keyworded arguments to the method my_init().
Overrides: object.__init__

my_init(self, **kargs)

source code 

This method is called from base constructor ProcessEvent.__init__(). This method is useless here and is meant to be redifined in a subclass of ProcessEvent. In effect, when subclassing just override this method if you want to provide custom initialization to your subclass' instance. You MUST pass keyword arguments though.

Parameters:
  • kargs (dict) - optional delegated arguments from __init__().

__call__(self, event)
(Call operator)

source code 

To behave like a functor the object must be callable. This method is a dispatch method. Its lookup order is:

  1. process_MASKNAME method
  2. process_FAMILY_NAME method
  3. otherwise calls process_default
Parameters:
  • event - Event to be processed.
Returns: bool
By convention when used from the ProcessEvent class:
  • Returning False or None (default value) means keep on executing next chained functors (see chain.py example).
  • Returning True instead means do not execute next processing functions.
Raises:
Overrides: _ProcessEvent.__call__
(inherited documentation)

process_IN_Q_OVERFLOW(self, event)

source code 

By default this method only reports warning messages, you can overredide it by subclassing ProcessEvent and implement your own process_IN_Q_OVERFLOW method. The actions you can take on receiving this event is either to update the variable max_queued_events in order to handle more simultaneous events or to modify your code in order to accomplish a better filtering diminishing the number of raised events. Because this method is defined, IN_Q_OVERFLOW will never get transmitted as arguments to process_default calls.

Parameters:
  • event (dict) - IN_Q_OVERFLOW event.

process_default(self, event)

source code 

Default processing event method. By default does nothing. Subclass ProcessEvent and redefine this method in order to modify its behavior.

Parameters:
  • event (Event instance) - Event to be processed. Can be of any type of events but IN_Q_OVERFLOW events (see method process_IN_Q_OVERFLOW).