How to use the vdirsyncer.exceptions.NotFoundError function in vdirsyncer

To help you get started, we’ve selected a few vdirsyncer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / vdirsyncer / vdirsyncer / storage / memory.py View on Github external
def update(self, href, item, etag):
        if href not in self.items:
            raise exceptions.NotFoundError(href)
        actual_etag, _ = self.items[href]
        if etag != actual_etag:
            raise exceptions.WrongEtagError(etag, actual_etag)

        new_etag = _random_string()
        self.items[href] = (new_etag, item)
        return new_etag
github pimutils / vdirsyncer / vdirsyncer / storage / etesync.py View on Github external
def upload(self, item):
        try:
            entry = self._item_type.create(self._journal.collection, item.raw)
            entry.save()
        except etesync.exceptions.DoesNotExist as e:
            raise exceptions.NotFoundError(e)
        except etesync.exceptions.AlreadyExists as e:
            raise exceptions.AlreadyExistingError(e)
        return item.uid, item.hash
github pimutils / vdirsyncer / vdirsyncer / storage / filesystem.py View on Github external
def delete(self, href, etag):
        fpath = self._get_filepath(href)
        if not os.path.isfile(fpath):
            raise exceptions.NotFoundError(href)
        actual_etag = get_etag_from_file(fpath)
        if etag != actual_etag:
            raise exceptions.WrongEtagError(etag, actual_etag)
        os.remove(fpath)
github pimutils / vdirsyncer / vdirsyncer / storage / singlefile.py View on Github external
def get(self, href):
        if self._items is None or not self._at_once:
            self.list()

        try:
            return self._items[href]
        except KeyError:
            raise exceptions.NotFoundError(href)
github pimutils / vdirsyncer / vdirsyncer / storage / memory.py View on Github external
def delete(self, href, etag):
        if not self.has(href):
            raise exceptions.NotFoundError(href)
        if etag != self.items[href][0]:
            raise exceptions.WrongEtagError(etag)
        del self.items[href]
github pimutils / vdirsyncer / vdirsyncer / storage / singlefile.py View on Github external
def delete(self, href, etag):
        if href not in self._items:
            raise exceptions.NotFoundError(href)

        _, actual_etag = self._items[href]
        if etag != actual_etag:
            raise exceptions.WrongEtagError(etag, actual_etag)

        del self._items[href]
github pimutils / vdirsyncer / vdirsyncer / storage / http.py View on Github external
def get(self, href):
        if self._items is None:
            self.list()

        try:
            return self._items[href]
        except KeyError:
            raise exceptions.NotFoundError(href)
github pimutils / vdirsyncer / vdirsyncer / storage / singlefile.py View on Github external
def update(self, href, item, etag):
        if href not in self._items:
            raise exceptions.NotFoundError(href)

        _, actual_etag = self._items[href]
        if etag != actual_etag:
            raise exceptions.WrongEtagError(etag, actual_etag)

        self._items[href] = item, item.hash
        return item.hash
github pimutils / vdirsyncer / vdirsyncer / storage / filesystem.py View on Github external
def get(self, href):
        fpath = self._get_filepath(href)
        try:
            with open(fpath, 'rb') as f:
                return (Item(f.read().decode(self.encoding)),
                        get_etag_from_file(fpath))
        except OSError as e:
            if e.errno == errno.ENOENT:
                raise exceptions.NotFoundError(href)
            else:
                raise