Skip to content

Commit

Permalink
cleanup pathlib overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Mar 31, 2024
1 parent 211baa6 commit eaa94fa
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions Libraries/Utility/src/utility/system/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,6 @@
_UNIX_EXTRA_SLASHES_RE = re.compile(r"/{2,}")


def get_direct_parent(cls: type):
parent_map: dict[type, type] = {
PurePath: object,
PureWindowsPath: pathlib.PurePath,
PurePosixPath: pathlib.PurePath,
Path: pathlib.PurePath,
WindowsPath: pathlib.Path,
PosixPath: pathlib.Path,
}
return parent_map.get(pathlib_to_override(cls), cls.__base__)


def override_to_pathlib(cls: type) -> type:
class_map: dict[type, type] = {
PurePath: pathlib.PurePath,
PureWindowsPath: pathlib.PureWindowsPath,
PurePosixPath: pathlib.PurePosixPath,
Path: pathlib.Path,
WindowsPath: pathlib.WindowsPath,
PosixPath: pathlib.PosixPath,
}

return class_map.get(cls, cls)


def pathlib_to_override(cls: type) -> type:
class_map: dict[type, type] = {
pathlib.PurePath: PurePath,
Expand Down Expand Up @@ -535,6 +510,7 @@ def has_access(
----
mode (int): The permissions to check for. Defaults to 0o6.
recurse (bool): Whether to recursively check permissions for all child paths. Defaults to False.
filter_results (Callable[[Path], bool] | None): An optional function that's called to determine if a file/folder should be ignored when recursing.
Returns:
-------
Expand Down Expand Up @@ -591,8 +567,6 @@ def has_access(
# raise
return False

unique_sentinel = object()

def gain_access(
self,
mode: int = 0o7,
Expand Down Expand Up @@ -737,7 +711,7 @@ def run_commands_as_admin(
with script_path.open("w") as file:
for command in cmd:
file.write(command + "\n")
if pause_after_command:
if pause_after_command and not hide_window:
file.write("pause\nexit\n")

# Determine the CMD switch to use
Expand Down

0 comments on commit eaa94fa

Please sign in to comment.