project/repr

This commit is contained in:
Marc Beninca 2024-09-15 01:59:00 +02:00
parent 63c179a0a4
commit f8567686fd
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -6,15 +6,21 @@ from pathlib import Path
class Project:
"""Parent class for any type of project."""
def __init__(self, file_path: str) -> None:
def __init__(self, file: Path) -> None:
"""Set file, root & name."""
self.file: Path = Path(file_path).resolve()
self.raw = file
self.file = self.raw.resolve()
self.root: Path = self.file.parent
self.name: str = self.root.name
def __repr__(self) -> str:
"""Represent project."""
return f"Project(file={self.raw!r})"
def __str__(self) -> str:
"""Return file, root & name."""
return f"""\
raw = {self.raw}
file = {self.file}
root = {self.root}
name = {self.name}