diff --git a/qlib/finco/task.py b/qlib/finco/task.py index 4a7f8415b..106418eea 100644 --- a/qlib/finco/task.py +++ b/qlib/finco/task.py @@ -1,3 +1,5 @@ +import os + from pathlib import Path from typing import Any, List from qlib.typehint import Literal @@ -60,6 +62,30 @@ class ActionTask(Task): return "success" +class SummarizeTask(Task): + def execution(self) -> Any: + output_path = '' + + def parse2txt(self, path) -> List: + file_list = [] + path = Path.cwd().joinpath(path) + for root, dirs, files in os.walk(path): + for filename in files: + file_path = os.path.join(root, filename) + print(file_path) + file_list.append(file_path) + + result = [] + for file in file_list: + postfix = file.split('.')[-1] + if postfix in ['txt', 'py', 'log']: + with open(file) as f: + content = f.read() + print(content) + result.append({'postfix': postfix, 'content': content}) + return result + + class WorkflowManager: """This manange the whole task automation workflow including tasks and actions""" diff --git a/qlib/finco/test_sumarize.py b/qlib/finco/test_sumarize.py new file mode 100644 index 000000000..f5efc771d --- /dev/null +++ b/qlib/finco/test_sumarize.py @@ -0,0 +1,14 @@ +import unittest + +from qlib.finco.task import SummarizeTask + + +class TestSummarize(unittest.TestCase): + def test_parse2txt(self): + task = SummarizeTask() + resp = task.parse2txt('') + print(resp) + + +if __name__ == '__main__': + unittest.main()