Browse Source

Improve coverage for bulkdata

tags/nilmdb-2.0.0
Jim Paris 2 years ago
parent
commit
a962258b2a
1 changed files with 6 additions and 7 deletions
  1. +6
    -7
      nilmdb/server/bulkdata.py

+ 6
- 7
nilmdb/server/bulkdata.py View File

@@ -25,7 +25,10 @@ fd_cache_size = 8
@nilmdb.utils.must_close(wrap_verify = False)
class BulkData(object):
def __init__(self, basepath, **kwargs):
self.basepath = self._encode_filename(basepath)
if isinstance(basepath, str):
self.basepath = self._encode_filename(basepath)
else:
self.basepath = basepath
self.root = os.path.join(self.basepath, b"data")
self.lock = self.root + b".lock"
self.lockfile = None
@@ -74,15 +77,11 @@ class BulkData(object):
def _encode_filename(self, path):
# Translate unicode strings to raw bytes, if needed. We
# always manipulate paths internally as bytes.
if isinstance(path, str):
return path.encode('utf-8')
return path
return path.encode('utf-8')

def _decode_filename(self, path):
# Translate raw bytes to unicode strings, escaping if needed
if isinstance(path, bytes):
return path.decode('utf-8', errors='backslashreplace')
return path
return path.decode('utf-8', errors='backslashreplace')

def _create_check_ospath(self, ospath):
if ospath[-1:] == b'/':


Loading…
Cancel
Save