############################################################################### # # Theme - A class for writing the Excel XLSX Worksheet file. # # Copyright 2013-2019, John McNamara, jmcnamara@cpan.org # # Standard packages. import codecs import sys # Standard packages in Python 2/3 compatibility mode. from .compatibility import StringIO class Theme(object): """ A class for writing the Excel XLSX Theme file. """ ########################################################################### # # Public API. # ########################################################################### def __init__(self): """ Constructor. """ super(Theme, self).__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 self.fh = codecs.open(filename, 'w', 'utf-8') ########################################################################### # # XML methods. # ########################################################################### def _write_theme_file(self): # Write a default theme.xml file. default_theme = """\n""" if sys.version_info < (3, 0, 0): default_theme = default_theme.decode('unicode-escape') self.fh.write(default_theme)