mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-02 10:31:00 +08:00
add parse method for summarization;
This commit is contained in:
@@ -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"""
|
||||
|
||||
|
||||
14
qlib/finco/test_sumarize.py
Normal file
14
qlib/finco/test_sumarize.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user