You're reading an old version of this documentation. If you want up-to-date information, please have a look at v0.8.2.

snl_d3d_cec_verify.report package

class snl_d3d_cec_verify.report.Content(width=None)

Bases: object

Class for storing document content in Pandoc markdown format. Use in conjunction with the Report class.

Content is stored in order, for example:

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> print(report)
1: one
2:
3: two
4:

Note that an empty line is placed between each part of the content.

Parameters:

width (Optional[int]) – maximum paragraph width, in characters

width: Optional[int] = None

maximum paragraph width, in characters

add_text(text, wrapped=True)

Add a paragraph of text to the document.

>>> report = Report()
>>> report.content.add_text("one")
>>> print(report)
1: one
2:
Parameters:
  • text (str) – Paragraph text

  • wrapped (bool) – Wrap the text based on the value of the width parameter, defaults to True.

add_heading(text, level=1)

Add a heading to the document.

>>> report = Report()
>>> report.content.add_heading("One")
>>> print(report)
1: # One
2:
Parameters:
  • text (str) – Heading text

  • level (int) – Heading level, defaults to 1.

add_table(dataframe, index=True, caption=None)

Add a table to the document, converted from a pandas.DataFrame.

>>> report = Report()
>>> a = {"a": [1, 2],
...      "b": [3, 4]}
>>> df = pd.DataFrame(a)
>>> report.content.add_table(df, index=False, caption="A table")
>>> print(report)
1: |   a |   b |
2: |----:|----:|
3: |   1 |   3 |
4: |   2 |   4 |
5:
6: Table:  A table
7:
Parameters:
  • dataframe (DataFrame) – DataFrame containing the table headings and data

  • index (bool) – include the DataFrame index in the table, defaults to True

  • caption (Optional[str]) – add a caption for the table

add_image(path, caption=None, width=None, height=None)

Add image to document, passed as path to a compatible image file.

>>> report = Report()
>>> report.content.add_image("high_art.png",
...                          caption="Probably an NFT",
...                          width="6in",
...                          height="4in")
>>> print(report)
1: ![Probably an NFT](high_art.png){ width=6in height=4in }
2:
Parameters:
  • path (Union[str, Path]) – path to the image file

  • caption (Optional[str]) – caption for the image

  • width (Optional[str]) – image width in document, including units

  • height (Optional[str]) – image height in document, including units

clear()

Remove all content from the document

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> report.content.clear()
>>> print(report)
undo()

Undo the last content addition

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> report.content.undo()
>>> print(report)
1: one
2: