INNER CODE UNIT · Python
at
wasm3/wasm3 · extra/format.py:108
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:
with open(os.path.join(dirpath, ".gitignore"), encoding="utf-8") as f:
for line in f:
line = line.strip()
if line and not line.startswith(("#", "!")):
pats, directory = self.patterns(line)
(dirs_only if directory else anything).extend(pats)
except OSError:
pass
self._at[dirpath] = Blacklist(anything), Blacklist(dirs_only)
return self._at[dirpath]