swh.deposit.parsers module

Module in charge of defining parsers with SWORD 2.0 supported mediatypes.

class swh.deposit.parsers.SWHFileUploadZipParser[source]

Bases: rest_framework.parsers.FileUploadParser

File upload parser limited to zip archive.

media_type = 'application/zip'
class swh.deposit.parsers.SWHFileUploadTarParser[source]

Bases: rest_framework.parsers.FileUploadParser

File upload parser limited to tarball (tar, tar.gz, tar.*) archives.

media_type = 'application/x-tar'
class swh.deposit.parsers.SWHXMLParser[source]

Bases: rest_framework.parsers.BaseParser

XML parser.

media_type = 'application/xml'
parse(stream, media_type=None, parser_context=None)[source]

Parses the incoming bytestream as XML and returns the resulting data.

class swh.deposit.parsers.SWHAtomEntryParser[source]

Bases: swh.deposit.parsers.SWHXMLParser

Atom entry parser limited to specific mediatype

media_type = 'application/atom+xml;type=entry'
parse(stream, media_type=None, parser_context=None)[source]

Parses the incoming bytestream as XML and returns the resulting data.

class swh.deposit.parsers.SWHMultiPartParser[source]

Bases: rest_framework.parsers.MultiPartParser

Multipart parser limited to a subset of mediatypes.

media_type = 'multipart/*; *'
swh.deposit.parsers.parse_xml(raw_content)[source]

Parse xml body.

Parameters

raw_content (bytes) – The content to parse

Raises

ParserError in case of a malformed xml

Returns

content parsed as dict.