Exemplo n.º 1
0
 def generate(self, outputfile: str) -> None:
     self._close_graph()
     graphviz_extensions = ("dot", "gv")
     name = self.title
     if outputfile is None:
         target = "png"
         pdot, dot_sourcepath = tempfile.mkstemp(".gv", name)
         ppng, outputfile = tempfile.mkstemp(".png", name)
         os.close(pdot)
         os.close(ppng)
     else:
         target = Path(outputfile).suffix.lstrip(".")
         if not target:
             target = "png"
             outputfile = outputfile + "." + target
         if target not in graphviz_extensions:
             pdot, dot_sourcepath = tempfile.mkstemp(".gv", name)
             os.close(pdot)
         else:
             dot_sourcepath = outputfile
     with open(dot_sourcepath, "w", encoding="utf8") as outfile:
         outfile.writelines(self.lines)
     if target not in graphviz_extensions:
         check_graphviz_availability()
         use_shell = sys.platform == "win32"
         subprocess.call(
             ["dot", "-T", target, dot_sourcepath, "-o", outputfile],
             shell=use_shell,
         )
         os.unlink(dot_sourcepath)
Exemplo n.º 2
0
    def __init__(self, args: Iterable[str]):
        super().__init__(usage=__doc__)
        insert_default_options()
        args = self.load_command_line_configuration(args)
        if self.config.output_format not in ("dot", "vcg", "puml", "plantuml"):
            check_graphviz_availability()

        sys.exit(self.run(args))
Exemplo n.º 3
0
    def __init__(self, args: Iterable[str]):
        super().__init__(usage=__doc__)
        insert_default_options()
        args = self.load_command_line_configuration(args)
        if self.config.output_format not in DIRECTLY_SUPPORTED_FORMATS:
            check_graphviz_availability()
            print(
                f"Format {self.config.output_format} is not supported natively. Pyreverse will try to generate it using Graphviz..."
            )
            check_if_graphviz_supports_format(self.config.output_format)

        sys.exit(self.run(args))
Exemplo n.º 4
0
    def __init__(self, args: Sequence[str]) -> NoReturn:  # type: ignore[misc]
        _ArgumentsManager.__init__(self, prog="pyreverse", description=__doc__)
        _ArgumentsProvider.__init__(self, self)

        # Parse options
        insert_default_options()
        args = self._parse_command_line_configuration(args)

        if self.config.output_format not in DIRECTLY_SUPPORTED_FORMATS:
            check_graphviz_availability()
            print(
                f"Format {self.config.output_format} is not supported natively. Pyreverse will try to generate it using Graphviz..."
            )
            check_if_graphviz_supports_format(self.config.output_format)

        sys.exit(self.run(args))