diff options
author | Michał Klichowicz <emkael@tlen.pl> | 2024-04-13 13:28:52 +0200 |
---|---|---|
committer | Michał Klichowicz <emkael@tlen.pl> | 2024-04-13 13:29:08 +0200 |
commit | 95ab57e027e32e7b23bc176c29b03121badb9815 (patch) | |
tree | f0b102f70c2b03ec45726938c504ccaa995ffe8a /jfr_playoff | |
parent | 40eaf8435414c6f0a3c7968942b90b5fa85f4d44 (diff) |
Force-converting path separators in filemanager to native OS separators
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/filemanager.py | 11 |
1 files 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( |