diff options
-rw-r--r-- | lbup/_path.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lbup/_path.py b/lbup/_path.py index 27f7072..994611f 100644 --- a/lbup/_path.py +++ b/lbup/_path.py @@ -10,11 +10,12 @@ class AbsPath: path = path.encode('utf-8') if len(path) < 1 or not path.startswith(b'/'): raise ValueError('Path does not look like valid absolute path', path) - components = list(filter(lambda x: len(x) > 0 and x != b'.', path[1:].split(b'/'))) - if b'..' in components: - raise ValueError('Parent references are not allowed', path) + components = filter(lambda x: len(x) > 0 and x != b'.', path[1:].split(b'/')) - self._components = components + self._components = tuple(components) + + if b'..' in self.components: + raise ValueError('Parent references are not allowed: %s' % self) def __bytes__(self): return self.path @@ -41,10 +42,10 @@ class AbsPath: @property def components(self): """ - Return a list of path components. + A tuple of path components. - Note that root does not count as a component, so a path of b'/' returns - an empty list. + Note that root does not count as a component, so for a path of b'/' this + is an empty tuple. """ return self._components |