tests: add moultipart.py
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 22 Sep 2023 20:43:00 +0000 (16:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 20 Oct 2023 23:29:14 +0000 (19:29 -0400)
commiteda81eee9ee730911b3779cc367c51a7123fded8
tree06fd05a9b61381f83d7ce6e68a3b1e1a6041af6f
parent57f97a8936ce99cc380bcbbbc1f01200fba18bdf
tests: add moultipart.py

Add moultipart.py, a Python module to help read text files meant to be
split in different parts.  A moultipart-compliant file is a succession
of parts, where each part is made of a header line followed with zero or
more lines of content.

A header line consists of `---` optionally followed by a space and some
custom information.

The moultipart module exposes the `parse` function, which takes a TextIO
object and returns a list of Part objects.

For instance, the following input:

    --- Victoria
    Parenteau
    ---
    Taillon
    --- This part is empty
    --- Josianne
    Gervais

results in the following parts:

    [Part('Victoria', 'Parenteau\n', 2),
     Part('', 'Taillon\n', 4),
     Part('This part is empty', '', 6),
     Part('Josianne', 'Gervais\n', 7)]

Change-Id: I50fb88ed6e064c09deaf1d56187415bc26002a14
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10912
Tested-by: jenkins <jenkins@lttng.org>
setup.cfg
tests/utils/python/moultipart.py [new file with mode: 0644]
This page took 0.025124 seconds and 4 git commands to generate.