labpack/mapping/data.py
def clean_data(input_value):

    ''' a function to transform a value into a json or yaml valid datatype

    :param input_value: object of any datatype
    :return: object with json valid datatype
    '''

# pass normal json/yaml datatypes
    if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneType']:
        pass

# transform byte data to base64 encoded string
    elif isinstance(input_value, bytes):
        from base64 import b64encode
        input_value = b64encode(input_value).decode()

# convert tuples and sets into lists
    elif isinstance(input_value, tuple) or isinstance(input_value, set):
        new_list = []
        new_list.extend(input_value)
        input_value = transform_data(clean_data, new_list)

# recurse through dictionaries and lists
    elif isinstance(input_value, dict) or isinstance(input_value, list):
        input_value = transform_data(clean_data, input_value)

# convert to string all python objects and callables
    else:
        input_value = str(input_value)

    return input_value
 a function to transform a value into a json or yaml valid datatype

    :param input_value: object of any datatype
    :return: object with json valid datatype
    
a function to transform a value into a json or yaml valid datatype
a function to transform a value into a json or yaml valid datatype
def clean_data(input_value):
    if input_value.__class__.__name__ in ['bool', 'str', 'float', 'int', 'NoneType']:
        pass
    elif isinstance(input_value, bytes):
        from base64 import b64encode
        input_value = b64encode(input_value).decode()
    elif isinstance(input_value, tuple) or isinstance(input_value, set):
        new_list = []
        new_list.extend(input_value)
        input_value = transform_data(clean_data, new_list)
    elif isinstance(input_value, dict) or isinstance(input_value, list):
        input_value = transform_data(clean_data, input_value)
    else:
        input_value = str(input_value)
    return input_value
def clean_data ( input_value ) : if input_value . __class__ . __name__ in [ 'bool' , 'str' , 'float' , 'int' , 'NoneType' ] : pass elif isinstance ( input_value , bytes ) : from base64 import b64encode input_value = b64encode ( input_value ) . decode ( ) elif isinstance ( input_value , tuple ) or isinstance ( input_value , set ) : new_list = [ ] new_list . extend ( input_value ) input_value = transform_data ( clean_data , new_list ) elif isinstance ( input_value , dict ) or isinstance ( input_value , list ) : input_value = transform_data ( clean_data , input_value ) else : input_value = str ( input_value ) return input_value
a function to transform a value into a json or yaml valid datatype
a function to transform a value into a json or yaml valid datatype
''' a function to transform a value into a json or yaml valid datatype

    :param input_value: object of any datatype
    :return: object with json valid datatype
    ''' # pass normal json/yaml datatypes # transform byte data to base64 encoded string # convert tuples and sets into lists # recurse through dictionaries and lists # convert to string all python objects and callables
object with json valid datatype
object with json valid datatype
input_value
object of any datatype
object of any datatype