Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to import Path for consistency #3101

Merged
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions archinstall/__main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import importlib
import pathlib
import sys
from pathlib import Path

# 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")

if spec is None or spec.loader is None:
Expand Down
12 changes: 6 additions & 6 deletions archinstall/lib/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
import os
import pathlib
import re
import secrets
import shlex
Expand All @@ -16,6 +15,7 @@
from collections.abc import Callable, Iterator
from datetime import date, datetime
from enum import Enum
from pathlib import Path
from select import EPOLLHUP, EPOLLIN, epoll
from shutil import which
from typing import TYPE_CHECKING, Any, override
Expand Down Expand Up @@ -73,7 +73,7 @@ def jsonify(obj: Any, safe: bool = True) -> Any:
return obj.isoformat()
if isinstance(obj, list | set | tuple):
return [jsonify(item, safe) for item in obj]
if isinstance(obj, pathlib.Path):
if isinstance(obj, Path):
return str(obj)
if hasattr(obj, "__dict__"):
return vars(obj)
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(
cmd = shlex.split(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])

self.cmd = cmd
Expand Down Expand Up @@ -245,7 +245,7 @@ def peak(self, output: str | bytes) -> bool:
except UnicodeDecodeError:
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
if peak_logfile.exists() is False:
Expand Down Expand Up @@ -304,7 +304,7 @@ def execute(self) -> bool:

# https://stackoverflow.com/questions/4022600/python-pty-fork-how-does-it-work
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
if history_logfile.exists() is False:
Expand Down Expand Up @@ -496,7 +496,7 @@ def json_stream_to_structure(configuration_identifier: str, stream: str, target:
return False

# 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:
raw = path.read_text()
except Exception as err:
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/interactions/general_conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

import pathlib
from pathlib import Path
from typing import TYPE_CHECKING

from archinstall.tui import Alignment, EditMenu, FrameProperties, MenuItem, MenuItemGroup, Orientation, ResultType, SelectMenu, Tui
Expand Down Expand Up @@ -243,7 +243,7 @@ def validator(s: str) -> str | None:
case ResultType.Selection:
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:
pacman_conf = f.read().split("\n")

Expand Down
4 changes: 2 additions & 2 deletions archinstall/scripts/list.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import glob
import pathlib
from pathlib import Path

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']:
continue

Expand Down
Loading