flowtool.files

flowtool.files.find_parent_containing(name, path=None, check='exists', not_found=None)[source]

Return the nearest directory in the parent dirs of path, that contains name, or None if no such parent dir exists. The check can be customized/chosen from exists, isfile and isdir.

flowtool.files.find_subdirs_containing(name, path=None, check='exists', checklist=<function <lambda>>, not_found=None)[source]

Return the subdirectories containind name. The check can be chosen from exists, (is)file and (is)dir.

flowtool.files.check_file(path, for_content)[source]

Check wether a file contains a substring. Might be inefficient on large files.

flowtool.files.append_to_file(path, content)[source]

Append content to a File.

flowtool.files.cached_read(path)[source]

Read a file, cached.

flowtool.files.cached_readlines(path)[source]

Get the lines of a file, cached.

flowtool.files.is_executable(filename)[source]

Check wether a file has the executable bit set (for the owner).

flowtool.files.make_executable(filename)[source]

Make a file executable (for the owner).

flowtool.files.make_not_executable(filename)[source]

Make a file not executable (for the owner).

flowtool.files.toggle_executable(filename)[source]

Toggle the executable bit of a file (for the owner).

class flowtool.files.cd(path)[source]

A context manager to change the current working directory.

flowtool.files.topdirs(path)[source]

Generates the top directories of path.