Change to import Path for consistency (#3101)
This commit is contained in:
parent
a575ac2c47
commit
22b410d082
|
|
@ -1,9 +1,9 @@
|
||||||
import importlib
|
import importlib
|
||||||
import pathlib
|
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Load .git version before the builtin version
|
# Load .git version before the builtin version
|
||||||
if pathlib.Path('./archinstall/__init__.py').absolute().exists():
|
if Path('./archinstall/__init__.py').absolute().exists():
|
||||||
spec = importlib.util.spec_from_file_location("archinstall", "./archinstall/__init__.py")
|
spec = importlib.util.spec_from_file_location("archinstall", "./archinstall/__init__.py")
|
||||||
|
|
||||||
if spec is None or spec.loader is None:
|
if spec is None or spec.loader is None:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pathlib
|
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
import shlex
|
import shlex
|
||||||
|
|
@ -16,6 +15,7 @@ import urllib.parse
|
||||||
from collections.abc import Callable, Iterator
|
from collections.abc import Callable, Iterator
|
||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from pathlib import Path
|
||||||
from select import EPOLLHUP, EPOLLIN, epoll
|
from select import EPOLLHUP, EPOLLIN, epoll
|
||||||
from shutil import which
|
from shutil import which
|
||||||
from typing import TYPE_CHECKING, Any, override
|
from typing import TYPE_CHECKING, Any, override
|
||||||
|
|
@ -73,7 +73,7 @@ def jsonify(obj: Any, safe: bool = True) -> Any:
|
||||||
return obj.isoformat()
|
return obj.isoformat()
|
||||||
if isinstance(obj, list | set | tuple):
|
if isinstance(obj, list | set | tuple):
|
||||||
return [jsonify(item, safe) for item in obj]
|
return [jsonify(item, safe) for item in obj]
|
||||||
if isinstance(obj, pathlib.Path):
|
if isinstance(obj, Path):
|
||||||
return str(obj)
|
return str(obj)
|
||||||
if hasattr(obj, "__dict__"):
|
if hasattr(obj, "__dict__"):
|
||||||
return vars(obj)
|
return vars(obj)
|
||||||
|
|
@ -116,7 +116,7 @@ class SysCommandWorker:
|
||||||
cmd = shlex.split(cmd)
|
cmd = shlex.split(cmd)
|
||||||
|
|
||||||
if cmd:
|
if cmd:
|
||||||
if cmd[0][0] != '/' and cmd[0][:2] != './': # pathlib.Path does not work well
|
if cmd[0][0] != '/' and cmd[0][:2] != './': # Path() does not work well
|
||||||
cmd[0] = locate_binary(cmd[0])
|
cmd[0] = locate_binary(cmd[0])
|
||||||
|
|
||||||
self.cmd = cmd
|
self.cmd = cmd
|
||||||
|
|
@ -245,7 +245,7 @@ class SysCommandWorker:
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
peak_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_output.txt")
|
peak_logfile = Path(f"{storage['LOG_PATH']}/cmd_output.txt")
|
||||||
|
|
||||||
change_perm = False
|
change_perm = False
|
||||||
if peak_logfile.exists() is False:
|
if peak_logfile.exists() is False:
|
||||||
|
|
@ -304,7 +304,7 @@ class SysCommandWorker:
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
|
# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
|
||||||
if not self.pid:
|
if not self.pid:
|
||||||
history_logfile = pathlib.Path(f"{storage['LOG_PATH']}/cmd_history.txt")
|
history_logfile = Path(f"{storage['LOG_PATH']}/cmd_history.txt")
|
||||||
|
|
||||||
change_perm = False
|
change_perm = False
|
||||||
if history_logfile.exists() is False:
|
if history_logfile.exists() is False:
|
||||||
|
|
@ -496,7 +496,7 @@ def json_stream_to_structure(configuration_identifier: str, stream: str, target:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Try using the stream as a filepath that should be read
|
# Try using the stream as a filepath that should be read
|
||||||
if raw is None and (path := pathlib.Path(stream)).exists():
|
if raw is None and (path := Path(stream)).exists():
|
||||||
try:
|
try:
|
||||||
raw = path.read_text()
|
raw = path.read_text()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import pathlib
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from archinstall.tui import Alignment, EditMenu, FrameProperties, MenuItem, MenuItemGroup, Orientation, ResultType, SelectMenu, Tui
|
from archinstall.tui import Alignment, EditMenu, FrameProperties, MenuItem, MenuItemGroup, Orientation, ResultType, SelectMenu, Tui
|
||||||
|
|
@ -243,7 +243,7 @@ def add_number_of_parallel_downloads(preset: int | None = None) -> int | None:
|
||||||
case ResultType.Selection:
|
case ResultType.Selection:
|
||||||
downloads: int = int(result.text())
|
downloads: int = int(result.text())
|
||||||
|
|
||||||
pacman_conf_path = pathlib.Path("/etc/pacman.conf")
|
pacman_conf_path = Path("/etc/pacman.conf")
|
||||||
with pacman_conf_path.open() as f:
|
with pacman_conf_path.open() as f:
|
||||||
pacman_conf = f.read().split("\n")
|
pacman_conf = f.read().split("\n")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import glob
|
import glob
|
||||||
import pathlib
|
from pathlib import Path
|
||||||
|
|
||||||
print("The following are viable --script options:")
|
print("The following are viable --script options:")
|
||||||
|
|
||||||
for script in [pathlib.Path(x) for x in glob.glob(f"{pathlib.Path(__file__).parent}/*.py")]:
|
for script in [Path(x) for x in glob.glob(f"{Path(__file__).parent}/*.py")]:
|
||||||
if script.stem in ['__init__', 'list']:
|
if script.stem in ['__init__', 'list']:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue