"""Manages the HTML log file.""" # pylint: disable=consider-using-f-string # pylint: disable=invalid-name # pylint: disable=line-too-long import atexit class HTMLLog: """Manages the HTML log file.""" def __init__(self, path): self.path = path with open(path, "w", encoding="utf8") as logfile: logfile.write( "" "\n" ) self.log(["#", "Opcode / Method", "..."]) atexit.register(self._close_tags) def _close_tags(self): with open(self.path, "a", encoding="utf8") as logfile: logfile.write("
") def log(self, values): """Append the given values to the HTML log.""" with open(self.path, "a", encoding="utf8") as logfile: logfile.write("") for val in values: logfile.write("%s" % val) logfile.write("\n") def print_log(self, message): """Print the given string and append it to the HTML log.""" print(message) self.log([message])