Rename add to put in persistent store backends
This commit is contained in:
parent
5bcc6b6934
commit
14f4cb23ae
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user