diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-10-08 16:53:41 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-10-08 16:57:00 +0200 |
commit | a7fead47c8ba3d1e0c0455fb61f60292d0261bc7 (patch) | |
tree | ee13661233d34f42bad89a3ee77ccb95b269f2f1 /lbup | |
parent | e0f577f3c26fc7c44ce33e2851e245c66af401a0 (diff) |
_path: change components from a list into a tuple
Diffstat (limited to 'lbup')
-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 |