commit 14f4cb23ae9e77b5de5743a0c787f4a378124d8b
parent 5bcc6b6934679953a89d000e001a9dff311e5f2d
Author: lash <dev@holbrook.no>
Date: Wed, 20 Apr 2022 14:24:02 +0000
Rename add to put in persistent store backends
Diffstat:
6 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/setup.cfg b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = shep
-version = 0.2.1a1
+version = 0.2.1a2
description = Multi-state key stores using bit masks
author = Louis Holbrook
author_email = dev@holbrook.no
diff --git a/shep/persist.py b/shep/persist.py
@@ -39,7 +39,7 @@ class PersistedState(State):
k = self.name(to_state)
self.__ensure_store(k)
- self.__stores[k].add(key, contents)
+ self.__stores[k].put(key, contents)
self.register_modify(key)
@@ -57,7 +57,7 @@ class PersistedState(State):
self.__ensure_store(k_to)
contents = self.__stores[k_from].get(key)
- self.__stores[k_to].add(key, contents)
+ self.__stores[k_to].put(key, contents)
self.__stores[k_from].remove(key)
self.sync(to_state)
@@ -79,7 +79,7 @@ class PersistedState(State):
self.__ensure_store(k_to)
contents = self.__stores[k_from].get(key)
- self.__stores[k_to].add(key, contents)
+ self.__stores[k_to].put(key, contents)
self.__stores[k_from].remove(key)
return to_state
@@ -99,7 +99,7 @@ class PersistedState(State):
self.__ensure_store(k_to)
contents = self.__stores[k_from].get(key)
- self.__stores[k_to].add(key, contents)
+ self.__stores[k_to].put(key, contents)
self.__stores[k_from].remove(key)
self.register_modify(key)
@@ -125,7 +125,7 @@ class PersistedState(State):
self.__ensure_store(k_to)
contents = self.__stores[k_from].get(key)
- self.__stores[k_to].add(key, contents)
+ self.__stores[k_to].put(key, contents)
self.__stores[k_from].remove(key)
self.register_modify(key)
diff --git a/shep/store/file.py b/shep/store/file.py
@@ -1,5 +1,9 @@
# standard imports
import os
+import re
+
+# local imports
+from .base import re_processedname
class SimpleFileStore:
@@ -17,7 +21,7 @@ class SimpleFileStore:
self.__m = ['r', 'w']
- def add(self, k, contents=None):
+ def put(self, k, contents=None):
"""Add a new key and optional contents
:param k: Content key to add
@@ -142,3 +146,11 @@ class SimpleFileStoreFactory:
k = str(k)
store_path = os.path.join(self.__path, k)
return SimpleFileStore(store_path, binary=self.__binary)
+
+
+ def ls(self):
+ r = []
+ for v in os.listdir(self.__path):
+ if re.match(re_processedname, v):
+ r.append(v)
+ return r
diff --git a/shep/store/redis.py b/shep/store/redis.py
@@ -28,7 +28,7 @@ class RedisStore:
return v.decode('utf-8')
- def add(self, k, contents=b''):
+ def put(self, k, contents=b''):
if contents == None:
contents = b''
k = self.__to_path(k)
diff --git a/shep/store/rocksdb.py b/shep/store/rocksdb.py
@@ -37,7 +37,7 @@ class RocksDbStore:
return v.decode('utf-8')
- def add(self, k, contents=b''):
+ def put(self, k, contents=b''):
if contents == None:
contents = b''
else:
diff --git a/tests/test_store.py b/tests/test_store.py
@@ -21,7 +21,7 @@ class MockStore:
self.for_state = 0
- def add(self, k, contents=None):
+ def put(self, k, contents=None):
self.v[k] = contents