diff --git a/pydfirram/core/base.py b/pydfirram/core/base.py index e8b7448..f746e7c 100644 --- a/pydfirram/core/base.py +++ b/pydfirram/core/base.py @@ -331,7 +331,6 @@ def __init__(self, operating_system: OperatingSystem, dump_file: Path): self.validate_dump_file(dump_file) self.os = operating_system self.plugins: list[PluginEntry] = self.get_all_plugins() - print(self.plugins) self.dump_file = dump_file self.context: Optional[Context] = None self.temp_data = None diff --git a/pydfirram/core/renderer.py b/pydfirram/core/renderer.py index 8f67047..f7107c8 100644 --- a/pydfirram/core/renderer.py +++ b/pydfirram/core/renderer.py @@ -40,8 +40,7 @@ # allow no PascalCase naming style and "lambda may not be necessary" # pylint: disable=W0108,C0103 # (todo) : switch to PascalCase - -class TreeGrid_to_json(V3CLIRenderer): # type: ignore +class TreeGrid_to_json(V3CLIRenderer): # type: ignore """ simple TreeGrid to JSON """ _type_renderers: Any = { @@ -72,8 +71,8 @@ def get_render_options(self) -> list[V3RenderOption]: """ return [] - # (fixme) : this methods should return nothing as defined in V3CLIRenderer - def render(self, grid: V3TreeGrid) -> list[V3TreeNode]: + # (fixme): This method should return nothing as defined in V3CLIRenderer + def render(self, grid: V3TreeGrid) -> dict[str, Any]: """ Render the TreeGrid to JSON format. @@ -84,15 +83,14 @@ def render(self, grid: V3TreeGrid) -> list[V3TreeNode]: Dict: The JSON representation of the TreeGrid. """ final_output: tuple[ - dict[str, list[V3TreeNode]], - list[V3TreeNode], + dict[str, dict[str, Any]], + list[dict[str, Any]], ] = ({}, []) - def visitor( node: V3TreeNode, - accumulator: tuple[dict[str,Any], list[dict[str,Any]]], - ) -> tuple[dict[str,Any], list[dict[str,Any]]]: + accumulator: tuple[dict[str, Any], list[dict[str, Any]]], + ) -> tuple[dict[str, Any], list[dict[str, Any]]]: """ A visitor function to process each node in the TreeGrid. @@ -102,7 +100,7 @@ def visitor( The accumulator containing the accumulated results. Returns: - Tuple[Dict[str,Any], List[Dict[str, Any]]]: The updated + Tuple[Dict[str, Any], List[Dict[str, Any]]]: The updated accumulator. """ acc_map = accumulator[0] @@ -111,8 +109,8 @@ def visitor( for column_index, column in enumerate(grid.columns): renderer = self._type_renderers.get( - key = column.type, - default = self._type_renderers["default"], + column.type, + self._type_renderers["default"] ) data = renderer( list(node.values)[column_index], @@ -132,11 +130,11 @@ def visitor( grid.populate(visitor, final_output) else: grid.visit( - node = None, - function = visitor, - initial_accumulator = final_output, + node=None, + function=visitor, + initial_accumulator=final_output, ) - return final_output[1] + return {"data": final_output[1]} class Renderer(): @@ -159,7 +157,7 @@ def __init__(self, data: Any) -> None: """ self.data = data - def to_list(self) -> dict[str,Any]: + def to_list(self): """ Convert the data to a list format. @@ -174,7 +172,8 @@ def to_list(self) -> dict[str,Any]: """ try: # (fixme) : `render()` should return nothing - return TreeGrid_to_json().render(self.data) + parsed_data : dict[str, Any] = TreeGrid_to_json().render(self.data) + return parsed_data.get("data") except Exception as e: logger.error("Impossible to render data in dictionary form.") raise e @@ -237,7 +236,7 @@ def to_df(self,max_row: bool = False) -> pd.DataFrame: if max_row: pd.set_option('display.max_rows', None) pd.set_option('display.max_columns', None) - return pd.DataFrame(data_as_dict) + return pd.DataFrame(data_as_dict.get("data")) except Exception as e: logger.error("Data cannot be rendered as a DataFrame.") raise e diff --git a/tests/config.py b/tests/config.py index 42546aa..f5357aa 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,3 +1,3 @@ from pathlib import Path -DUMP_FILE = Path("./data/dump.raw") +DUMP_FILE = Path("/home/braguette/dataset_memory/ch2.dmp") diff --git a/tests/test_volatility_windows_function.py b/tests/test_volatility_windows_function.py index 277ba64..4ee34e8 100644 --- a/tests/test_volatility_windows_function.py +++ b/tests/test_volatility_windows_function.py @@ -32,7 +32,6 @@ def test_volatility_pslist(generic_instance: Generic) -> None: output: Renderer = generic_instance.pslist() assert isinstance(output, Renderer), "Output is not an instance of Renderer" pslist_content: List[Any] = output.to_list() - print(type(pslist_content)) assert isinstance(pslist_content, list), "Output content is not a list" assert len(pslist_content) > 0, "Output list is empty" logger.success("TEST PASSED!")