Simple PDF reports using reportlab
Named report ‘report’ generates ‘report.pdf’ and directory ‘report/’ with images which were requested to be included in the report
You can attach report to the existing ‘verbose’ with
>>> report = Report()
>>> verbose.handlers += [report]
and then all verbose messages present on the screen will also be recorded in the report. Use
>>> report.text("string") # to add arbitrary text
>>> report.xml("<H1>skajdsf</H1>") # to add XML snippet
or
>>> report.figure() # to add the current figure to the report.
>>> report.figures() # to add existing figures to the report
Note that in the later usecase, figures might not be properly interleaved with verbose messages if there were any between the creations of the figures.
Inspired by Andy Connolly
Methods
clear() | Clear the report |
figure([fig, name, savefig_kwargs]) | Add a figure to the report :Parameters: fig : None or str or figure.Figure Figure to place into report: str is treated as a filename, Figure stores it into a file under directory and embeds into the report, and None takes the current figure savefig_kwargs : dict Additional keyword arguments to provide savefig with (e.g. |
figures(*args, **kwargs) | Adds all present figures at once |
flowbreak() | Just a marker for the break of the flow |
save([add_preamble]) | Saves PDF |
text(line, **kwargs) | Add a text string to the report |
write(line, **kwargs) | Add a text string to the report |
xml(line[, style]) | Adding XML string to the report |
Initialize report
Parameters: | name : string
title : string or None
path : string
author : string or None
style : string
fig_ext : string
font : string
pagesize : tuple of floats
|
---|
Methods
clear() | Clear the report |
figure([fig, name, savefig_kwargs]) | Add a figure to the report :Parameters: fig : None or str or figure.Figure Figure to place into report: str is treated as a filename, Figure stores it into a file under directory and embeds into the report, and None takes the current figure savefig_kwargs : dict Additional keyword arguments to provide savefig with (e.g. |
figures(*args, **kwargs) | Adds all present figures at once |
flowbreak() | Just a marker for the break of the flow |
save([add_preamble]) | Saves PDF |
text(line, **kwargs) | Add a text string to the report |
write(line, **kwargs) | Add a text string to the report |
xml(line[, style]) | Adding XML string to the report |
Clear the report
Add a figure to the report
Parameters: | fig : None or str or figure.Figure
savefig_kwargs : dict
**kwargs :
|
---|
Adds all present figures at once
If called twice, it might add the same figure multiple times, so make sure to close all previous figures if you use figures() multiple times
Just a marker for the break of the flow
Saves PDF
Parameters: | add_preamble : bool
|
---|
Add a text string to the report
Just an alias for .text, so we could simply provide report as a handler for verbose
Adding XML string to the report