Walk a directory recursively, yielding each file/directory
'''
- def walk_dir(dir_path):
- '''
- Walk a directory, yielding each file/directory
- '''
- for filename in sorted(os.listdir(dir_path)):
- file_path = os.path.join(dir_path, filename)
- is_dir = os.path.isdir(file_path)
- if self.filter_path(file_path, source_path, is_dir) == NO_MATCH:
- continue
- if not os.access(file_path, os.R_OK):
- self.logger.warn('Error accessing possibly locked file %s' % file_path)
- continue
- yield file_path
-
queue = [source_path]
if strip_base_dir:
if not os.path.exists(cur_path):
continue
- for child in walk_dir(cur_path):
+ for filename in sorted(os.listdir(cur_path)):
+ child = os.path.join(cur_path, filename)
is_dir = os.path.isdir(child)
status = self.filter_path(child, source_path, is_dir)
+ if status == NO_MATCH:
+ continue
+ if not os.access(child, os.R_OK):
+ self.logger.warn('Error accessing possibly locked file %s' % child)
+ continue
if status == MATCH:
yield child[beginning_size:]