Generate output from the supplied template All the public methods and fields of this class can be accessed from the template via "algo". :param template_path: Relative or absolute file path to the template :param output_path: Relative or absolute file path
(self, template_path, output_path, data_dict=None)
| 141 | raise Exception("Unsupported format %s" % fmt) |
| 142 | |
| 143 | def process_template(self, template_path, output_path, data_dict=None): |
| 144 | """ |
| 145 | Generate output from the supplied template |
| 146 | |
| 147 | All the public methods and fields of this class can be accessed from |
| 148 | the template via "algo". |
| 149 | |
| 150 | :param template_path: Relative or absolute file path to the template |
| 151 | :param output_path: Relative or absolute file path to create |
| 152 | :param data_dict: Additional data to use when generating |
| 153 | """ |
| 154 | if data_dict is None: |
| 155 | data_dict = {} |
| 156 | else: |
| 157 | assert isinstance(data_dict, dict) |
| 158 | data_dict = dict(data_dict) |
| 159 | assert "algo" not in data_dict, "algo already set by user data" |
| 160 | data_dict["algo"] = self |
| 161 | |
| 162 | with open(template_path) as file_handle: |
| 163 | template_text = file_handle.read() |
| 164 | |
| 165 | template = jinja2.Template(template_text) |
| 166 | target_text = template.render(data_dict) |
| 167 | |
| 168 | with open(output_path, "w") as file_handle: |
| 169 | file_handle.write(target_text) |
| 170 | |
| 171 | |
| 172 | def _extract_symbols(simple_elf, symbols, default=None): |