Normalize Windows path with Python's pathlib

This commit is contained in:
Ivan Kravets
2021-11-05 17:21:15 +02:00
parent f88a2de8a9
commit 7c040ed99f
2 changed files with 4 additions and 3 deletions

View File

@ -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)
)

View File

@ -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]