MCPcopy Create free account
hub / github.com/twisted/twisted / walk

Method walk

src/twisted/python/filepath.py:468–500  ·  view source on GitHub ↗

Yield myself, then each of my children, and each of those children's children in turn. The optional argument C{descend} is a predicate that takes a FilePath, and determines whether or not that FilePath is traversed/descended into. It will be called with eac

(
        self: _Self,
        descend: Callable[[_Self], bool] | None = None,
    )

Source from the content-addressed store, hash-verified

466 return result
467
468 def walk(
469 self: _Self,
470 descend: Callable[[_Self], bool] | None = None,
471 ) -> Iterable[_Self]:
472 """
473 Yield myself, then each of my children, and each of those children's
474 children in turn.
475
476 The optional argument C{descend} is a predicate that takes a FilePath,
477 and determines whether or not that FilePath is traversed/descended
478 into. It will be called with each path for which C{isdir} returns
479 C{True}. If C{descend} is not specified, all directories will be
480 traversed (including symbolic links which refer to directories).
481
482 @param descend: A one-argument callable that will return True for
483 FilePaths that should be traversed, False otherwise.
484
485 @return: a generator yielding FilePath-like objects.
486 """
487 yield self
488 if self.isdir():
489 for c in self.children():
490 # we should first see if it's what we want, then we
491 # can walk through the directory
492 if descend is None or descend(c):
493 for subc in c.walk(descend):
494 if os.path.realpath(self.path).startswith(
495 os.path.realpath(subc.path)
496 ):
497 raise LinkError("Cycle in file graph.")
498 yield subc
499 else:
500 yield c
501
502 def sibling(self: _Self, path: OtherAnyStr) -> AbstractFilePath[OtherAnyStr]:
503 """

Callers 11

findTwistedProjectsFunction · 0.80
zipitFunction · 0.80
test_walkMethod · 0.80
iterateOverPathMethod · 0.80
test_walkObeysDescendMethod · 0.80
test_copyToDirectoryMethod · 0.80
test_moveToMethod · 0.80
fromDirectoryMethod · 0.80
watchMethod · 0.80
fix-for-src-mv.pyFile · 0.80
mvFunction · 0.80

Calls 4

isdirMethod · 0.95
childrenMethod · 0.95
LinkErrorClass · 0.85
realpathMethod · 0.80

Tested by 6

zipitFunction · 0.64
test_walkMethod · 0.64
iterateOverPathMethod · 0.64
test_walkObeysDescendMethod · 0.64
test_copyToDirectoryMethod · 0.64
test_moveToMethod · 0.64