mirror of
https://github.com/dkmstr/openuds.git
synced 2025-02-02 09:47:13 +03:00
Minor Storage class aditions
This commit is contained in:
parent
ae240a36ed
commit
e3c839d70f
@ -28,7 +28,7 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""
|
||||
UDS Service modules interfaces and classes.
|
||||
UDS Service generics modules interfaces and classes.
|
||||
|
||||
Author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
"""
|
||||
|
@ -331,6 +331,18 @@ class Storage:
|
||||
|
||||
def read(self, skey: typing.Union[str, bytes]) -> typing.Optional[typing.Union[str, bytes]]:
|
||||
return self.read_from_db(skey)
|
||||
|
||||
def read_string(self, skey: typing.Union[str, bytes]) -> typing.Optional[str]:
|
||||
data = self.read(skey)
|
||||
if isinstance(data, bytes):
|
||||
return data.decode('utf-8')
|
||||
return data
|
||||
|
||||
def read_bytes(self, skey: typing.Union[str, bytes]) -> typing.Optional[bytes]:
|
||||
data = self.read(skey)
|
||||
if isinstance(data, str):
|
||||
return data.encode('utf-8')
|
||||
return data
|
||||
|
||||
def read_pickled(self, skey: typing.Union[str, bytes]) -> typing.Any:
|
||||
v = self.read_from_db(skey, True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user