From deaf61caac32961266e2d0644ad4312ea2dcd867 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 23 May 2015 13:50:43 -0700 Subject: Make the default file encoding a class constant with a docstring Having this exposed makes it easier to know what it is being used for and what the default is (and also makes it show up in generated docs, so people can read all about it). Change-Id: I2e0f85d9c087d220671e2dbf82d497677c462a9e --- taskflow/persistence/backends/impl_dir.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/taskflow/persistence/backends/impl_dir.py b/taskflow/persistence/backends/impl_dir.py index b6d1a27..1047d67 100644 --- a/taskflow/persistence/backends/impl_dir.py +++ b/taskflow/persistence/backends/impl_dir.py @@ -60,6 +60,12 @@ class DirBackend(path_based.PathBasedBackend): } """ + DEFAULT_FILE_ENCODING = 'utf-8' + """ + Default encoding used when decoding or encoding files into or from + text/unicode into binary or binary into text/unicode. + """ + def __init__(self, conf): super(DirBackend, self).__init__(conf) max_cache_size = self._conf.get('max_cache_size') @@ -71,7 +77,7 @@ class DirBackend(path_based.PathBasedBackend): self.file_cache = cachetools.LRUCache(max_cache_size) else: self.file_cache = {} - self.encoding = self._conf.get('encoding', 'utf-8') + self.encoding = self._conf.get('encoding', self.DEFAULT_FILE_ENCODING) if not self._path: raise ValueError("Empty path is disallowed") self._path = os.path.abspath(self._path) -- cgit v1.2.1