From fe01e040019a0ff000fcacee6334fbaac5f0f379 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Tue, 7 Jun 2022 06:16:28 +0200 Subject: [PATCH] Dealt with a couple todos. --- src/bootstraparse/modules/export.py | 10 +++++----- src/bootstraparse/modules/sitecreator.py | 2 +- tests/modules/test_export.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bootstraparse/modules/export.py b/src/bootstraparse/modules/export.py index 049990f..2fa2fa0 100644 --- a/src/bootstraparse/modules/export.py +++ b/src/bootstraparse/modules/export.py @@ -111,7 +111,7 @@ class ExportManager: level='CRITICAL' ) # future: allow for template selection - optionals = format_optionals(export_request.optionals) # TODO : Extensive testing + optionals = format_optionals(export_request.optionals) # FUTURE : More Extensive testing return start, end, optionals @@ -188,7 +188,7 @@ class ContextConverter: """ Transforms output form context manager into final, printable versions of the containers. """ - def __init__(self, pile, exporter): + def __init__(self, pile, exporter, destination): """ Takes a pile and the exporter object Parameters @@ -202,6 +202,7 @@ class ContextConverter: self.pile = pile self.exporter = exporter self.io_initialized = False + self.destination = destination def process_pile(self): """ @@ -227,9 +228,8 @@ class ContextConverter: return self.io_output.readlines() def __repr__(self): - return f"ContextConverter[FileName] <{len(self.pile)}> " \ + return f"ContextConverter[{self.destination}] <{len(self.pile)}> " \ f"Status: {'initialized' if self.io_initialized else 'uninitialized'}" - # TODO: deal with filename def print_all(self): print(self) @@ -249,7 +249,7 @@ if __name__ == '__main__': # pragma: no cover __templates = config.ConfigLoader(pathresolver.b_path("templates/")) exm = ExportManager(__config, __templates) cxm = context_mngr.ContextManager(test) - cxc = ContextConverter(cxm(), exm) + cxc = ContextConverter(cxm(), exm, "Undefined") rich.inspect(cxc) cxc.process_pile() rich.inspect(cxc.pile[0]) diff --git a/src/bootstraparse/modules/sitecreator.py b/src/bootstraparse/modules/sitecreator.py index 59780e8..5194403 100644 --- a/src/bootstraparse/modules/sitecreator.py +++ b/src/bootstraparse/modules/sitecreator.py @@ -57,7 +57,7 @@ def preparse_parse(preparser): def save(list_of_containers, destination, env): with open(destination, "w") as output_file: - output_file.write(export.ContextConverter(list_of_containers, env.export_mngr).process_pile().read()) + output_file.write(export.ContextConverter(list_of_containers, env.export_mngr, destination).process_pile().read()) if __name__ == "__main__": # pragma: no cover diff --git a/tests/modules/test_export.py b/tests/modules/test_export.py index 9efa31b..5c2ff41 100644 --- a/tests/modules/test_export.py +++ b/tests/modules/test_export.py @@ -175,7 +175,7 @@ def test_context_cov(): # base = context_mngr.ContextManager(lst) # base.pile = lst # return base - convr = export.ContextConverter(lst, em) + convr = export.ContextConverter(lst, em, "Undefined") convr.process_pile() convr.__repr__() convr.readlines()