Here's part of the output that's incorrect: models\W_BoomerEdge BYOS_C.entity.xml BYOS_C_Collision.entity.xml
Notice that the file BYOS_C.entity.xml is showing up as a file in the directory W_BoomerEdge. This file does not exist in this folder, but yet in a different folder. The output is consistent with the 'print' statements you will see in the function I posted earlier. On 8/17/07, Robert Dailey <[EMAIL PROTECTED]> wrote: > > Hi, > > I've created a function that is used to recurse a directory tree in > Windows XP using os.walk(). For the most part it works, however in some > instances the data is incorrect and I'm getting invalid sub-directory paths. > Here's the function: > > > def __doSearch( root_dir, sub_path, restype, ext ): > print sub_path > # Searches the specified directory and generates a > # list of files to preload. > complete_path = osp.normpath( osp.join( root_dir, sub_path ) ) > for root, dirs, files in os.walk( complete_path ): > > # Record the list of file hash ID's > for file in files: > split = __resType( file ) > if split[1] == restype: > # print sub_path > print "\t", file > __appendResource( ext, sub_path, split[0] ) > > # Remove .svn subdirectories; we don't walk these. > if ".svn" in dirs: > dirs.remove( ".svn" ) > > # Recurse child directories > for dir in dirs: > __doSearch( root_dir, osp.join( sub_path, dir ), restype, ext > ) > > Does anyone see anything immediately suspicious about the code? I'm > assuming that in Python, every time a function is called recursively it gets > its own copy of local variables. For some reason the sub_path variable isn't > consistent depending on where I use it. For example, if you notice the print > call at the very start of the function, it will output something like > "models/ships". However, after passing it into __appendResource(), it > appears to be just "models". >
-- http://mail.python.org/mailman/listinfo/python-list