From 95ab57e027e32e7b23bc176c29b03121badb9815 Mon Sep 17 00:00:00 2001 From: MichaƂ Klichowicz Date: Sat, 13 Apr 2024 13:28:52 +0200 Subject: Force-converting path separators in filemanager to native OS separators --- jfr_playoff/filemanager.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jfr_playoff/filemanager.py b/jfr_playoff/filemanager.py index 3a6c19e..2d36aa2 100644 --- a/jfr_playoff/filemanager.py +++ b/jfr_playoff/filemanager.py @@ -12,20 +12,25 @@ class PlayoffFileManager(object): def __init__(self, settings): self.goniec = settings.get('goniec') if settings.has_section('goniec') else None PlayoffLogger.get('filemanager').info('goniec settings: %s', self.goniec) - self.output_file = settings.get('output') + self.output_file = self._sanitize_pathsep(settings.get('output')) PlayoffLogger.get('filemanager').info('output file: %s', self.output_file) self.output_path = os.path.dirname( self.output_file ).strip(os.sep) if len(self.output_path) > 0: self.output_path += os.sep + self.output_path = self._sanitize_pathsep(self.output_path) PlayoffLogger.get('filemanager').info('output path: %s', self.output_path) self.files = set() + def _sanitize_pathsep(self, path): + return path.replace('/', os.sep).replace('\\', os.sep) + def reset(self): self.files.clear() def register_file(self, path): + path = self._sanitize_pathsep(path) if path.startswith(self.output_path): PlayoffLogger.get('filemanager').info('registering file: %s', path) self.files.add(path.replace(self.output_path, '')) @@ -56,8 +61,8 @@ class PlayoffFileManager(object): if not os.path.exists(source_path): raise IOError('File: %s missing from runtime directory' % ( filename)) - output_path = os.path.join(self.output_path, path) - output_dir = os.path.dirname(output_path) + output_path = self._sanitize_pathsep(os.path.join(self.output_path, path)) + output_dir = self._sanitize_pathsep(os.path.dirname(output_path)) if len(output_dir) > 0: if not os.path.exists(output_dir): PlayoffLogger.get('filemanager').info( -- cgit v1.2.3