From 20d7ea08cc578c01dbb637640b296b24c090eaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 2 Jan 2019 15:04:54 +0100 Subject: [PATCH] Workaround for Windows failing on glob patterns in path.resolve() Windows fails with an OSError when `somepath.resolve()` is called and `somepath` contains a glob pattern. As a workaround, we now `resolve()` the parent directory, and put the filename at its end. This only works when the glob pattern is in the filename, which is the case for BAT- generated globs. --- blender_asset_tracer/trace/result.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/blender_asset_tracer/trace/result.py b/blender_asset_tracer/trace/result.py index 47cdb63..e20599f 100644 --- a/blender_asset_tracer/trace/result.py +++ b/blender_asset_tracer/trace/result.py @@ -149,10 +149,17 @@ class BlockUsage: if self._abspath is None: bpath = self.block.bfile.abspath(self.asset_path) as_path = pathlib.Path(bpath.to_path()) + + # Windows cannot resolve() a path that has a glob pattern in it. + # Since globs are generally only on the filename part, we take that off, + # resolve() the parent directory, then put the filename back. try: - self._abspath = as_path.resolve() + abs_parent = as_path.parent.resolve() except FileNotFoundError: self._abspath = as_path + else: + self._abspath = abs_parent / as_path.name + log.info('Resolving %s rel to %s -> %s', self.asset_path, self.block.bfile.filepath, self._abspath) else: