writer API reference

Writer class to be used with Jinja2 templates

class biomajmanager.writer.Writer(template_dir=None, config=None, output=None)[source]

Writer class for BioMAJ manager to create what’s desired as output

__init__(template_dir=None, config=None, output=None)[source]

Create Writer object

Parameters:
  • template_dir (str) – Root directory where to find templates
  • config (configparser) – Global configuration file from BiomajConfig
  • output (str) – Output file. Default STDOUT
Raises:
  • SystemExit – If ‘template_dir’ is not given
  • SystemExit – If ‘MANAGER’ section not found in manager.properties
  • SystemExit – If ‘template.dir’ not set in manager.properties
__weakref__

list of weak references to the object (if defined)

write(template=None, data=None)[source]

Print template ‘data’ to stdout using template file ‘template’.

‘data’ arg can be left None, this way method can be used to render file from scratch

Parameters:
  • template (str) – Template file name
  • data (dict) – Template data
Returns:

True, throws on error

Return type:

bool

Raises:
  • SystemExit – If ‘template’ is None
  • SystemExit – If ‘template’ is not found
  • SystemExit – If ‘template’ has a syntax error in it
  • SystemExit – If ‘output’ file cannot be opened