MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / resource_iter

Function resource_iter

src/commoncode/fileutils.py:364–378  ·  view source on GitHub ↗

Return an iterable of paths at `location` recursively. :param location: a file or a directory. :param ignored: a callable accepting a location argument and returning True if the location should be ignored. :return: an iterable of file and directory locations.

(location, ignored=ignore_nothing, with_dirs=True, follow_symlinks=False)

Source from the content-addressed store, hash-verified

362
363
364def resource_iter(location, ignored=ignore_nothing, with_dirs=True, follow_symlinks=False):
365 """
366 Return an iterable of paths at `location` recursively.
367
368 :param location: a file or a directory.
369 :param ignored: a callable accepting a location argument and returning True
370 if the location should be ignored.
371 :return: an iterable of file and directory locations.
372 """
373 for top, dirs, files in walk(location, ignored, follow_symlinks=follow_symlinks):
374 if with_dirs:
375 for d in dirs:
376 yield os.path.join(top, d)
377 for f in files:
378 yield os.path.join(top, f)
379
380
381#

Calls 2

walkFunction · 0.85
joinMethod · 0.45