From 15659a68aa3f7704aac43feef1a248cb91e5a8f7 Mon Sep 17 00:00:00 2001 From: John Mertic Date: Wed, 4 Dec 2024 08:01:04 -0500 Subject: [PATCH] Strip out `\u2028` character, as it causes issues reading back the file (#88) Signed-off-by: John Mertic --- lfx_landscape_tools/landscapeoutput.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lfx_landscape_tools/landscapeoutput.py b/lfx_landscape_tools/landscapeoutput.py index 4546634..fb5c4b8 100644 --- a/lfx_landscape_tools/landscapeoutput.py +++ b/lfx_landscape_tools/landscapeoutput.py @@ -49,8 +49,11 @@ def load(self, resetCategory = False, newLandscape = False): if not newLandscape: try: with open(self.landscapefile, 'r', encoding="utf8", errors='ignore') as fileobject: + logging.getLogger().info("Successfully opened landscape file '{}'".format(self.landscapefile)) self.landscape = ruamel.yaml.YAML().load(fileobject) - except: + logging.getLogger().info("Successfully parsed yaml output in landscape file '{}'".format(self.landscapefile)) + except Exception as e: + logging.getLogger().error("Error opening landscape file '{}' - will reset file - '{}'".format(self.landscapefile,e)) newLandscape = True found = False if self.landscape: @@ -208,7 +211,7 @@ def save(self): ryaml.dump(self.landscape, fileobject, transform=self._removeNulls) def _removeNulls(self,yamlout): - return yamlout.replace('- item: null','- item:').replace('- category: null','- category:').replace('- subcategory: null','- subcategory:') + return yamlout.replace('- item: null','- item:').replace('- category: null','- category:').replace('- subcategory: null','- subcategory:').replace('\u2028',' ') def _str_presenter(self, dumper, data): if '\n' in data: