diff --git a/openpype/pipeline/lib/__init__.py b/openpype/pipeline/lib/__init__.py index 1bb65be79b..e2c15cbd2d 100644 --- a/openpype/pipeline/lib/__init__.py +++ b/openpype/pipeline/lib/__init__.py @@ -1,3 +1,8 @@ +from .events import ( + BaseEvent, + BeforeWorkfileSave +) + from .attribute_definitions import ( AbtractAttrDef, UnknownDef, @@ -9,6 +14,9 @@ from .attribute_definitions import ( __all__ = ( + "BaseEvent", + "BeforeWorkfileSave", + "AbtractAttrDef", "UnknownDef", "NumberDef", diff --git a/openpype/pipeline/lib/events.py b/openpype/pipeline/lib/events.py new file mode 100644 index 0000000000..8e7dcbd70e --- /dev/null +++ b/openpype/pipeline/lib/events.py @@ -0,0 +1,38 @@ +"""Events holding data about specific event.""" + + +class BaseEvent: + """Base event object. + + Can be used to anything because data are not much specific. Only required + argument is topic which defines why event is happening and may be used for + filtering. + + Arg: + topic (str): Identifier of event. + data (Any): Data specific for event. Dictionary is recommended. + """ + _data = {} + + def __init__(self, topic, data=None): + self._topic = topic + if data is None: + data = {} + self._data = data + + @property + def data(self): + return self._data + + @property + def topic(self): + return self._topic + + +class BeforeWorkfileSave(BaseEvent): + """Before workfile changes event data.""" + def __init__(self, new_workfile, workdir): + super(BeforeWorkfileSave, self).__init__("before.workfile.save") + + self.workfile_path = new_workfile + self.workdir_path = workdir