Refactoring, ipathlib, and others!

This commit is contained in:
Xander Mckay 2024-10-09 19:31:52 -04:00
parent b9801cad59
commit 440bd2f153
8 changed files with 64 additions and 1380 deletions

21
std/ipathlib.py Normal file
View file

@ -0,0 +1,21 @@
import pathlib
from typing import Self
"""
Pathlib without all the PAINlib.
"""
class Path(pathlib.Path):
def listdir(self: Self) -> list[Self]:
return list(self.iterdir())
def remove(self: Self, missing_ok: bool = True) -> None:
"""Remove this file or link. If the path is a directory, use rmdir() instead."""
self.unlink(missing_ok=missing_ok)
def rmtree(self: Self):
if self.is_file():
self.remove()
else:
for child in self.iterdir():
child.rmtree()
self.rmdir()
PurePath = pathlib.PurePath