Changeset View
Changeset View
Standalone View
Standalone View
swh/search/utils.py
# Copyright (C) 2021 The Software Heritage developers | # Copyright (C) 2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import codecs | import codecs | ||||
from datetime import datetime | from datetime import datetime | ||||
from typing import Optional | from typing import Optional | ||||
import iso8601 | import iso8601 | ||||
def get_expansion(field, sep=None): | def get_expansion(field, sep=None): | ||||
METADATA_FIELDS = { | METADATA_FIELDS = { | ||||
"licenses": ["intrinsic_metadata", "http://schema.org/license", "@id"], | "licenses": ["jsonld", "http://schema.org/license", "@id"], | ||||
"programming_languages": [ | "programming_languages": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/programmingLanguage", | "http://schema.org/programmingLanguage", | ||||
"@value", | "@value", | ||||
], | ], | ||||
"keywords": [ | "keywords": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/keywords", | "http://schema.org/keywords", | ||||
"@value", | "@value", | ||||
], | ], | ||||
"descriptions": [ | "descriptions": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/description", | "http://schema.org/description", | ||||
"@value", | "@value", | ||||
], | ], | ||||
"date_created": [ | "date_created": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/dateCreated", | "http://schema.org/dateCreated", | ||||
"@value", | "@value", | ||||
], | ], | ||||
"date_modified": [ | "date_modified": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/dateModified", | "http://schema.org/dateModified", | ||||
"@value", | "@value", | ||||
], | ], | ||||
"date_published": [ | "date_published": [ | ||||
"intrinsic_metadata", | "jsonld", | ||||
"http://schema.org/datePublished", | "http://schema.org/datePublished", | ||||
"@value", | "@value", | ||||
], | ], | ||||
} | } | ||||
if sep: | if sep: | ||||
return sep.join(METADATA_FIELDS[field]) | return sep.join(METADATA_FIELDS[field]) | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |