def content_dict_slicer(content_dict, base_fields=[], taxon_fields=[], ppo_fields=[]):
    result = slice(content_dict, base_fields)
    taxons = dig(content_dict, 'links', 'taxons')
    ppo = dig(content_dict, 'links', 'primary_publishing_organisation')

    if taxons:
        result['taxons'] = [slice(taxon, taxon_fields) for taxon in taxons]
    if ppo:
        result['primary_publishing_organisation'] = slice(ppo[0], ppo_fields)

    return result
def untagged_dict_slicer(content_dict, base_fields=[], ppo_fields=[]):
    result = slice(content_dict, base_fields)

    logo = dig(content_dict, 'links', 'organisations', 0, 'details', 'logo', 'formatted-title')
    ppo = dig(content_dict, 'links', 'primary_publishing_organisation')

    if logo:
        result['logo'] = logo
    if ppo:
        result['primary_publishing_organisation'] = slice(ppo[0], ppo_fields)

    return result
 def test_slice(self):
     self.assertEqual(slice({"a": 1, "b": 2}, ["a"]), {"a": 1})
Пример #4
0
 def __build_child_dict(self, taxon, parent_content_id):
     sliced_dict = slice(taxon, key_list=self.key_list)
     sliced_dict['parent_content_id'] = parent_content_id
     return sliced_dict
Пример #5
0
 def level_one_taxons(self):
     taxons = dig(self.__get_content_dict('/'), "links", "level_one_taxons")
     return [slice(taxon, self.key_list) for taxon in taxons]