def to_field(obj):


    if isinstance(obj, Field):
        field = obj
    else:
        d = { "storage_type": "unknown" }

        if isinstance(obj, basestring):
            d["name"] = obj
        elif type(obj) == tuple or type(obj) == list:
            d["name"] = obj[0]
            try:
                d["storage_type"] = obj[1]
                try:
                    d["analytical_type"] = obj[2]
                except:
                    pass
            except:
                pass
        else: # assume dictionary
            d["name"] = obj["name"]
            d["label"] = obj.get("label")
            d["storage_type"] = obj.get("storage_type")
            d["analytical_type"] = obj.get("analytical_type")
            d["adapter_storage_type"] = obj.get("adapter_storage_type")

        if "analytical_type" not in d:
            storage_type = d.get("storage_type")
            if storage_type:
                deftype = default_analytical_types.get(storage_type)
                d["analytical_type"] = deftype or "typeless"
            else:
                d["analytical_type"] = "typeless"

        field = Field(**d)
    return field
Put a new value into the editor
dataset/ETHPy150Open Stiivi/brewery/brewery/metadata.py/to_field--crossover with--dataset/ETHPy150Open ODM2/ODMToolsPython/odmtools/lib/oldOlv/CellEditor.py/IntEditor.SetValue