def translate(self): destination_path = self.destination.destination_path if destination_path not in ('<stdout>', '<string>'): # there is a specified destination dest_dir, extension = splitext(destination_path) if extension: # there is a filename in the destination dest_dir, dest_filename = split(destination_path) else: # The specified destination is a directory. A new filename is necessary dest_filename = splitext(basename(self.document.settings._source))[0] + '.html' self.destination = FileOutput(destination_path=join(dest_dir, dest_filename), encoding='utf-8') HTML5Writer.translate(self) self.rebuild_output() return