INNER CODE UNIT · Python
__init__
wasm3/wasm3 · extra/format.py:94
def __init__(self):
self._at = {}
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."""