コード例 #1
0
ファイル: __init__.py プロジェクト: uc-cdis/sheepdog
 def value_to_list_value(self, cls, link_name, prop, value):
     if value is None:
         return value
     l_values = value.split(SUB_DELIMITERS.get(self.format))
     r_values = []
     for v in l_values:
         converted_value = self.convert_link_value(cls, link_name, prop, v)
         # only add the prop if there is a link - for example,
         # TSV submissions may include empty link columns
         if converted_value:
             r_values.append({prop: converted_value})
     return r_values
コード例 #2
0
def dict_props_to_list(obj, props, titles_linked, file_format):
    sub_splitter = SUB_DELIMITERS.get(file_format)
    link_props_split = list(map(format_linked_prop, titles_linked))

    l_prop_values = [str(obj.get(k)) for k in props]
    link_fields = []
    for (link_name, link_prop) in link_props_split:
        s = sub_splitter.join(
            list(
                filter(
                    lambda x: x != "",
                    map(lambda x: str(x.get(link_prop, "")),
                        obj.get(link_name, [])),
                )))
        link_fields.append(s)
    return l_prop_values + link_fields