Package mvpa :: Package base :: Module report :: Class Report
[hide private]
[frames] | no frames]

Class Report

source code


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, but they
    might not be properly interleaved with verbose messages if there were
    any between the creations of the figures.

Inspired by Andy Connolly

Instance Methods [hide private]
 
__init__(self, name='report', title=None, path=None, author=None, style="Normal", fig_ext=None, font='Helvetica', pagesize=None)
Initialize report
source code
 
__preamble(self)
Compose the beginning of the report
source code
 
clear(self)
Clear the report
source code
 
xml(self, line, style=None)
Adding XML string to the report
source code
 
text(self, line, **kwargs)
Add a text string to the report
source code
 
write(self, line, **kwargs)
Just an alias for .text, so we could simply provide report as a handler for verbose
source code
 
figure(self, fig=None, name=None, savefig_kwargs={}, **kwargs)
Add a figure to the report
source code
 
figures(self, *args, **kwargs)
Adds all present figures at once
source code
 
__flowbreak(self) source code
 
flowbreak(self)
Just a marker for the break of the flow
source code
 
save(self, add_preamble=True)
Saves PDF
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name='report', title=None, path=None, author=None, style="Normal", fig_ext=None, font='Helvetica', pagesize=None)
(Constructor)

source code 
Initialize report
Parameters:
  • name (string) - Name of the report
  • title (string or None) - Title to start the report, if None, name will be used
  • path (string) - Top directory where named report will be stored. Has to be set now to have correct path for storing image renderings. Default: current directory
  • author (string or None) - Optional author identity to be printed
  • style (string) - Default Paragraph to be used. Must be the one of the known to reportlab styles, e.g. Normal
  • fig_ext (string) - What extension to use for figures by default. If None, a default will be used. Since versions prior 2.2 of reportlab might do not support pdf, 'png' is default for those, 'pdf' otherwise
  • font (string) - Name of the font to use
  • pagesize (tuple of floats) - Optional page size if not to be default
Overrides: object.__init__

__preamble(self)

source code 
Compose the beginning of the report
Decorators:
  • @property

figure(self, fig=None, name=None, savefig_kwargs={}, **kwargs)

source code 
Add a figure to the report

:Parameters:
  fig : None or string or `figure.Figure`
    Figure to place into report
      string : treat as a filename
      Figure : stores it into a file under directory
               and embedds into the report
      None :   takes the current figure
  savefig_kwargs : dict
    Additional keyword arguments to provide savefig with (e.g. dpi)
  **kwargs
    Passed to :class:`reportlab.platypus.Image` constructor

figures(self, *args, **kwargs)

source code 

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

__flowbreak(self)

source code 
Decorators:
  • @property

save(self, add_preamble=True)

source code 
Saves PDF
Parameters:
  • add_preamble (bool) - Either to add preamble containing title/date/author information