1
0
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:
Adolfo Gómez García 2024-06-12 18:41:45 +02:00
parent ae240a36ed
commit e3c839d70f
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 13 additions and 1 deletions

View File

@ -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
"""

View File

@ -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)