mirror of
https://github.com/9001/copyparty.git
synced 2026-04-13 07:32:49 -06:00
util: add helper to read .hidden file
This commit is contained in:
parent
ffe6a9aa6f
commit
665a40ed0e
|
|
@ -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(".")]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue