From 681e5d8d05d035905e6fc694af93ee27ac87dbf2 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Tue, 24 Sep 2024 22:11:53 +0200 Subject: [PATCH] Squashed 'kiauh/core/submodules/simple_config_parser/' changes from 7835d2b..3a006f1 3a006f1 fix: correctly update last element value git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: 3a006f1b4695919f27c6759c94b538acdda13e48 --- src/simple_config_parser/simple_config_parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simple_config_parser/simple_config_parser.py b/src/simple_config_parser/simple_config_parser.py index 2b6413d..a1a38cd 100644 --- a/src/simple_config_parser/simple_config_parser.py +++ b/src/simple_config_parser/simple_config_parser.py @@ -197,18 +197,18 @@ class SimpleConfigParser: last_option_name: str = list(prev_section_content.keys())[-1] if last_option_name.startswith("#_"): - last_elem: str = prev_section_content[last_option_name][-1] + last_elem_value: str = prev_section_content[last_option_name][-1] # if the last section is a collector, we first check if the last element # in the collector ends with a newline. if it does not, we append a newline. # this can happen if the config file does not end with a newline. - if not last_elem.endswith("\n"): - last_elem = f"{last_elem}\n" + if not last_elem_value.endswith("\n"): + prev_section_content[last_option_name][-1] = f"{last_elem_value}\n" # if the last item in a collector is not a newline, we append a newline, so # that the new section is seperated from the options of the previous section # by a newline - if last_elem != "\n": + if last_elem_value != "\n": prev_section_content[last_option_name].append("\n") else: prev_section_content[self._generate_rand_id()] = ["\n"]