Skip to content

Commit 01f8df3

Browse files
committed
Simplifies uri file and swaps os to Path
Also, fixes uri creation in diagnostic tests
1 parent 7d90a73 commit 01f8df3

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

fortls/jsonrpc.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import json
2-
3-
try:
4-
import Queue
5-
except ImportError:
6-
import queue as Queue
7-
82
import os
3+
import queue
94
import threading
105
from collections import deque
11-
12-
try:
13-
from urllib.parse import quote, unquote
14-
except ImportError:
15-
from urllib2 import quote
16-
from urlparse import unquote
6+
from pathlib import Path
7+
from urllib.parse import quote, unquote
178

189
from fortls.constants import log
1910

@@ -26,7 +17,7 @@ def path_from_uri(uri: str) -> str:
2617
_, path = uri.split("file:///", 1)
2718
else:
2819
_, path = uri.split("file://", 1)
29-
return os.path.normpath(unquote(path))
20+
return str(Path(unquote(path)).resolve())
3021

3122

3223
def path_to_uri(path: str) -> str:
@@ -185,7 +176,7 @@ def send_request_batch(self, requests):
185176

186177
# We communicate the request ids using a thread safe queue.
187178
# It also allows us to bound the number of concurrent requests.
188-
q = Queue.Queue(100)
179+
q = queue.Queue(100)
189180

190181
def send():
191182
for method, params in requests:

test/test_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def check_return(results, ref_results):
703703
assert errcode == 0
704704
results.extend(res[1:])
705705

706-
root = Path(test_dir)
706+
root = path_to_uri(str((test_dir / "diag" / "test_external.f90").resolve()))
707707
ref_results = [
708708
[],
709709
[],
@@ -720,7 +720,7 @@ def check_return(results, ref_results):
720720
"relatedInformation": [
721721
{
722722
"location": {
723-
"uri": f"file://{root/'diag'/'test_external.f90'}",
723+
"uri": str(root),
724724
"range": {
725725
"start": {"line": 5, "character": 0},
726726
"end": {"line": 5, "character": 0},
@@ -740,7 +740,7 @@ def check_return(results, ref_results):
740740
"relatedInformation": [
741741
{
742742
"location": {
743-
"uri": f"file://{root/'diag'/'test_external.f90'}",
743+
"uri": str(root),
744744
"range": {
745745
"start": {"line": 3, "character": 0},
746746
"end": {"line": 3, "character": 0},

0 commit comments

Comments
 (0)