Tuple in Couchdbkit

74 Views Asked by At

I need save EXIF data to couchdb. This is a dictionary of different variable types (str, list, int ...). Lists can have inside different types too. I have problem with storing Tuple to couchdbkit. This type is no present inside ALLOWED_PROPERTY_TYPES

1

There are 1 best solutions below

0
On BEST ANSWER

I prepared recursive function for replace all tuple to list:

def _tuple_to_list(self, el):

    if type(el) is tuple:
        el = self._tuple_to_list(list(el))
    elif type(el) is dict:
        for (key, value) in el.items():
            el[key] = self._tuple_to_list(value)
    elif type(el) is list:
        for i in range(len(el)):
            el[i] = self._tuple_to_list(el[i])

    return el