From 7c040ed99f457d2152fe24fbf8113da96274a628 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 5 Nov 2021 17:21:15 +0200 Subject: [PATCH] Normalize Windows path with Python's pathlib --- platformio/commands/home/rpc/handlers/app.py | 3 ++- platformio/commands/home/rpc/handlers/ide.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/platformio/commands/home/rpc/handlers/app.py b/platformio/commands/home/rpc/handlers/app.py index d69cdc2f..5ef4afa8 100644 --- a/platformio/commands/home/rpc/handlers/app.py +++ b/platformio/commands/home/rpc/handlers/app.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import os +from pathlib import Path from platformio import __version__, app, fs, util from platformio.project.config import ProjectConfig @@ -66,7 +67,7 @@ class AppRPC: # skip non-existing recent projects storage["recentProjects"] = list( set( - os.path.normpath(p) + str(Path(p).resolve()) for p in storage.get("recentProjects", []) if is_platformio_project(p) ) diff --git a/platformio/commands/home/rpc/handlers/ide.py b/platformio/commands/home/rpc/handlers/ide.py index 703f75a6..5ff9fe33 100644 --- a/platformio/commands/home/rpc/handlers/ide.py +++ b/platformio/commands/home/rpc/handlers/ide.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import time +from pathlib import Path from ajsonrpc.core import JSONRPC20DispatchException @@ -53,7 +53,7 @@ class IDERPC: if cmd_id not in self._cmd_queue: return if self._cmd_queue[cmd_id]["method"] == "get_pio_project_dirs": - value = [os.path.normpath(p) for p in value] + value = [str(Path(p).resolve()) for p in value] self._cmd_queue[cmd_id]["future"].set_result(value) del self._cmd_queue[cmd_id]