Provides various ways of walking a directory tree

Created on Jun 9, 2011

exception cpip.util.DirWalk.ExceptionDirWalk

Exception class for this module.


list of weak references to the object (if defined)

class cpip.util.DirWalk.FileInOut(filePathIn, filePathOut)

A pair of (in, out) file paths


Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, filePathIn, filePathOut)

Create new instance of FileInOut(filePathIn, filePathOut)


Return a nicely formatted representation string


Return a new OrderedDict which maps field names to their values.

classmethod _make(iterable, new=<built-in method __new__ of type object at 0xa385c0>, len=<built-in function len>)

Make a new FileInOut object from a sequence or iterable

_replace(_self, **kwds)

Return a new FileInOut object replacing specified fields with new values


Alias for field number 0


Alias for field number 1

cpip.util.DirWalk.dirWalk(theIn, theOut=None, theFnMatch=None, recursive=False, bigFirst=False)

Walks a directory tree generating file paths.

The input directory.
The output directory. If None then input file paths as strings will be generated If non-None this function will yield FileInOut(in, out) objects. NOTE: This does not create the output directory structure, it is up to the caller to do that.
A glob like match pattern for file names (not tested for directory names). Can be a list of strings any of which can match. If None or empty list then all files match.
Boolean to recurse into directories or not.
If True then the largest files in directory are given first. If False it is alphabetical.

Generator that yields the biggest files (name not path) first. This is fairly simple in that it it only looks the current directory not only sub-directories. Useful for multiprocessing.