############################################################################### # # Theme - A class for writing the Excel XLSX Worksheet file. # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2013-2025, John McNamara, jmcnamara@cpan.org # from io import StringIO class Theme: """ A class for writing the Excel XLSX Theme file. """ ########################################################################### # # Public API. # ########################################################################### def __init__(self): """ Constructor. """ super().__init__() self.fh = None self.internal_fh = False ########################################################################### # # Private API. # ########################################################################### def _assemble_xml_file(self): # Assemble and write the XML file. self._write_theme_file() if self.internal_fh: self.fh.close() def _set_xml_writer(self, filename): # Set the XML writer filehandle for the object. if isinstance(filename, StringIO): self.internal_fh = False self.fh = filename else: self.internal_fh = True # pylint: disable=consider-using-with self.fh = open(filename, mode="w", encoding="utf-8") ########################################################################### # # XML methods. # ########################################################################### def _write_theme_file(self): # Write a default theme.xml file. # pylint: disable=line-too-long default_theme = """\n""" # noqa self.fh.write(default_theme)