util: add helper to read .hidden file

This commit is contained in:
NecRaul 2026-03-08 11:33:44 +04:00
parent ffe6a9aa6f
commit 665a40ed0e
No known key found for this signature in database

View file

@ -2381,6 +2381,13 @@ def u8safe(txt: str) -> str:
except: except:
return txt.encode("utf-8", "replace").decode("utf-8", "replace") return txt.encode("utf-8", "replace").decode("utf-8", "replace")
def load_dothidden(dpath: str) -> set[str]:
try:
with open(os.path.join(dpath, ".hidden"), "rb") as f:
return {ln.strip() for ln in f.read().decode("utf-8", "replace").splitlines()}
except OSError:
return {}
def exclude_dotfiles(filepaths: list[str]) -> list[str]: def exclude_dotfiles(filepaths: list[str]) -> list[str]:
return [x for x in filepaths if not x.split("/")[-1].startswith(".")] return [x for x in filepaths if not x.split("/")[-1].startswith(".")]