mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-09-08 17:54:10 +00:00
19 lines
399 B
Python
19 lines
399 B
Python
|
def encode_if_needed(value):
|
||
|
if isinstance(value, str):
|
||
|
value = value.encode('utf-8')
|
||
|
return value
|
||
|
|
||
|
|
||
|
def decode_if_needed(value):
|
||
|
if isinstance(value, (bytes, bytearray)):
|
||
|
value = value.decode('utf-8')
|
||
|
return value
|
||
|
|
||
|
|
||
|
def serialize_all(*args):
|
||
|
return [encode_if_needed(a) for a in args]
|
||
|
|
||
|
|
||
|
def deserialize_all(*args):
|
||
|
return [decode_if_needed(a) for a in args]
|