From e6550b14402ff4414a59c8b1ce0259cbb80a41cc Mon Sep 17 00:00:00 2001 From: shiyu22 Date: Thu, 25 May 2023 16:01:21 +0800 Subject: [PATCH] Update loader Signed-off-by: shiyu22 --- __init__.py | 5 +++++ loader.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 __init__.py create mode 100644 loader.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..30424ee --- /dev/null +++ b/__init__.py @@ -0,0 +1,5 @@ +from .loader import TextLoader + + +def text_loader(*args, **kwargs): + return TextLoader(*args, **kwargs) diff --git a/loader.py b/loader.py new file mode 100644 index 0000000..4805b0e --- /dev/null +++ b/loader.py @@ -0,0 +1,16 @@ +from towhee.operator import PyOperator + + +class TextLoader(PyOperator): + """ + DefaultOperator for _input and _output nodes. + """ + + def __init__(self): + #pylint: disable=useless-super-delegation + super().__init__() + + def __call__(self, *args): + if len(args) == 1: + return args[0] + return args