pdk.Util.FileUtils ($Date: 2002/12/04 10:13:21 $)
index
pdk/Util/FileUtils.py

File handling utilities.

FOG 08.2001

 
Functions
            
collectfiles(startDir, extensionL, absolute=0, follow=0, recursive=1, exclude=None)
collects files of given extensions in a directory tree.
startDir is the directory where to start collecting; extensionL provides a list of file extensions to collect; absolute indicates whether to use absolte filenames; follow indicates whether to follow symbolic links (Unix only); exclude is a regular expression string; directories matching this regex are skipped.
collectfilesbysuffix(startDir, suffix)
collects files with an arbitrary suffix suffix in the directory tree starting with startDir.
commonprefix(*paths)

finds the common prefix for the paths given in *paths.

Note that this function, unlike its counterpart in os.path, does a os.path.normpath prior to the comparison so that "/home/user/../../vitaldata" and "/home/user" do _not_ have a common prefix! Note also that "/home/user" does not have a common prefix with "home/user", i.e., relative and absolute paths are distinguished.

commonpostfix(*paths)
finds the common postfix for the paths given in *paths. Note that a trailing os.sep character will spoil the comparison, i.e., "/usr/data/" will not have a common postfix with "/usr/local/data"!
comparefilesizes = comparefilestats(fileName1, fileName2, statItem=6)
compares the two files given by their names fileName1 and fileName2 with respect to the stat module constant statItem (defaults to stat.ST_SIZE).
comparefilestats(fileName1, fileName2, statItem=6)
compares the two files given by their names fileName1 and fileName2 with respect to the stat module constant statItem (defaults to stat.ST_SIZE).
copyfiles(fileNameL, targetDir, prompt=1)
copies files given in the list of file names fileNameL to the target directory given in targetDir. If prompt is set to 1, a console dialog is popped up in case a file is about to be overwritten.
filenameroot(filePath)
returns the root name of filePath. The root name is the complete path of a file stripped of the directory and the extension.
filenameext(filePath)
returns the extension of filePath.
getmtimestring(fileName, format='%Y-%b-%d %H:%M')
returns the modification time of a file as a formatted string
isexecutable(path)
checks whether the path path is executable.
isreadable(path)
checks whether the path path is readable.
iswritable(path)
checks whether the path path is writable.
oktowritefile(fileName, msg='File "%s" already exists. Overwrite [Y/N]?')
console-type file overwrite dialog.
safemkdirs(path)
stripprefix(prefixPath, path)
strips a prefix off a path. This will shorten path by prefixPath, if the latter is indeed a prefix of the former. Otherwise, path is returned unchanged.
 
Author
            
$Author: gathmann $