pydiffx.dom.reader#

Reader for parsing a DiffX file into DOM objects.

Classes

DiffXDOMReader(diffx_cls)

A reader for parsing a DiffX file into DOM objects.

class pydiffx.dom.reader.DiffXDOMReader(diffx_cls)#

Bases: object

A reader for parsing a DiffX file into DOM objects.

This will construct a DiffX from an input byte stream, such as a file, HTTP response, or memory-backed stream.

Often, you won’t use this directly. Instead, you’ll call DiffXFile.from_stream() or DiffXFile.from_bytes().

If constructing manually, one instance can be reused for multiple streams.

diffx_cls#

The DiffX class or subclass to create when parsing.

Type

type

reader_cls#

The class to instantiate for reading from a stream.

Subclasses can set this if they need to use a more specialized reader.

Type:

type

alias of pydiffx.reader.DiffXReader

__init__(diffx_cls)#

Initialize the reader.

Parameters

diffx_cls (type) – The DiffX class or subclass to create when parsing.

parse(stream)#

Parse a stream and construct the DOM objects.

The stream will be closed after reading.

Parameters

stream (file or io.IOBase) – The byte stream containing a valid DiffX file.

Returns

The resulting DiffX instance.

Return type

pydiffx.dom.objects.DiffX

Raises

pydiffx.errors.DiffXParseError – The DiffX contents could not be parsed. Details will be in the error message.