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)¶
-
robot.writer.dataextractor module¶
robot.writer.datafilewriter module¶
-
class
robot.writer.datafilewriter.DataFileWriter(**options)[source]¶ Bases:
objectObject to write parsed test data file objects back to disk.
Parameters: **options – A WritingContextis 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:
objectContains 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¶
- datafile (
robot.writer.filewriters module¶
-
robot.writer.filewriters.FileWriter(context)[source]¶ Creates and returns a
FileWriterobject.Parameters: context ( WritingContext) – The type of the returnedFileWriteris determined based oncontext.format.contextis 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)¶
-
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)¶
-
robot.writer.htmlformatter module¶
-
class
robot.writer.htmlformatter.HtmlFormatter(column_count)[source]¶ Bases:
robot.writer.formatters._DataFileFormatter-
empty_row_after(table)¶
-
format_table(table)¶
-
-
class
robot.writer.htmlformatter.HtmlCell(content='', attributes=None, tag='td', escape=True)[source]¶ Bases:
object