def transform_path(path): r"""Do platform-specific transformations, like changing E: to E:\. Returns None if the path is invalid on the current platform. """ if sys.platform != "win32": return path path = utils.expand_windows_drive(path) # Drive dependent working directories are not supported, e.g. # E:filename is invalid if re.match(r'[A-Z]:[^\\]', path, re.IGNORECASE): return None # Paths like COM1, ... # See https://github.com/qutebrowser/qutebrowser/issues/82 if pathlib.Path(path).is_reserved(): return None return path
def transform_path(path): r"""Do platform-specific transformations, like changing E: to E:\. Returns None if the path is invalid on the current platform. """ if sys.platform != "win32": return path path = utils.expand_windows_drive(path) # Drive dependent working directories are not supported, e.g. # E:filename is invalid if re.match(r'[A-Z]:[^\\]', path, re.IGNORECASE): return None # Paths like COM1, ... # See https://github.com/qutebrowser/qutebrowser/issues/82 if pathlib.Path(path).is_reserved(): return None return path