robot.writer package

Implements writing of parsed, and possibly edited, test data back to files.

This functionality is used by robot.parsing.model.TestCaseFile.save() and indirectly by robot.tidy. External tools should not need to use this package directly.

This package is considered stable, although the planned changes to robot.parsing may affect also this package.

Submodules

robot.writer.aligners module

class robot.writer.aligners.FirstColumnAligner(first_column_width)[source]

Bases: robot.writer.aligners._Aligner

align_row(row)
align_rows(rows)
class robot.writer.aligners.ColumnAligner(first_column_width, table)[source]

Bases: robot.writer.aligners._Aligner

align_row(row)
align_rows(rows)
class robot.writer.aligners.NullAligner(widths=None)[source]

Bases: robot.writer.aligners._Aligner

align_rows(rows)[source]
align_row(row)[source]

robot.writer.dataextractor module

class robot.writer.dataextractor.DataExtractor(want_name_on_first_row=None)[source]

Bases: object

Transforms table of a parsed test data file into a list of rows.

rows_from_table(table)[source]

robot.writer.datafilewriter module

class robot.writer.datafilewriter.DataFileWriter(**options)[source]

Bases: object

Object to write parsed test data file objects back to disk.

Parameters:**options – A WritingContext is created based on these.
write(datafile)[source]

Writes given datafile using **options.

Parameters:datafile (TestCaseFile, ResourceFile, TestDataDirectory) – The parsed test data object to be written
class robot.writer.datafilewriter.WritingContext(datafile, format='', output=None, pipe_separated=False, txt_separating_spaces=4, line_separator='n')[source]

Bases: object

Contains configuration used in writing a test data file to disk.

Parameters:
  • datafile (TestCaseFile, ResourceFile, TestDataDirectory) – The datafile to be written.
  • format (str) – Output file format. If omitted, read from the extension of the source attribute of the given datafile.
  • output – An open, file-like object used in writing. If omitted, value of source attribute of the given datafile is used to construct a new file object.
  • pipe_separated (bool) – Whether to use pipes as separator when output file format is txt.
  • txt_separating_spaces (int) – Number of separating spaces between cells in space separated format.
  • line_separator (str) – Line separator used in output files.

If output is not given, an output file is created based on the source of the given datafile and value of format. Examples:

Write output in a StringIO instance using format of datafile.source:

WriteConfiguration(datafile, output=StringIO)

Output file is created from datafile.source by stripping extension and replacing it with html:

WriteConfiguration(datafile, format='html')
txt_format = 'txt'
html_format = 'html'
tsv_format = 'tsv'
robot_format = 'robot'
txt_column_count = 8
html_column_count = 5
tsv_column_count = 8

robot.writer.filewriters module

robot.writer.filewriters.FileWriter(context)[source]

Creates and returns a FileWriter object.

Parameters:context (WritingContext) – The type of the returned FileWriter is determined based on context.format. context is also passed to created writer.
class robot.writer.filewriters.SpaceSeparatedTxtWriter(configuration)[source]

Bases: robot.writer.filewriters._DataFileWriter

write(datafile)
class robot.writer.filewriters.PipeSeparatedTxtWriter(configuration)[source]

Bases: robot.writer.filewriters._DataFileWriter

write(datafile)
class robot.writer.filewriters.TsvFileWriter(configuration)[source]

Bases: robot.writer.filewriters._DataFileWriter

write(datafile)
class robot.writer.filewriters.HtmlFileWriter(configuration)[source]

Bases: robot.writer.filewriters._DataFileWriter

write(datafile)[source]

robot.writer.formatters module

class robot.writer.formatters.TsvFormatter(column_count)[source]

Bases: robot.writer.formatters._DataFileFormatter

empty_row_after(table)
format_header(table)
format_table(table)
class robot.writer.formatters.TxtFormatter(column_count)[source]

Bases: robot.writer.formatters._DataFileFormatter

empty_row_after(table)
format_header(table)
format_table(table)
class robot.writer.formatters.PipeFormatter(column_count)[source]

Bases: robot.writer.formatters.TxtFormatter

empty_row_after(table)
format_header(table)
format_table(table)

robot.writer.htmlformatter module

class robot.writer.htmlformatter.HtmlFormatter(column_count)[source]

Bases: robot.writer.formatters._DataFileFormatter

format_header(table)[source]
empty_row_after(table)
format_table(table)
class robot.writer.htmlformatter.HtmlCell(content='', attributes=None, tag='td', escape=True)[source]

Bases: object

class robot.writer.htmlformatter.NameCell(name='', attributes=None)[source]

Bases: robot.writer.htmlformatter.HtmlCell

class robot.writer.htmlformatter.AnchorNameCell(name, type_)[source]

Bases: robot.writer.htmlformatter.HtmlCell

class robot.writer.htmlformatter.DocumentationCell(content, span)[source]

Bases: robot.writer.htmlformatter.HtmlCell

class robot.writer.htmlformatter.HeaderCell(name, span=1)[source]

Bases: robot.writer.htmlformatter.HtmlCell

robot.writer.htmltemplate module

robot.writer.rowsplitter module

class robot.writer.rowsplitter.RowSplitter(cols=8, split_multiline_doc=True)[source]

Bases: object

split(row, table_type)[source]