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

Method walk

src/commoncode/resource.py:1433–1462  ·  view source on GitHub ↗

Yield all descendant Resources of this Resource. Does not include self. Walk the tree top-down, depth-first if `topdown` is True, otherwise walk bottom-up. Each level is sorted by children sort order (e.g. without-children, then with-children and each group

(self, codebase, topdown=True, ignored=ignore_nothing)

Source from the content-addressed store, hash-verified

1431 return files_count, dirs_count, size_count
1432
1433 def walk(self, codebase, topdown=True, ignored=ignore_nothing):
1434 """
1435 Yield all descendant Resources of this Resource. Does not include self.
1436
1437 Walk the tree top-down, depth-first if `topdown` is True, otherwise walk
1438 bottom-up.
1439
1440 Each level is sorted by children sort order (e.g. without-children, then
1441 with-children and each group by case-insensitive name)
1442
1443 `ignored` is a callable that accepts two arguments, `resource` and `codebase`,
1444 and returns True if `resource` should be ignored.
1445 """
1446
1447 for child in self.children(codebase):
1448 if not ignored(child, codebase):
1449 child = attr.evolve(child)
1450 if topdown:
1451 yield child
1452
1453 for subchild in child.walk(
1454 codebase=codebase,
1455 topdown=topdown,
1456 ignored=ignored,
1457 ):
1458 if not ignored(subchild, codebase):
1459 yield subchild
1460
1461 if not topdown:
1462 yield child
1463
1464 def has_children(self):
1465 """

Callers 1

descendantsMethod · 0.95

Calls 3

childrenMethod · 0.95
evolveMethod · 0.80
walkMethod · 0.45

Tested by

no test coverage detected