From 1a8a792244b673e2c01c036ff76b86577b4231b9 Mon Sep 17 00:00:00 2001 From: ServerlessSam Date: Sun, 18 Dec 2022 09:19:21 -0500 Subject: [PATCH 1/2] Add flag to config.build() to give option to save locally --- src/config.py | 6 ++++-- tests/test_config.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config.py b/src/config.py index 28a8b26..caa6264 100644 --- a/src/config.py +++ b/src/config.py @@ -185,6 +185,8 @@ def load_config_from_file( source_files=source_files, destination_file=dest_file, root_path=root_path ) - def build(self): + def build(self, save_to_local_file:bool=True): content = self.generate_new_dest_content() - self.write_content(content) + if save_to_local_file: + self.write_content(content) + return content diff --git a/tests/test_config.py b/tests/test_config.py index 95ce96d..7eb89b7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -109,7 +109,7 @@ def test_configs(self): src = SourceFile(src_file_location, "$.AnotherKeyInTheFile", "$") dest = DestinationFile(dest_file_location) config = BuildConfig([src], dest, Path(__file__).parent.resolve()) - assert config.generate_new_dest_content() == { + assert config.build(save_to_local_file=False) == { "Hello": "There", "UhOh": "This", "OneIs": "Nested", From 643631b4b0748b8de143ebcc17ad07749b6c599a Mon Sep 17 00:00:00 2001 From: ServerlessSam Date: Sun, 18 Dec 2022 09:20:53 -0500 Subject: [PATCH 2/2] Update config.py --- src/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.py b/src/config.py index caa6264..9fe30c9 100644 --- a/src/config.py +++ b/src/config.py @@ -185,7 +185,7 @@ def load_config_from_file( source_files=source_files, destination_file=dest_file, root_path=root_path ) - def build(self, save_to_local_file:bool=True): + def build(self, save_to_local_file: bool = True): content = self.generate_new_dest_content() if save_to_local_file: self.write_content(content)