diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-31 00:44:23 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-31 00:44:23 +0200 |
commit | 80b7cf6ff8efbe653f5e6c4b4d4d43dd4b388c6e (patch) | |
tree | 946c2a85dadb6896b345446aab18ece7571fdfd3 | |
parent | 128cc2eeb4b7f526d2af87d09129a1838061bb1e (diff) | |
download | slixmpp-80b7cf6ff8efbe653f5e6c4b4d4d43dd4b388c6e.tar.gz slixmpp-80b7cf6ff8efbe653f5e6c4b4d4d43dd4b388c6e.tar.bz2 slixmpp-80b7cf6ff8efbe653f5e6c4b4d4d43dd4b388c6e.tar.xz slixmpp-80b7cf6ff8efbe653f5e6c4b4d4d43dd4b388c6e.zip |
util.cache: Support None for encode and decode.
-rw-r--r-- | slixmpp/util/cache.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/slixmpp/util/cache.py b/slixmpp/util/cache.py index 059eca5b..79498d5e 100644 --- a/slixmpp/util/cache.py +++ b/slixmpp/util/cache.py @@ -53,8 +53,8 @@ class MemoryPerJidCache(PerJidCache): class FileSystemStorage: def __init__(self, encode, decode, binary): - self.encode = encode - self.decode = decode + self.encode = encode if encode is not None else lambda x: x + self.decode = decode if decode is not None else lambda x: x self.read = 'rb' if binary else 'r' self.write = 'wb' if binary else 'w' @@ -81,7 +81,7 @@ class FileSystemStorage: return False class FileSystemCache(Cache, FileSystemStorage): - def __init__(self, directory, cache_type, *, encode, decode, binary=False): + def __init__(self, directory, cache_type, *, encode=None, decode=None, binary=False): FileSystemStorage.__init__(self, encode, decode, binary) self.base_dir = os.path.join(directory, cache_type) @@ -92,7 +92,7 @@ class FileSystemCache(Cache, FileSystemStorage): return self._store(self.base_dir, key, value) class FileSystemPerJidCache(PerJidCache, FileSystemStorage): - def __init__(self, directory, cache_type, *, encode, decode, binary=False): + def __init__(self, directory, cache_type, *, encode=None, decode=None, binary=False): FileSystemStorage.__init__(self, encode, decode, binary) self.base_dir = os.path.join(directory, cache_type) |