Skip to content

Commit 22b410d

Browse files
authored
Change to import Path for consistency (#3101)
1 parent a575ac2 commit 22b410d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

archinstall/__main__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import importlib
2-
import pathlib
32
import sys
3+
from pathlib import Path
44

55
# Load .git version before the builtin version
6-
if pathlib.Path('./archinstall/__init__.py').absolute().exists():
6+
if Path('./archinstall/__init__.py').absolute().exists():
77
spec = importlib.util.spec_from_file_location("archinstall", "./archinstall/__init__.py")
88

99
if spec is None or spec.loader is None:

archinstall/lib/general.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
import pathlib
65
import re
76
import secrets
87
import shlex
@@ -16,6 +15,7 @@
1615
from collections.abc import Callable, Iterator
1716
from datetime import date, datetime
1817
from enum import Enum
18+
from pathlib import Path
1919
from select import EPOLLHUP, EPOLLIN, epoll
2020
from shutil import which
2121
from typing import TYPE_CHECKING, Any, override
@@ -73,7 +73,7 @@ def jsonify(obj: Any, safe: bool = True) -> Any:
7373
return obj.isoformat()
7474
if isinstance(obj, list | set | tuple):
7575
return [jsonify(item, safe) for item in obj]
76-
if isinstance(obj, pathlib.Path):
76+
if isinstance(obj, Path):
7777
return str(obj)
7878
if hasattr(obj, "__dict__"):
7979
return vars(obj)
@@ -116,7 +116,7 @@ def __init__(
116116
cmd = shlex.split(cmd)
117117

118118
if cmd:
119-
if cmd[0][0] != '/' and cmd[0][:2] != './': # pathlib.Path does not work well
119+
if cmd[0][0] != '/' and cmd[0][:2] != './': # Path() does not work well
120120
cmd[0] = locate_binary(cmd[0])
121121

122122
self.cmd = cmd
@@ -245,7 +245,7 @@ def peak(self, output: str | bytes) -> bool:
245245
except UnicodeDecodeError:
246246
return False
247247

248-
peak_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_output.txt")
248+
peak_logfile = Path(f"{storage['LOG_PATH']}/cmd_output.txt")
249249

250250
change_perm = False
251251
if peak_logfile.exists() is False:
@@ -304,7 +304,7 @@ def execute(self) -> bool:
304304

305305
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
306306
if not self.pid:
307-
history_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_history.txt")
307+
history_logfile = Path(f"{storage['LOG_PATH']}/cmd_history.txt")
308308

309309
change_perm = False
310310
if history_logfile.exists() is False:
@@ -496,7 +496,7 @@ def json_stream_to_structure(configuration_identifier: str, stream: str, target:
496496
return False
497497

498498
# Try using the stream as a filepath that should be read
499-
if raw is None and (path := pathlib.Path(stream)).exists():
499+
if raw is None and (path := Path(stream)).exists():
500500
try:
501501
raw = path.read_text()
502502
except Exception as err:

archinstall/lib/interactions/general_conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import pathlib
3+
from pathlib import Path
44
from typing import TYPE_CHECKING
55

66
from archinstall.tui import Alignment, EditMenu, FrameProperties, MenuItem, MenuItemGroup, Orientation, ResultType, SelectMenu, Tui
@@ -243,7 +243,7 @@ def validator(s: str) -> str | None:
243243
case ResultType.Selection:
244244
downloads: int = int(result.text())
245245

246-
pacman_conf_path = pathlib.Path("/etc/pacman.conf")
246+
pacman_conf_path = Path("/etc/pacman.conf")
247247
with pacman_conf_path.open() as f:
248248
pacman_conf = f.read().split("\n")
249249

archinstall/scripts/list.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import glob
2-
import pathlib
2+
from pathlib import Path
33

44
print("The following are viable --script options:")
55

6-
for script in [pathlib.Path(x) for x in glob.glob(f"{pathlib.Path(__file__).parent}/*.py")]:
6+
for script in [Path(x) for x in glob.glob(f"{Path(__file__).parent}/*.py")]:
77
if script.stem in ['__init__', 'list']:
88
continue
99

0 commit comments

Comments
 (0)