function in jsngram.dir2 module
Description
Scan files in a directory recursively, excluding dot files and dot directories.
Apply a specified function
to each file.
Example
def myfunc(path, dest): return path jsngram.dir2.apply_files('/scratch', None, myfunc, True) # [('/scratch/c/d.txt', None, '/scratch/c/d.txt'), # ('/scratch/c/e.txt', None, '/scratch/c/e.txt')]
Usage
jsngram.dir2.apply_files(path, dest, func, exclude_root_files=False)
Argument path is a source directory that will be scanned.
Argument dest is a destination directory.
Argument func is a function with two arguments (full path of a source file, destination directory).
Both arguments given to the func are integrated path that will keep consistent position between the source treen and the destination tree.
You can use this to convert multiple files
with a function that converts file from source to destination.
Or use this to get some information from files
with a function that returns a summary from a file.
Returns a list of three element tuple, that is the source file path, destination and the return value of the func.
The length of the list is same as the number of files processed.
Creates dest directory tree before calling func unless dest = None
.
Skip files at top directory if exclude_root_files = True
.