INNER CODE UNIT · Python

version

wasm3/wasm3 · extra/format.py:285

    def version(self):
        """The clang-format on PATH, as (major, printable version).

        `major` is None when the banner cannot be read, leaving the caller to decide
        what a version it cannot identify is worth. Not being able to run clang-format
        at all is something else, and raises.
        """
        try:
            out = subprocess.run(
                [self.NAME, "--version"], capture_output=True, text=True, check=True
            ).stdout
        except (OSError, subprocess.CalledProcessError) as e:
            raise FormatterError(f"cannot run {self.NAME}: {e}") from e

        m = re.search(r"\bversion\s+(\d+)\.(\S+)", out)
        if not m:
            return None, f"an unrecognised version ({out.strip()})"
        return int(m.group(1)), f"{m.group(1)}.{m.group(2)}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…