MCPcopy Create free account
hub / github.com/docker/docker-py / rec_walk

Method rec_walk

docker/utils/build.py:186–217  ·  view source on GitHub ↗
(current_dir)

Source from the content-addressed store, hash-verified

184
185 def walk(self, root):
186 def rec_walk(current_dir):
187 for f in os.listdir(current_dir):
188 fpath = os.path.join(
189 os.path.relpath(current_dir, root), f
190 )
191 if fpath.startswith(f".{os.path.sep}"):
192 fpath = fpath[2:]
193 match = self.matches(fpath)
194 if not match:
195 yield fpath
196
197 cur = os.path.join(root, fpath)
198 if not os.path.isdir(cur) or os.path.islink(cur):
199 continue
200
201 if match:
202 # If we want to skip this file and it's a directory
203 # then we should first check to see if there's an
204 # excludes pattern (e.g. !dir/file) that starts with this
205 # dir. If so then we can't skip this dir.
206 skip = True
207
208 for pat in self.patterns:
209 if not pat.exclusion:
210 continue
211 if pat.cleaned_pattern.startswith(
212 normalize_slashes(fpath)):
213 skip = False
214 break
215 if skip:
216 continue
217 yield from rec_walk(cur)
218
219 return rec_walk(root)
220

Callers

nothing calls this directly

Calls 3

matchesMethod · 0.95
normalize_slashesFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected