Exemplo n.º 1
0
def list2blend(blend_list):
    try:
        if blend_list and len(blend_list) == 2 and len(blend_list[1])>1:
            d = {}
            d["label"] = decode(blend_list[0])
            d["ingredients"] = [{"coffee": decode(i[0]), "ratio": i[1]} for i in blend_list[1]]
            return d
        else:
            return None
    except:
        return None
Exemplo n.º 2
0
def addString2dict(dict_source,key_source,dict_target,key_target,maxlen):
    if key_source in dict_source and dict_source[key_source]:
        txt = limittext(maxlen,decode(dict_source[key_source]))
        if txt is not None:
            dict_target[key_target] = txt