summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-10-16 16:46:50 +0200
committerAnton Khirnov <anton@khirnov.net>2023-10-16 16:46:50 +0200
commitfb0eab1bccf3dfd1b80ad5c3eacb9bde211a7440 (patch)
tree2f8e57217ddb4f4b48be3c506b091eef28819e67
parent49c1362ff05a446c4360b8a0af104a341388a97a (diff)
_path: implement AbsPath.__add__
-rw-r--r--lbup/_path.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lbup/_path.py b/lbup/_path.py
index 49cdec5..c21a59c 100644
--- a/lbup/_path.py
+++ b/lbup/_path.py
@@ -38,6 +38,15 @@ class AbsPath:
def __len__(self):
return len(self.components)
+ def __add__(self, other):
+ if isinstance(other, str):
+ other = other.encode('utf-8')
+
+ if isinstance(other, bytes):
+ other = self.__class__(b'/' + other)
+
+ return self.__class__(components = self.components + other.components)
+
@property
def path(self):
return b'/' + b'/'.join(self.components)