Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit f86de53

Browse files
committed
Use @total_ordering and @Property
1 parent 985a8b5 commit f86de53

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

python/selfie-lib/selfie_lib/TypedPath.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1+
from functools import total_ordering
2+
3+
4+
@total_ordering
15
class TypedPath:
26
def __init__(self, absolute_path: str):
37
self.absolute_path = absolute_path
4-
self.name = self._get_name()
5-
self.is_folder = self.absolute_path.endswith("/")
68

7-
def _get_name(self) -> str:
9+
@property
10+
def name(self) -> str:
811
if self.absolute_path.endswith("/"):
912
path = self.absolute_path[:-1]
1013
else:
1114
path = self.absolute_path
1215
last_slash = path.rfind("/")
1316
return path[last_slash + 1 :]
1417

18+
@property
19+
def is_folder(self) -> bool:
20+
return self.absolute_path.endswith("/")
21+
1522
def assert_folder(self) -> None:
1623
if not self.is_folder:
1724
raise AssertionError(

0 commit comments

Comments
 (0)