From fb0eab1bccf3dfd1b80ad5c3eacb9bde211a7440 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 16 Oct 2023 16:46:50 +0200 Subject: _path: implement AbsPath.__add__ --- lbup/_path.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- cgit v1.2.3