Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions meshroom/core/desc/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ class MrNodeType(enum.Enum):
INPUT = enum.auto()


def add_method_flag(methodName: str):
""" Decorator used to add a flag to a method. A flag is simply a variable set to True.
It will be used in this context to track whether a method is overloaded or not.

Args:
methodName (str): Name of the annotation to set
"""
def wrapper(method):
method.__annotations__[methodName] = True
return method
return wrapper


class BaseNode(object):
"""
"""
Expand Down Expand Up @@ -164,6 +177,7 @@ def postUpdate(cls, node):
"""
pass

@add_method_flag("disabled_preprocess")
def preprocess(self, node):
""" Gets invoked just before the processChunk method for the node.

Expand All @@ -172,6 +186,11 @@ def preprocess(self, node):
"""
pass

def _hasPreprocess(self):
""" Returns True if the class has a preprocess """
return not self.preprocess.__annotations__.get("disabled_preprocess", False)

@add_method_flag("disabled_postprocess")
def postprocess(self, node):
""" Gets invoked after the processChunk method for the node.

Expand All @@ -180,6 +199,10 @@ def postprocess(self, node):
"""
pass

def _hasPostprocess(self):
""" Returns True if the class has a postprocess """
return not self.postprocess.__annotations__.get("disabled_postprocess", False)

def process(self, node):
raise NotImplementedError(f'No process implementation on node: "{node.name}"')

Expand Down
Loading