leveldir

Multi-level directory structure data stores in python3
git clone git://git.defalsify.org/python-leveldir.git
Log | Files | Refs | LICENSE

commit 94800fb006e99e1223ec1542dc01c9afa6f3ff06
parent 8cafbf42ca20edf488d09c4c459bd3f27176d4d0
Author: lash <dev@holbrook.no>
Date:   Tue,  8 Nov 2022 12:54:53 +0000

Add package deps, overridable key stringer

Diffstat:
MCHANGELOG | 3++-
AMANIFEST.in | 1+
Mleveldir/hex.py | 9+++++++--
3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,5 +1,6 @@ - 0.3.1 - * Include dependency in packaging + * Include dependency in packaging + * Allow overridable key string representation - 0.3.0 * Make master file a dotfile - 0.2.0 diff --git a/MANIFEST.in b/MANIFEST.in @@ -0,0 +1 @@ +include *requirements.txt LICENSE diff --git a/leveldir/hex.py b/leveldir/hex.py @@ -41,7 +41,7 @@ class HexDir(LevelDir): def add(self, key, content, prefix=b''): self.__check(key, content, prefix) - key_hex = key.hex() + key_hex = self.key_to_string(key) entry_path = self.to_filepath(key_hex) return self.__add(entry_path, key, content, key_hex, prefix=prefix) @@ -65,9 +65,13 @@ class HexDir(LevelDir): return (c, entry_path) + def key_to_string(self, k): + return k.hex() + + def add_dir(self, file_key, key, content, prefix=b''): self.__check(key, content, prefix) - key_hex = key.hex() + key_hex = self.key_to_string(key) entry_path = self.to_filepath(key_hex) entry_path = os.path.join(entry_path, file_key) return self.__add(entry_path, key, content, key_hex, prefix=prefix) @@ -92,6 +96,7 @@ class HexDir(LevelDir): def get(self, idx): cursor = self.__cursor(idx) + print('cursor {}'.format(cursor)) f = open(self.master_file, 'rb') f.seek(cursor) prefix = f.read(self.prefix_length)