MCPcopy Index your code
hub / github.com/docker/docker-py / walk

Method walk

docker/utils/build.py:185–219  ·  view source on GitHub ↗
(self, root)

Source from the content-addressed store, hash-verified

183 return matched
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
221
222class Pattern:

Callers 5

exclude_pathsFunction · 0.95
walkFunction · 0.95
build_file_listFunction · 0.80
contextsMethod · 0.80
create_pluginMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected