You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@
20
20
21
21
There are many libraries for traversing directories. You can also do this using the standard library. What makes this library different:
22
22
23
+
- 💎 Beautiful, laconic syntax.
23
24
- ⚗️ Filtering by file extensions, text patterns in [`.gitignore` format](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository#_ignoring), and using custom callables.
24
25
- 🐍 Natively works with both [`Path` objects](https://docs.python.org/3/library/pathlib.html#basic-use) from the standard library and strings.
25
26
- ❌ Support for [cancellation tokens](https://github.com/pomponchik/cantok).
@@ -30,7 +31,7 @@ There are many libraries for traversing directories. You can also do this using
30
31
31
32
-[**Installation**](#installation)
32
33
-[**Basic usage**](#basic-usage)
33
-
-[**Applying a Function to Each Path**](#applying-a-function-to-each-path)
34
+
-[**Applying a function to each path**](#applying-a-function-to-each-path)
34
35
-[**Filtering**](#filtering)
35
36
-[**Working with Cancellation Tokens**](#working-with-cancellation-tokens)
All of the crawler's settings — extensions, excludes, custom filters, and cancellation tokens — are respected, exactly as they would be during normal iteration. You can also pass a fresh cancellation token to `apply()` itself, the same way you would to `go()`.
86
+
> ↑ This will print the entire contents of the directory, except for the excluded locations.
87
+
88
+
> ⓘ All of the crawler's settings are respected, exactly as they would be during normal iteration.
88
89
89
90
90
91
## Filtering
@@ -137,14 +138,14 @@ You can set an arbitrary condition under which file traversal will stop using [c
137
138
138
139
1. If you use the crawler as a one-time object for a single iteration, set the token when creating it:
139
140
140
-
```python
141
+
```python
141
142
for path in Crawler('.', token=TimeoutToken(0.0001)): # Limit the iteration time to 0.0001 seconds.
142
143
print(path)
143
144
```
144
145
145
146
2. If you plan to use the crawler object several times, use the `go()` method for iteration and pass a new token to it every time:
146
147
147
-
```python
148
+
```python
148
149
crawler = Crawler('.')
149
150
150
151
for path in crawler.go(token=TimeoutToken(0.0001)): # Limit the iteration time to 0.0001 seconds.
0 commit comments