ADd method to resolve name string to state property
This commit is contained in:
parent
a95a25f745
commit
488687a8d8
@ -1,3 +1,7 @@
|
|||||||
|
- 0.0.17
|
||||||
|
* Add reverse lookup method for name to state property
|
||||||
|
- 0.0.16
|
||||||
|
* Ensure store is present if path query for NEW is fired before any put
|
||||||
- 0.0.15
|
- 0.0.15
|
||||||
* Add missing store module in setup
|
* Add missing store module in setup
|
||||||
- 0.0.14
|
- 0.0.14
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = shep
|
name = shep
|
||||||
version = 0.0.15
|
version = 0.0.17
|
||||||
description = Multi-state key stores using bit masks
|
description = Multi-state key stores using bit masks
|
||||||
author = Louis Holbrook
|
author = Louis Holbrook
|
||||||
author_email = dev@holbrook.no
|
author_email = dev@holbrook.no
|
||||||
|
@ -87,6 +87,8 @@ class PersistedState(State):
|
|||||||
def sync(self, state):
|
def sync(self, state):
|
||||||
k = self.name(state)
|
k = self.name(state)
|
||||||
|
|
||||||
|
self.__ensure_store(k)
|
||||||
|
|
||||||
for o in self.__stores[k].list():
|
for o in self.__stores[k].list():
|
||||||
self.__ensure_store(k)
|
self.__ensure_store(k)
|
||||||
try:
|
try:
|
||||||
|
@ -35,12 +35,12 @@ class State:
|
|||||||
def __check_name_valid(self, k):
|
def __check_name_valid(self, k):
|
||||||
if not k.isalpha():
|
if not k.isalpha():
|
||||||
raise ValueError('only alpha')
|
raise ValueError('only alpha')
|
||||||
|
return k.upper()
|
||||||
|
|
||||||
|
|
||||||
def __check_name(self, k):
|
def __check_name(self, k):
|
||||||
self.__check_name_valid(k)
|
k = self.__check_name_valid(k)
|
||||||
|
|
||||||
k = k.upper()
|
|
||||||
try:
|
try:
|
||||||
getattr(self, k)
|
getattr(self, k)
|
||||||
raise StateExists(k)
|
raise StateExists(k)
|
||||||
@ -140,6 +140,11 @@ class State:
|
|||||||
return k
|
return k
|
||||||
|
|
||||||
|
|
||||||
|
def from_name(self, k):
|
||||||
|
k = self.__check_name_valid(k)
|
||||||
|
return getattr(self, k)
|
||||||
|
|
||||||
|
|
||||||
def match(self, v, pure=False):
|
def match(self, v, pure=False):
|
||||||
alias = None
|
alias = None
|
||||||
if not pure:
|
if not pure:
|
||||||
|
@ -93,5 +93,11 @@ class TestState(unittest.TestCase):
|
|||||||
self.assertEqual(states.peek('abcd'))
|
self.assertEqual(states.peek('abcd'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_from_name(self):
|
||||||
|
states = State(3)
|
||||||
|
states.add('foo')
|
||||||
|
self.assertEqual(states.from_name('foo'), states.FOO)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user