Add a streaming writer for DiffX files.

Review Request #11713 — Created July 10, 2021 and submitted

Information

DiffX
master

Reviewers

This introduces diffx.writer.DiffXWriter, a streaming writer for the
DiffX file format. This is a low-level interface for writing DiffX
files to a stream (such as a local file, an in-progress HTTP response,
or a memory-backed stream) progressively, section-by-section, according
to the DiffX specification.

It carefully ensures that sections are never generated in the wrong
order, using the same state tree used for parsing. It also validates
that values going into options.

The writer tends to be thorough when it generates sections, opting to
explicitly provide information like the line ending types or the
metadata format, even when optional in DiffX files.

It's up to the consumer to write the correct preambles, metadata, diff
content, and any options not otherwise handled by the writer. However,
the writer will take care to compute some things, like line ending
types, if not otherwise provided (though it's recommended that callers
still provide these if they know them).

DiffXWriter should now be usable for production DiffX generation
(pending any new changes to the spec).

Unit tests pass on Python 2 and 3.

Summary ID
Add a streaming writer for DiffX files.
This introduces `diffx.writer.DiffXWriter`, a streaming writer for the DiffX file format. This is a low-level interface for writing DiffX files to a stream (such as a local file, an in-progress HTTP response, or a memory-backed stream) progressively, section-by-section, according to the DiffX specification. It carefully ensures that sections are never generated in the wrong order, using the same state tree used for parsing. It also validates that values going into options. The writer tends to be thorough when it generates sections, opting to explicitly provide information like the line ending types or the metadata format, even when optional in DiffX files. It's up to the consumer to write the correct preambles, metadata, diff content, and any options not otherwise handled by the writer. However, the writer will take care to compute some things, like line ending types, if not otherwise provided (though it's recommended that callers still provide these if they know them). `DiffXWriter` should now be usable for production DiffX generation (pending any new changes to the spec).
eccb3258f0e4c707bd4f8296510ebd45a1730135
Description From Last Updated

E501 line too long (81 > 79 characters)

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. python/diffx/tests/test_writer.py (Diff revision 2)
     
     

    Maybe mention "without raising an exception"?

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (c58be64)
Loading...