FAQ - How to make a dependency on all files in a folder

Skip to first unread message

Fotis Jannidis

Jul 10, 2020, 7:51:59 AM7/10/20
to python-doit

The FAQ says:
" file_dep does NOT support folders. If you want to specify all files from a folder you can use a third party library like pathlib ( pathlib was add on python’s 3.4 stdlib)."

The obvious way to refer to all files in a folder with pathlib is using the functions glob() or iterdir(). Both do not work here, because 'file_dep must be a str or Path from pathlib' and these functions return a generator. From PEP 428 it seems to me that Path objects always refer to a specific file or directory. So I am stumped again. Sorry for all the questions.

best wishes

ps: I know that I could write my own update function but this seems like overkill for such an everyday functionality.

pps: and if you just wrap the directory in a path object it obviously doesn't work either because you cannot compute a hash on a dir object.

Samuel Lotz

Aug 13, 2020, 8:35:06 PM8/13/20
to python-doit
Just "unpack" the generator using the list constructor `list(p.glob("*"))`
Reply all
Reply to author
0 new messages