def remove(self, path): """ Remove the item at the relative or absolute path `path` from this file listing and return the item. If no such item is found (including an absolute path that does not descend from `self.base`), return None. See the documentation for `Container.remove` for more details. """ path = Path(path) if path.is_absolute: # This is an absolute path. Ensure that `path` descends from # `self.base`, otherwise it does not belong in this file list. path = path.relative_to(self.base) return super(FileListing, self).remove(path)
def add(self, path, overwrite=False, **kwargs): """ Add an item to this file listing at the relative or absolute path `path` and return the added item. If the path is absolute, it must descend from `self.base`. See the documentation for `Container.add` for more details. """ path = Path(path) if path.is_absolute: # This is an absolute path. Ensure that `path` descends from # `self.base`, otherwise it does not belong in this file list. path = path.relative_to(self.base) return super(FileListing, self).add(path, overwrite, **kwargs)