aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-01-18 19:07:22 +0100
committerTristan Gingold <tgingold@free.fr>2021-01-19 07:40:56 +0100
commit7dc3c1979f7451eb517863a5a8c501bc6c3d0a47 (patch)
tree407b2c63b4e54f3f9fbb859a4ac8b0e5e51db38d /pyGHDL
parent1e5b92e6acdc4902cb548afa32d01b0f1a20b623 (diff)
downloadghdl-7dc3c1979f7451eb517863a5a8c501bc6c3d0a47.tar.gz
ghdl-7dc3c1979f7451eb517863a5a8c501bc6c3d0a47.tar.bz2
ghdl-7dc3c1979f7451eb517863a5a8c501bc6c3d0a47.zip
lsp.py: factorize is_windows
Diffstat (limited to 'pyGHDL')
-rw-r--r--pyGHDL/lsp/lsp.py5
1 files changed, 3 insertions, 2 deletions
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)