@@ -146,24 +146,25 @@ def bind(cls, fs):
146146 Returns:
147147 ~fs.walk.BoundWalker: a bound walker.
148148
149- Example:
150- >>> from fs import open_fs
151- >>> from fs.walk import Walker
152- >>> home_fs = open_fs('~/')
153- >>> walker = Walker.bind(home_fs)
154- >>> for path in walker.files(filter=['*.py']):
155- ... print(path)
156-
157- Unless you have written a customized walker class, you will be
158- unlikely to need to call this explicitly, as filesystem objects
159- already have a ``walk`` attribute which is a bound walker
160- object.
149+ Examples:
161150
162- Example:
163- >>> from fs import open_fs
164- >>> home_fs = open_fs('~/')
165- >>> for path in home_fs.walk.files(filter=['*.py']):
166- ... print(path)
151+ Use this method to explicitly bind a filesystem instance::
152+
153+ >>> walker = Walker.bind(my_fs)
154+ >>> for path in walker.files(filter=['*.py']):
155+ ... print(path)
156+ /foo.py
157+ /bar.py
158+
159+ Unless you have written a customized walker class, you will
160+ be unlikely to need to call this explicitly, as filesystem
161+ objects already have a ``walk`` attribute which is a bound
162+ walker object::
163+
164+ >>> for path in my_fs.walk.files(filter=['*.py']):
165+ ... print(path)
166+ /foo.py
167+ /bar.py
167168
168169 """
169170 return BoundWalker (fs )
@@ -316,14 +317,16 @@ def walk(
316317 `~fs.info.Info` objects for directories and files in ``<path>``.
317318
318319 Example:
319- >>> home_fs = open_fs('~/')
320320 >>> walker = Walker(filter=['*.py'])
321- >>> namespaces = ['details']
322- >>> for path, dirs, files in walker.walk(home_fs, namespaces)
321+ >>> for path, dirs, files in walker.walk(my_fs, namespaces=["details"]):
323322 ... print("[{}]".format(path))
324323 ... print("{} directories".format(len(dirs)))
325324 ... total = sum(info.size for info in files)
326- ... print("{} bytes {}".format(total))
325+ ... print("{} bytes".format(total))
326+ [/]
327+ 2 directories
328+ 55 bytes
329+ ...
327330
328331 """
329332 _path = abspath (normpath (path ))
@@ -495,10 +498,9 @@ class BoundWalker(typing.Generic[_F]):
495498 `BoundWalker` object.
496499
497500 Example:
498- >>> import fs
499- >>> home_fs = fs.open_fs('~/')
500- >>> home_fs.walk
501- BoundWalker(OSFS('/Users/will', encoding='utf-8'))
501+ >>> tmp_fs = fs.tempfs.TempFS()
502+ >>> tmp_fs.walk
503+ BoundWalker(TempFS())
502504
503505 A `BoundWalker` is callable. Calling it is an alias for the
504506 `~fs.walk.BoundWalker.walk` method.
@@ -575,13 +577,16 @@ def walk(
575577 `~fs.info.Info` objects for directories and files in ``<path>``.
576578
577579 Example:
578- >>> home_fs = open_fs('~/')
579580 >>> walker = Walker(filter=['*.py'])
580- >>> for path, dirs, files in walker.walk(home_fs , namespaces=['details']):
581+ >>> for path, dirs, files in walker.walk(my_fs , namespaces=['details']):
581582 ... print("[{}]".format(path))
582583 ... print("{} directories".format(len(dirs)))
583584 ... total = sum(info.size for info in files)
584- ... print("{} bytes {}".format(total))
585+ ... print("{} bytes".format(total))
586+ [/]
587+ 2 directories
588+ 55 bytes
589+ ...
585590
586591 This method invokes `Walker.walk` with bound `FS` object.
587592
0 commit comments