diff options
Diffstat (limited to 'mu4web/util.py')
-rw-r--r-- | mu4web/util.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mu4web/util.py b/mu4web/util.py index 41601c5..7e2df8c 100644 --- a/mu4web/util.py +++ b/mu4web/util.py @@ -1,3 +1,5 @@ +"""Various misc. utilities.""" + import subprocess from os import PathLike from typing import ( @@ -5,9 +7,22 @@ from typing import ( ) -def find(basedir: PathLike, +def find(basedir: PathLike[str] | PathLike[bytes], **flags: str | bytes) -> list[bytes]: - cmdline: list[Union[str, bytes, PathLike]] = ['find', basedir] + """ + Run the shell command ``find``. + + :param basedir: + Directory to search under. + + :param flags: + Key-value pairs passed to find. Each key is prefixed with a + single dash. Compound searches might be possible with some + trickery, but extend this function instead of doing that. + """ + cmdline: list[Union[str, bytes, + PathLike[str], + PathLike[bytes]]] = ['find', basedir] for key, value in flags.items(): cmdline += [f'-{key}', value] cmdline.append('-print0') |