def METHOD_NAME(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')