Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/parsers.py
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def parse(self, stream, media_type=None, parser_context=None): | ||||
""" | """ | ||||
parser_context = parser_context or {} | parser_context = parser_context or {} | ||||
encoding = parser_context.get("encoding", settings.DEFAULT_CHARSET) | encoding = parser_context.get("encoding", settings.DEFAULT_CHARSET) | ||||
namespaces = { | namespaces = { | ||||
"http://www.w3.org/2005/Atom": None, | "http://www.w3.org/2005/Atom": None, | ||||
"http://purl.org/dc/terms/": None, | "http://purl.org/dc/terms/": None, | ||||
"https://doi.org/10.5063/SCHEMA/CODEMETA-2.0": "codemeta", | "https://doi.org/10.5063/SCHEMA/CODEMETA-2.0": "codemeta", | ||||
"http://purl.org/net/sword/": "sword", | "http://purl.org/net/sword/": "sword", | ||||
"https://www.softwareheritage.org/schema/2018/deposit": "swh", | |||||
} | } | ||||
data = xmltodict.parse( | data = xmltodict.parse( | ||||
stream, encoding=encoding, namespaces=namespaces, process_namespaces=True | stream, encoding=encoding, namespaces=namespaces, process_namespaces=True | ||||
) | ) | ||||
if "entry" in data: | if "entry" in data: | ||||
data = data["entry"] | data = data["entry"] | ||||
return data | return data | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |