From: Christian Herdtweck Date: Fri, 17 Jun 2016 09:59:27 +0000 (+0200) Subject: simplify DeltaTar._recursive_walk_dir X-Git-Tag: v2.2~29 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=7dec665c8f553bec7ef7fe63f1864ebda9db7ba6;p=python-delta-tar simplify DeltaTar._recursive_walk_dir (had called os.path.isdir and filter_path twice on each file directly after another) --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 9bd6927..682667a 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -364,20 +364,6 @@ class DeltaTar(object): 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: @@ -391,9 +377,15 @@ class DeltaTar(object): 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:]