Renders the barcode using `self.writer`. :param writer_options: Options for `self.writer`, see writer docs for details. :param text: Text to render under the barcode. :returns: Output of the writers render method.
(self, writer_options: dict | None = None, text: str | None = None)
| 94 | self.writer.write(output, fp) |
| 95 | |
| 96 | def render(self, writer_options: dict | None = None, text: str | None = None): |
| 97 | """Renders the barcode using `self.writer`. |
| 98 | |
| 99 | :param writer_options: Options for `self.writer`, see writer docs for details. |
| 100 | :param text: Text to render under the barcode. |
| 101 | |
| 102 | :returns: Output of the writers render method. |
| 103 | """ |
| 104 | options = self.default_writer_options.copy() |
| 105 | options.update(writer_options or {}) |
| 106 | if options["write_text"] or text is not None: |
| 107 | if text is not None: |
| 108 | options["text"] = text |
| 109 | else: |
| 110 | options["text"] = self.get_fullcode() |
| 111 | self.writer.set_options(options) |
| 112 | code_list = self.build() |
| 113 | if not len(code_list) == 1: |
| 114 | raise RuntimeError("Code list must contain a single element.") |
| 115 | code = code_list[0] |
| 116 | return self.writer.render([code]) |
no test coverage detected