INNER CODE UNIT · Python

patterns

wasm3/wasm3 · extra/format.py:97

    def patterns(self, line):
        """One .gitignore line as (fnmatch patterns, whether it names directories only).

        An anchored line matches at its own level only; an unanchored one matches at any
        depth below the .gitignore holding it, which takes a second pattern to say.
        """
        directory = line.endswith("/")
        anchored = "/" in line.rstrip("/")
        line = line.strip("/")
        return ([line] if anchored else [line, "*/" + line]), directory

    def at(self, dirpath):
        """What the .gitignore in `dirpath` names, as a (whatever it is, directories
        only) pair of blacklists over paths relative to `dirpath`. Read once per
        directory, and empty where there is no .gitignore."""
        if dirpath not in self._at:
            anything, dirs_only = list(self.ALWAYS), []
            try:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…