Receipts
Module containing the class for generating test receipts.
TestReceipts
Class for generating test receipts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_path |
str
|
Path to the template file to be used for generating the receipts. |
required |
jinja_env_kwargs |
Dict
|
Keyword arguments to be passed to the jinja2.Environment constructor. |
None
|
Source code in paramaterial\receipts.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
generate_receipts(ds, receipts_path, replace_dict, receipts_dir='./receipts', clean=True)
Generate receipts for the tests in the DataSet. The receipts are saved as pdf files in the receipts_dir directory. The directory structure is receipts_dir/test_id/(files for test_id receipt). The receipts are merged into a single pdf file and saved at receipts_path. The replace_dict dictionary is used to replace the placeholders in the template file. The keys of the dictionary are the placeholders, and the values are the replacement strings. The values can also be functions that take a DataItem as input and return a string. The functions are called with the DataItem corresponding to the test_id of the receipt being generated. If the function generates a plot, it should save the plot in the current directory and return the name of the saved plot-file
Source code in paramaterial\receipts.py
parse_placeholders(as_dict=False)
Parse the template file for placeholders. With the default setup for the jinja2.Environment, placeholders are defined as \VAR{placeholder_name}. The placeholders are returned as a list of strings, or as a dictionary with the placeholder names as keys and None as values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
as_dict |
bool
|
If True, return a dictionary with the placeholder names as keys and None as values. If False, |
False
|