From 525baf8cccdca38f951beac633c51aada5445d2c Mon Sep 17 00:00:00 2001 From: Sermet Pekin Date: Wed, 21 Aug 2024 07:42:38 +0300 Subject: [PATCH] ResultChat class was modified --- evdschat/core/result.py | 45 ++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/evdschat/core/result.py b/evdschat/core/result.py index 80afe62..884425a 100644 --- a/evdschat/core/result.py +++ b/evdschat/core/result.py @@ -4,12 +4,13 @@ from evdspy.EVDSlocal.index_requests.get_series_indexes_exp import Result from enum import Enum -from typing import Any +from typing import Any + class Status(Enum): - success= 1 - failed= 0 - unknown= 2 + success = 1 + failed = 0 + unknown = 2 @dataclass @@ -19,7 +20,8 @@ class ResultChat(Result): def __str__(self): content = super().__str__() - return f""" + return ( + f""" ! get_series_exp function returns instance of this class status : {self.status.name} => Indicates the status of the result @@ -29,7 +31,9 @@ def __str__(self): write : Callable => Creates an Excel file with data and metadata in two sheets to_excel : Callable => Same as write to meet pandas to_excel function - """ + content + """ + + content + ) def create_result(result: Any, status: Status = None, reason: str = "") -> ResultChat: @@ -37,16 +41,33 @@ def create_result(result: Any, status: Status = None, reason: str = "") -> Resul status = Status.unknown if isinstance(result, Result): - return ResultChat(data=result.data, metadata=result.metadata, write=result.write, status=status, reason=reason) + return ResultChat( + data=result.data, + metadata=result.metadata, + write=result.write, + status=status, + reason=reason, + ) if isinstance(result, pd.DataFrame): - r = Result(data=result, metadata=pd.DataFrame(), write=None) # Replace None with a suitable write function if available - return ResultChat(data=r.data, metadata=r.metadata, write=r.write, status=status, reason=reason) + r = Result(data=result, metadata=pd.DataFrame(), write=None) + return ResultChat( + data=r.data, + metadata=r.metadata, + write=r.write, + status=status, + reason=reason, + ) if result is None: - r = Result(data=pd.DataFrame(), metadata=pd.DataFrame(), write=None) # Replace None with a suitable write function if available - return ResultChat(data=r.data, metadata=r.metadata, write=r.write, status=status, reason=reason) - + r = Result(data=pd.DataFrame(), metadata=pd.DataFrame(), write=None) + return ResultChat( + data=r.data, + metadata=r.metadata, + write=r.write, + status=status, + reason=reason, + ) __all__ = ["ResultChat"]