How to use the pottery.exceptions.KeyExistsError function in pottery

To help you get started, we’ve selected a few pottery 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 brainix / pottery / pottery / set.py View on Github external
def _populate(self, iterable=tuple()):
        encoded_values = {self._encode(value) for value in iterable}
        if encoded_values:
            if self.redis.exists(self.key):
                raise KeyExistsError(self.redis, self.key)
            else:
                self.redis.multi()
                self.redis.sadd(self.key, *encoded_values)
github brainix / pottery / pottery / list.py View on Github external
def _populate(self, iterable=tuple()):
        encoded_values = [self._encode(value) for value in iterable]
        if encoded_values:  # pragma: no cover
            if self.redis.exists(self.key):
                raise KeyExistsError(self.redis, self.key)
            else:
                self.redis.multi()
                self.redis.rpush(self.key, *encoded_values)
github brainix / pottery / pottery / dict.py View on Github external
def __init__(self, iterable=tuple(), *, redis=None, key=None, **kwargs):
        'Initialize a RedisDict.  O(n)'
        super().__init__(redis=redis, key=key, **kwargs)
        if iterable or kwargs:
            with self._watch(iterable):
                if self.redis.exists(self.key):
                    raise KeyExistsError(self.redis, self.key)
                else:
                    self._populate(iterable, **kwargs)