# Path: simplekv/_compat.py
# PY2 = sys.version_info[0] == 2


from ._compat import quote_plus, unquote_plus, text_type, binary_type
    def _filter(self, key):
        return key.startswith(self.prefix)

    def _map_key(self, key):
        self._check_valid_key(key)
        return self.prefix + key

    def _map_key_prefix(self, key_prefix):
        return self.prefix + key_prefix

    def _unmap_key(self, key):
        assert key.startswith(self.prefix)

        return key[len(self.prefix):]


class URLEncodeKeysDecorator(KeyTransformingDecorator):
    """URL-encodes keys before passing them on to the underlying store."""
    def _map_key(self, key):
        if not isinstance(key, text_type):
            raise ValueError('%r is not a unicode string' % key)
        quoted = quote_plus(key.encode('utf-8'))
        if isinstance(quoted, binary_type):
            quoted = quoted.decode('utf-8')
        return quoted

    def _map_key_prefix(self, key_prefix):
        return self._map_key(key_prefix)

    def _unmap_key(self, key):

# Path: simplekv/_compat.py
# PY2 = sys.version_info[0] == 2


# Path: simplekv/decorator.py
from ._compat import quote_plus, unquote_plus, text_type, binary_type

    def _filter(self, key):
        return key.startswith(self.prefix)

    def _map_key(self, key):
        self._check_valid_key(key)
        return self.prefix + key

    def _map_key_prefix(self, key_prefix):
        return self.prefix + key_prefix

    def _unmap_key(self, key):
        assert key.startswith(self.prefix)

        return key[len(self.prefix):]


class URLEncodeKeysDecorator(KeyTransformingDecorator):
    """URL-encodes keys before passing them on to the underlying store."""
    def _map_key(self, key):
        if not isinstance(key, text_type):
            raise ValueError('%r is not a unicode string' % key)
        quoted = quote_plus(key.encode('utf-8'))
        if isinstance(quoted, binary_type):
            quoted = quoted.decode('utf-8')
        return quoted

    def _map_key_prefix(self, key_prefix):
        return self._map_key(key_prefix)

    def _unmap_key(self, key):

        return unquote_plus(key)