From 03525528d6875e023a6d0f93e7486cb676c03cfc Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 11 Dec 2024 10:51:06 +0100 Subject: [PATCH] llnl.path: make system_path_filter a noop on non-win32 (#48032) --- lib/spack/llnl/path.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/spack/llnl/path.py b/lib/spack/llnl/path.py index 4c5da8472d2..9a8d3432d71 100644 --- a/lib/spack/llnl/path.py +++ b/lib/spack/llnl/path.py @@ -66,7 +66,7 @@ def _is_url(path_or_url: str) -> bool: return result -def system_path_filter(_func=None, arg_slice: Optional[slice] = None): +def _system_path_filter(_func=None, arg_slice: Optional[slice] = None): """Filters function arguments to account for platform path separators. Optional slicing range can be specified to select specific arguments @@ -100,6 +100,16 @@ def path_filter_caller(*args, **kwargs): return holder_func +def _noop_decorator(_func=None, arg_slice: Optional[slice] = None): + return _func if _func else lambda x: x + + +if sys.platform == "win32": + system_path_filter = _system_path_filter +else: + system_path_filter = _noop_decorator + + def sanitize_win_longpath(path: str) -> str: """Strip Windows extended path prefix from strings Returns sanitized string.