Skip to content

Commit

Permalink
Strip out \u2028 character, as it causes issues reading back the fi…
Browse files Browse the repository at this point in the history
…le (#88)

Signed-off-by: John Mertic <[email protected]>
  • Loading branch information
jmertic authored Dec 4, 2024
1 parent 7c1e0da commit 15659a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lfx_landscape_tools/landscapeoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 15659a6

Please sign in to comment.