ncdiff.writer package¶
Submodules¶
ncdiff.writer.base module¶
Diff tool classes for writing diff result files of different data types.
- since
2012-02-10
-
ncdiff.writer.base.
create_writer
(target_config: ncdiff.configuration.TargetConfiguration, result_format: str) → ncdiff.writer.base.BaseWriter¶ Create the writer according the passed configuration.
- Parameter
target_config – The configuration of the diff target.
result_format – The name of the result format the writer should be created for.
For a diff configuration multiple output formats are possible :return: A writer that can handle the row dictionaries produced by the differ.
-
ncdiff.writer.base.
create_statistic_writer
(target_config: ncdiff.configuration.TargetConfiguration, result_format: str) → ncdiff.writer.base.BaseWriter¶ Create the writer according the passed configuration for the status report.
- Parameter
target_config (
TargetConfiguration
) – The configuration of the diff target.result_format – The name of the result format the writer should be created for.
For a diff configuration multiple output formats are possible :type result_format:
str
:return: A writer that can write the row dictionaries of a statistics result. :rtype:BaseWriter
-
ncdiff.writer.base.
create_writer_chain
(target_config: ncdiff.configuration.TargetConfiguration) → ncdiff.writer.base.WriterChain¶ Create a writer class chain according the passed configuration.
- Parameter
target_config – The configuration of the diff target.
- Rückgabe
A writer chain
-
ncdiff.writer.base.
create_statistic_writer_chain
(target_config: ncdiff.configuration.TargetConfiguration) → ncdiff.writer.base.WriterChain¶ Create the writer class according the passed configuration for the status report.
- Parameter
target_config – The configuration of the diff target.
- Rückgabe
A writer chain
-
class
ncdiff.writer.base.
BaseWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
object
Base class for all writer implementations.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer.
-
open
() → None¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if the writer has reached it’s maximum line limit.
-
-
class
ncdiff.writer.base.
NoneWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.BaseWriter
Writer which does not write anything.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.base.
WriterChain
¶ Bases:
ncdiff.writer.base.BaseWriter
Exposes the writer interface for a list of writers to write different output in one step.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
add_writer
(writer: ncdiff.writer.base.BaseWriter) → None¶ Add a writer implementation to the list.
- Parameter
writer (
BaseWriter
) – A writer object implementing theBaseWriter
interface.
-
close
() → None¶ Close the writer.
-
open
() → None¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if all writers have reached their maximum line limit
-
-
class
ncdiff.writer.base.
FileWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.BaseWriter
Defines common methods to collect report lines, format and sort them and write the lines into a file.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Set the line counter to 0.
-
open
(file_name: str) → None¶ Open the writer.
- Parameter
file_name – The file name
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name.
- Parameter
file_name – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if the writer has reached it’s maximum line limit.
-
ncdiff.writer.cl module¶
Writer classes for command line.
- since
2012-02-10
-
class
ncdiff.writer.cl.
CLStatisticWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.BaseWriter
Pretty print the statistic information.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the writer.
-
open
()¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_statistic: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the information to the command line.
- Parameter
diff_statistic (
TargetStatistic
) – The object / list of dictionaries containing the fields.
-
ncdiff.writer.converter module¶
Provides converter classes for writers to convert a type to a specific string.
- since
2012-02-10
-
class
ncdiff.writer.converter.
BaseLineConverter
¶ Bases:
object
Abstract base class to convert result objects to lines.
-
convert
(result_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.TargetStatistic]) → List[Dict[str, Any]]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj (
object
) – The object containing the fields.- Rückgabe
array of dictionaries with field information
- Rückgabetyp
list
-
-
class
ncdiff.writer.converter.
NoneLineConverter
¶ Bases:
ncdiff.writer.converter.BaseLineConverter
Line converter which just returns the line info without any conversion.
-
convert
(result_obj: ncdiff.diff_value.DiffValue) → List[Dict[str, Any]]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj – The object containing the fields.
- Rückgabe
array of dictionaries with field information
-
-
class
ncdiff.writer.converter.
NoneStatisticConverter
¶ Bases:
ncdiff.writer.converter.BaseLineConverter
Line converter which just returns the line info without any conversion.
-
convert
(result_obj: ncdiff.statistics.TargetStatistic) → Dict[str, Any]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj – The object containing the fields.
- Rückgabe
dictionary with statistic information
-
ncdiff.writer.csv module¶
Writer classes for CSV files.
- since
2012-02-10
-
class
ncdiff.writer.csv.
CSVWriter
(target_config, csv_delimiter=';')¶ Bases:
ncdiff.writer.base.FileWriter
Report which is capable of writing csv data immediately line by line by calling write.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj)¶ Call the methods who writes some lines to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.csv.
CSVStatisticWriter
(target_config, csv_delimiter=';')¶ Bases:
ncdiff.writer.base.FileWriter
Simple statistic file writing csv data immediately line by line by calling write.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj)¶ Call the methods who writes some lines to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
ncdiff.writer.formatter module¶
Formatter classes for the writer.
- since
2012-02-10
-
class
ncdiff.writer.formatter.
Formatter
¶ Bases:
object
Base class of the data formatter.
The formatter are responsible to convert data types and their values into the format which should be displayed in the report.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
-
class
ncdiff.writer.formatter.
TypeFormatter
¶ Bases:
ncdiff.writer.formatter.Formatter
Base class of the data type formatter.
The formatter are responsible to convert data types and their values into the format which should be displayed in the report.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_type_to_format
() → List[Any]¶ Get the data type for which this formatter is registered. Can be a single type or a list of there of.
- Rückgabe
The data type for which this formatter is registered.
- Rückgabetyp
type
orlist of type
-
-
class
ncdiff.writer.formatter.
ColumnFormatter
(column_name: str)¶ Bases:
ncdiff.writer.formatter.Formatter
Base class for all formatter registered on a specific column.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_column_name_to_format
() → str¶ Return the column name to format.
- Rückgabe
The column name to format.
-
-
class
ncdiff.writer.formatter.
PercentFormatter
(column_name: str, number_format: str = 'DE', decimals: int = 2)¶ Bases:
ncdiff.writer.formatter.ColumnFormatter
Column formatter to print a number in percent.
-
format
(key: str, values: Dict[str, Any]) → str¶ Formatter to generate a hyperlink for the given value.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_column_name_to_format
() → str¶ Return the column name to format.
- Rückgabe
The column name to format.
-
-
class
ncdiff.writer.formatter.
NoneTypeFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formatter for
None
types - just returnsNone
which is then not displayed in the report.-
format
(key: str, values: Dict[str, Any]) → str¶ Format an empty value.
- Parameter
key (
str
) – The key of the parameter to convert.values (
dict
) – The parameters to convert.
- Rückgabe
The converted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
None
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
type
-
-
class
ncdiff.writer.formatter.
DateTimeFormatter
(date_format: str = '%Y-%m-%d', time_format: str = '%H:%M:%S')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats various date and time objects into a consistent format.
By default the ISO date and time format is used.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
) for which this formatter is registered.- Rückgabe
The data type for which this converter is registered.
-
-
class
ncdiff.writer.formatter.
TimeDeltaFormatter
(time_format: str = '%H:%M:%S')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats timedelta objects into a consistent format.
By default the ISO date and time format is used.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
,ael.date
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.formatter.
TimeInSecondsFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats timedelta objects to show its value in seconds.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
,ael.date
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.formatter.
NumberFormatter
(number_format: str = 'DE', decimals: int = None, nan_value: str = '')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats numbers into a consistent output format.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
int
,float
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.formatter.
TypeTypeFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats a python type into a string.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type
type
for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
-
ncdiff.writer.html module¶
Writer classes for HTML files.
To create HTML output the mako template library is used.
- since
2012-02-10
-
class
ncdiff.writer.html.
HTMLWriter
(target_config)¶ Bases:
ncdiff.writer.html.BaseHTMLWriter
Report which is capable of writing the data immediately line by line by calling write.
-
TAB_CONFIGURATION
= 'Config'¶
-
TAB_DIFFERENCES
= 'Differences'¶
-
TAB_FILES
= 'Files'¶
-
TAB_SUFFIX
= '-Data'¶
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open and initialize the html file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_ressource_directory
(res)¶ Set the resource directory for HTML output.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write the data into the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.html.
HTMLStatisticWriter
(target_config)¶ Bases:
ncdiff.writer.html.BaseHTMLWriter
Writer of the HTML statistics file.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open and initialize the html file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_ressource_directory
(res)¶ Set the resource directory for HTML output.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write the table lines into the table in html file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.
-
ncdiff.writer.junit module¶
Writer classes for JUNIT files.
- since
2020-04-03
-
class
ncdiff.writer.junit.
JUNITWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.NoneWriter
The junit writer class.
This class does not write anything since the junit result is just created for the overall statistic.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.junit.
JUNITStatisticWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.FileWriter
The junit statistic writer.
This writer creates a file in the junit XML format of the overall NCDiff statistic. The output can be used to be imported into CI/CD systems like Jenkins or Jira.
-
add_failure
(statistic: ncdiff.statistics.TargetStatistic, test_case: xml.etree.ElementTree.Element) → None¶ Add failure XML node if diff target was not successful. :param statistic: The target statistic object. :param test_case: The testcase element the failure XML element should be added.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the report file and frees up any resources.
-
get_test_class_name
(target_configuration: ncdiff.configuration.TargetConfiguration) → str¶ Get and format the test class name from the target configuration. :param target_configuration: The target configuration to get the name from. :return: The test class name.
-
open
()¶ Open the report file.
-
prettify_xml
(element: xml.etree.ElementTree.Element) → str¶ Return a pretty-printed XML string for the Element. :param element: The XML element tree to convert to a pretty XML string.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the statistics of the diff run into the xml file. :param diff_val_obj: The object / list of dictionaries containing the fields. :return: True if the writer has reached it’s maximum line limit.
-
ncdiff.writer.xlsx module¶
Writer classes for XLSX files.
- since
2012-02-10
-
class
ncdiff.writer.xlsx.
XLSXWriter
(target_config)¶ Bases:
ncdiff.writer.xlsx.BaseXLSXWriter
Excel report writer using external libraries.
-
CONFIG_SHEET_NAME
= 'Config'¶
-
FILES_SHEET_NAME
= 'Files'¶
-
MAX_COLUMNS
= 16384¶
-
MAX_ROWS
= 1000000¶
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Overwritten function for closing the opened file stream.
Normally there is no use for that, because a xlwt file doesn’t have to be closed separately.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names, field_names_old=None, field_names_new=None)¶ Set the header lines of a report.
- Parameter
field_names (
list of str
) – List of header stringsfield_names_old (
list of str
) – list of header strings from the old filefield_names_new (
list of str
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines)¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
The XLSX writer has a hard limit of 1000000 according the file format specification. :param max_result_lines: The number of result lines that will be written into the file. :type max_result_lines:
int
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write some lines which is specified by list of dictionaries directly to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.xlsx.
XLSXStatisticWriter
(target_config)¶ Bases:
ncdiff.writer.xlsx.BaseXLSXWriter
Excel statistic report writer using external librarie openpyxl.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Overwritten function to close the opened file stream and release resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names, field_names_old=None, field_names_new=None)¶ Set the header lines of a report.
- Parameter
field_names (
list of str
) – List of header stringsfield_names_old (
list of str
) – list of header strings from the old filefield_names_new (
list of str
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write some lines which is specified by list of dictionaries directly to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
ncdiff.writer.xray module¶
Writer classes for XRAY files.
- since
2020-04-14
-
class
ncdiff.writer.xray.
XRAYWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.NoneWriter
The Xray writer class.
This class does not write anything since the junit result is just created for the overall statistic.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.xray.
XRAYStatisticWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.FileWriter
The Xray statistic writer.
This writer creates a file in the Xray json format of the overall NCDiff statistic. The output can be used to be imported into Jira/Xray.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the statistics of the diff run into the xml file. :param diff_val_obj: The object / list of dictionaries containing the fields. :return: True if the writer has reached it’s maximum line limit.
-
Module contents¶
Writer package.
Defines public viewable API by specifying the __all__ list. :since: 2020-04-14
-
ncdiff.writer.
create_writer
(target_config: ncdiff.configuration.TargetConfiguration, result_format: str) → ncdiff.writer.base.BaseWriter¶ Create the writer according the passed configuration.
- Parameter
target_config – The configuration of the diff target.
result_format – The name of the result format the writer should be created for.
For a diff configuration multiple output formats are possible :return: A writer that can handle the row dictionaries produced by the differ.
-
ncdiff.writer.
create_statistic_writer
(target_config: ncdiff.configuration.TargetConfiguration, result_format: str) → ncdiff.writer.base.BaseWriter¶ Create the writer according the passed configuration for the status report.
- Parameter
target_config (
TargetConfiguration
) – The configuration of the diff target.result_format – The name of the result format the writer should be created for.
For a diff configuration multiple output formats are possible :type result_format:
str
:return: A writer that can write the row dictionaries of a statistics result. :rtype:BaseWriter
-
ncdiff.writer.
create_writer_chain
(target_config: ncdiff.configuration.TargetConfiguration) → ncdiff.writer.base.WriterChain¶ Create a writer class chain according the passed configuration.
- Parameter
target_config – The configuration of the diff target.
- Rückgabe
A writer chain
-
ncdiff.writer.
create_statistic_writer_chain
(target_config: ncdiff.configuration.TargetConfiguration) → ncdiff.writer.base.WriterChain¶ Create the writer class according the passed configuration for the status report.
- Parameter
target_config – The configuration of the diff target.
- Rückgabe
A writer chain
-
class
ncdiff.writer.
BaseWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
object
Base class for all writer implementations.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer.
-
open
() → None¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if the writer has reached it’s maximum line limit.
-
-
class
ncdiff.writer.
NoneWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.BaseWriter
Writer which does not write anything.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.
WriterChain
¶ Bases:
ncdiff.writer.base.BaseWriter
Exposes the writer interface for a list of writers to write different output in one step.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
add_writer
(writer: ncdiff.writer.base.BaseWriter) → None¶ Add a writer implementation to the list.
- Parameter
writer (
BaseWriter
) – A writer object implementing theBaseWriter
interface.
-
close
() → None¶ Close the writer.
-
open
() → None¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if all writers have reached their maximum line limit
-
-
class
ncdiff.writer.
FileWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.BaseWriter
Defines common methods to collect report lines, format and sort them and write the lines into a file.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Set the line counter to 0.
-
open
(file_name: str) → None¶ Open the writer.
- Parameter
file_name – The file name
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name.
- Parameter
file_name – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the passed lines to the file.
- Parameter
diff_val_obj – The object containing the fields.
- Rückgabe
True if the writer has reached it’s maximum line limit.
-
-
class
ncdiff.writer.
BaseLineConverter
¶ Bases:
object
Abstract base class to convert result objects to lines.
-
convert
(result_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.TargetStatistic]) → List[Dict[str, Any]]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj (
object
) – The object containing the fields.- Rückgabe
array of dictionaries with field information
- Rückgabetyp
list
-
-
class
ncdiff.writer.
NoneLineConverter
¶ Bases:
ncdiff.writer.converter.BaseLineConverter
Line converter which just returns the line info without any conversion.
-
convert
(result_obj: ncdiff.diff_value.DiffValue) → List[Dict[str, Any]]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj – The object containing the fields.
- Rückgabe
array of dictionaries with field information
-
-
class
ncdiff.writer.
NoneStatisticConverter
¶ Bases:
ncdiff.writer.converter.BaseLineConverter
Line converter which just returns the line info without any conversion.
-
convert
(result_obj: ncdiff.statistics.TargetStatistic) → Dict[str, Any]¶ Convert the result_obj to a list of line dictionaries.
- Parameter
result_obj – The object containing the fields.
- Rückgabe
dictionary with statistic information
-
-
class
ncdiff.writer.
Formatter
¶ Bases:
object
Base class of the data formatter.
The formatter are responsible to convert data types and their values into the format which should be displayed in the report.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
-
class
ncdiff.writer.
TypeFormatter
¶ Bases:
ncdiff.writer.formatter.Formatter
Base class of the data type formatter.
The formatter are responsible to convert data types and their values into the format which should be displayed in the report.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_type_to_format
() → List[Any]¶ Get the data type for which this formatter is registered. Can be a single type or a list of there of.
- Rückgabe
The data type for which this formatter is registered.
- Rückgabetyp
type
orlist of type
-
-
class
ncdiff.writer.
ColumnFormatter
(column_name: str)¶ Bases:
ncdiff.writer.formatter.Formatter
Base class for all formatter registered on a specific column.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format values as string as a default.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_column_name_to_format
() → str¶ Return the column name to format.
- Rückgabe
The column name to format.
-
-
class
ncdiff.writer.
PercentFormatter
(column_name: str, number_format: str = 'DE', decimals: int = 2)¶ Bases:
ncdiff.writer.formatter.ColumnFormatter
Column formatter to print a number in percent.
-
format
(key: str, values: Dict[str, Any]) → str¶ Formatter to generate a hyperlink for the given value.
- Parameter
key – The key of the parameter to format.
values – The parameters to format.
- Rückgabe
The converted value.
-
get_column_name_to_format
() → str¶ Return the column name to format.
- Rückgabe
The column name to format.
-
-
class
ncdiff.writer.
NoneTypeFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formatter for
None
types - just returnsNone
which is then not displayed in the report.-
format
(key: str, values: Dict[str, Any]) → str¶ Format an empty value.
- Parameter
key (
str
) – The key of the parameter to convert.values (
dict
) – The parameters to convert.
- Rückgabe
The converted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
None
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
type
-
-
class
ncdiff.writer.
DateTimeFormatter
(date_format: str = '%Y-%m-%d', time_format: str = '%H:%M:%S')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats various date and time objects into a consistent format.
By default the ISO date and time format is used.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
) for which this formatter is registered.- Rückgabe
The data type for which this converter is registered.
-
-
class
ncdiff.writer.
TimeDeltaFormatter
(time_format: str = '%H:%M:%S')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats timedelta objects into a consistent format.
By default the ISO date and time format is used.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
,ael.date
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.
TimeInSecondsFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats timedelta objects to show its value in seconds.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
datetime
,date
,ael.date
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.
NumberFormatter
(number_format: str = 'DE', decimals: int = None, nan_value: str = '')¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats numbers into a consistent output format.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type (
int
,float
) for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
- Rückgabetyp
list of type
-
-
class
ncdiff.writer.
TypeTypeFormatter
¶ Bases:
ncdiff.writer.formatter.TypeFormatter
Formats a python type into a string.
-
format
(key: str, values: Dict[str, Any]) → str¶ Format the value.
- Parameter
key (
str
) – The key of the parameter to format.values (
dict
) – The parameters to format.
- Rückgabe
The formatted value.
- Rückgabetyp
str
-
get_type_to_format
() → List[Any]¶ Get the data type
type
for which this converter is registered.- Rückgabe
The data type for which this converter is registered.
-
-
class
ncdiff.writer.
CLStatisticWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.BaseWriter
Pretty print the statistic information.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the writer.
-
open
()¶ Open the writer.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_statistic: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the information to the command line.
- Parameter
diff_statistic (
TargetStatistic
) – The object / list of dictionaries containing the fields.
-
-
class
ncdiff.writer.
CSVWriter
(target_config, csv_delimiter=';')¶ Bases:
ncdiff.writer.base.FileWriter
Report which is capable of writing csv data immediately line by line by calling write.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj)¶ Call the methods who writes some lines to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.
CSVStatisticWriter
(target_config, csv_delimiter=';')¶ Bases:
ncdiff.writer.base.FileWriter
Simple statistic file writing csv data immediately line by line by calling write.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj)¶ Call the methods who writes some lines to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.
HTMLWriter
(target_config)¶ Bases:
ncdiff.writer.html.BaseHTMLWriter
Report which is capable of writing the data immediately line by line by calling write.
-
TAB_CONFIGURATION
= 'Config'¶
-
TAB_DIFFERENCES
= 'Differences'¶
-
TAB_FILES
= 'Files'¶
-
TAB_SUFFIX
= '-Data'¶
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open and initialize the html file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_ressource_directory
(res)¶ Set the resource directory for HTML output.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write the data into the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.
HTMLStatisticWriter
(target_config)¶ Bases:
ncdiff.writer.html.BaseHTMLWriter
Writer of the HTML statistics file.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Close the report file and frees up any resources.
-
open
()¶ Open and initialize the html file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_ressource_directory
(res)¶ Set the resource directory for HTML output.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write the table lines into the table in html file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.
-
-
class
ncdiff.writer.
JUNITWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.NoneWriter
The junit writer class.
This class does not write anything since the junit result is just created for the overall statistic.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.
JUNITStatisticWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.FileWriter
The junit statistic writer.
This writer creates a file in the junit XML format of the overall NCDiff statistic. The output can be used to be imported into CI/CD systems like Jenkins or Jira.
-
add_failure
(statistic: ncdiff.statistics.TargetStatistic, test_case: xml.etree.ElementTree.Element) → None¶ Add failure XML node if diff target was not successful. :param statistic: The target statistic object. :param test_case: The testcase element the failure XML element should be added.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the report file and frees up any resources.
-
get_test_class_name
(target_configuration: ncdiff.configuration.TargetConfiguration) → str¶ Get and format the test class name from the target configuration. :param target_configuration: The target configuration to get the name from. :return: The test class name.
-
open
()¶ Open the report file.
-
prettify_xml
(element: xml.etree.ElementTree.Element) → str¶ Return a pretty-printed XML string for the Element. :param element: The XML element tree to convert to a pretty XML string.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the statistics of the diff run into the xml file. :param diff_val_obj: The object / list of dictionaries containing the fields. :return: True if the writer has reached it’s maximum line limit.
-
-
class
ncdiff.writer.
XLSXWriter
(target_config)¶ Bases:
ncdiff.writer.xlsx.BaseXLSXWriter
Excel report writer using external libraries.
-
CONFIG_SHEET_NAME
= 'Config'¶
-
FILES_SHEET_NAME
= 'Files'¶
-
MAX_COLUMNS
= 16384¶
-
MAX_ROWS
= 1000000¶
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Overwritten function for closing the opened file stream.
Normally there is no use for that, because a xlwt file doesn’t have to be closed separately.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names, field_names_old=None, field_names_new=None)¶ Set the header lines of a report.
- Parameter
field_names (
list of str
) – List of header stringsfield_names_old (
list of str
) – list of header strings from the old filefield_names_new (
list of str
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines)¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
The XLSX writer has a hard limit of 1000000 according the file format specification. :param max_result_lines: The number of result lines that will be written into the file. :type max_result_lines:
int
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write some lines which is specified by list of dictionaries directly to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.
XLSXStatisticWriter
(target_config)¶ Bases:
ncdiff.writer.xlsx.BaseXLSXWriter
Excel statistic report writer using external librarie openpyxl.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
()¶ Overwritten function to close the opened file stream and release resources.
-
open
()¶ Open the report file and also write the header line to the file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names, field_names_old=None, field_names_new=None)¶ Set the header lines of a report.
- Parameter
field_names (
list of str
) – List of header stringsfield_names_old (
list of str
) – list of header strings from the old filefield_names_new (
list of str
) – list of header strings from the new file
-
set_file_name
(file_name)¶ Set the file name.
- Parameter
file_name (
str
) – The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
set_template
(template_dir, template_file)¶ Set a template file name.
- Parameter
template_dir (
str
) – The Name of a template directory.template_file (
str
) – The Name of a template file.
-
write
(diff_val_obj)¶ Write some lines which is specified by list of dictionaries directly to the file.
- Parameter
diff_val_obj (
DiffValue
orTargetStatistic
) – The object / list of dictionaries containing the fields.- Rückgabe
True if the writer has reached it’s maximum line limit.
- Rückgabetyp
bool
-
-
class
ncdiff.writer.
XRAYWriter
(target_config: Optional[ncdiff.configuration.TargetConfiguration])¶ Bases:
ncdiff.writer.base.NoneWriter
The Xray writer class.
This class does not write anything since the junit result is just created for the overall statistic.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the writer - nothing is done here.
-
open
() → None¶ Open the writer - nothing is done here.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The name of the file to write.
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results. :param max_result_lines: The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the data - nothing is done here. :return:
True
if the set max result line limit is reached.
-
-
class
ncdiff.writer.
XRAYStatisticWriter
(target_config: ncdiff.configuration.TargetConfiguration)¶ Bases:
ncdiff.writer.base.FileWriter
The Xray statistic writer.
This writer creates a file in the Xray json format of the overall NCDiff statistic. The output can be used to be imported into Jira/Xray.
-
add_formatter
(formatter: Union[ncdiff.writer.formatter.TypeFormatter, ncdiff.writer.formatter.ColumnFormatter]) → None¶ Add data formatters to the report.
The formatters are responsible to convert a data into the desired output type and format. For instance to convert
boolean
values intoyes
andno
. :param formatter: The formatter object. :type formatter:Formatter
-
close
() → None¶ Close the report file and frees up any resources.
-
open
()¶ Open the report file.
-
set_converter
(converter)¶ Set the converter to convert result objects into output lines.
- Parameter
converter (
BaseConverter
) – The converter to convert results to lines.
-
set_field_names
(field_names: List[str], field_names_old: Optional[List[str]] = None, field_names_new: Optional[List[str]] = None)¶ Set the header lines of a report.
- Parameter
field_names (
list of
) – List of header stringsfield_names_old (
list of
) – list of header strings from the old filefield_names_new (
list of
) – list of header strings from the new file
-
set_file_name
(file_name: str) → None¶ Set the file name. :param file_name: The Name of a File
-
set_max_result_lines
(max_result_lines: int) → None¶ Set the maximum number of lines allowed to reach until the writer stops writing results.
- Parameter
max_result_lines (
int
) – The number of result lines that will be written into the file.
-
set_target_statistic
(target_statistic)¶ Set this targets statistic object to be written to the output.
- Parameter
target_statistic (
TargetStatistic
) – The targets statistic object.
-
write
(diff_val_obj: Union[ncdiff.diff_value.DiffValue, ncdiff.statistics.OverallDiffStatistic]) → bool¶ Write the statistics of the diff run into the xml file. :param diff_val_obj: The object / list of dictionaries containing the fields. :return: True if the writer has reached it’s maximum line limit.
-