Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/parsers.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | def parse(self, stream, media_type=None, parser_context=None): | ||||
""" | """ | ||||
Parses the incoming bytestream as XML and returns the resulting data. | Parses the incoming bytestream as XML and returns the resulting data. | ||||
""" | """ | ||||
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://www.w3.org/2007/app": "app", | "http://www.w3.org/2007/app": "app", | ||||
"http://purl.org/dc/terms/": None, | "http://purl.org/dc/terms/": "dc", | ||||
"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/terms/": "sword", | "http://purl.org/net/sword/terms/": "sword", | ||||
"https://www.softwareheritage.org/schema/2018/deposit": "swh", | "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 | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |