Commit 80b7cf6f authored by Link Mauve's avatar Link Mauve

util.cache: Support None for encode and decode.

parent 128cc2ee
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment