def tex_to_dvi(tex_file): tex_config = get_tex_config() program = tex_config["executable"] file_type = tex_config["intermediate_filetype"] result = tex_file.replace(".tex", "." + file_type) if not os.path.exists(result): commands = [ program, "-interaction=batchmode", "-halt-on-error", f"-output-directory=\"{os.path.dirname(tex_file)}\"", f"\"{tex_file}\"", ">", os.devnull ] exit_code = os.system(" ".join(commands)) if exit_code != 0: log_file = tex_file.replace(".tex", ".log") log.error("LaTeX Error! Not a worry, it happens to the best of us.") with open(log_file, "r", encoding="utf-8") as file: for line in file.readlines(): if line.startswith("!"): log.debug(f"The error could be: `{line[2:-1]}`") raise LatexError() return result
def interpolate(start, end, alpha): try: return (1 - alpha) * start + alpha * end except TypeError: log.debug(f"`start` parameter with type `{type(start)}` and dtype `{start.dtype}`") log.debug(f"`end` parameter with type `{type(end)}` and dtype `{end.dtype}`") log.debug(f"`alpha` parameter with value `{alpha}`") import sys sys.exit(2)
def print_family(mobject: Mobject, n_tabs: int = 0) -> None: """For debugging purposes""" log.debug("\t" * n_tabs + str(mobject) + " " + str(id(mobject))) for submob in mobject.submobjects: print_family(submob, n_tabs + 1)
def list_tex_strings_of_submobjects(self): # Work with `index_labels()`. log.debug(f"Submobjects of \"{self.get_tex()}\":") for i, submob in enumerate(self.submobjects): log.debug(f"{i}: \"{submob.get_tex()}\"")