INNER CODE UNIT · Python

config_for

wasm3/wasm3 · extra/format.py:327

    def config_for(self, path):
        """The .clang-format for `path`: the shared one, or a variant with its overrides.

        The variant is built by loading the config as the YAML it is and updating the
        keys, so a nested block is replaced wholesale rather than merged key by key --
        and so the result cannot end up with the duplicated mapping key that
        clang-format rejects.
        """
        rel = relative(path)
        for i, entry in enumerate(self.STYLE_OVERRIDES):
            if rel not in entry["files"]:
                continue
            if i not in self._derived:
                with open(self.CONFIG, encoding="utf-8") as f:
                    style = yaml.safe_load(f)
                style.update(entry["style"])
                fd, name = tempfile.mkstemp(
                    prefix="clang-format-", suffix=".yaml", text=True

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…