From 7dc3c1979f7451eb517863a5a8c501bc6c3d0a47 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 18 Jan 2021 19:07:22 +0100 Subject: lsp.py: factorize is_windows --- pyGHDL/lsp/lsp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pyGHDL') diff --git a/pyGHDL/lsp/lsp.py b/pyGHDL/lsp/lsp.py index caaef6b2e..b3d413e4c 100644 --- a/pyGHDL/lsp/lsp.py +++ b/pyGHDL/lsp/lsp.py @@ -10,6 +10,7 @@ except ImportError: log = logging.getLogger("ghdl-ls") +is_windows = os.name == "nt" class ProtocolError(Exception): pass @@ -39,7 +40,7 @@ def path_from_uri(uri): # No scheme return uri _, path = uri.split("file://", 1) - if os.name == "nt" and path.startswith("/"): + if is_windows and path.startswith("/"): # On windows, absolute files start like "/C:/aa/bbb". # Remove the first "/". path = path[1:] @@ -48,7 +49,7 @@ def path_from_uri(uri): def path_to_uri(path): # Convert path to file uri (add html like head part) - if os.name == "nt": + if is_windows: return "file:///" + quote(path.replace("\\", "/")) else: return "file://" + quote(path) -- cgit v1.2.3