ithon/std/ipathlib.py
2024-10-09 19:31:52 -04:00

21 lines
No EOL
599 B
Python

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