Skip to content

Commit a0b691f

Browse files
authored
Merge pull request #9 from mutating/develop
0.0.9
2 parents 0270eaa + 192f957 commit a0b691f

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
There are many libraries for traversing directories. You can also do this using the standard library. What makes this library different:
2222

23+
- 💎 Beautiful, laconic syntax.
2324
- ⚗️ 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.
2425
- 🐍 Natively works with both [`Path` objects](https://docs.python.org/3/library/pathlib.html#basic-use) from the standard library and strings.
2526
- ❌ 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
3031

3132
- [**Installation**](#installation)
3233
- [**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)
3435
- [**Filtering**](#filtering)
3536
- [**Working with Cancellation Tokens**](#working-with-cancellation-tokens)
3637
- [**Combination**](#combination)
@@ -74,17 +75,17 @@ crawler = Crawler('.', only_files=False)
7475
```
7576

7677

77-
## Applying a Function to Each Path
78+
## Applying a function to each path
7879

7980
If you just want to run a function for each file the crawler finds, you don't have to write the loop yourself — every crawler has an `apply()` method:
8081

8182
```python
82-
from dirstree import PythonCrawler
83-
84-
PythonCrawler('src', exclude=['tests/**']).apply(my_linter)
83+
Crawler('src', exclude=['tests/**']).apply(print)
8584
```
8685

87-
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.
8889
8990

9091
## Filtering
@@ -137,14 +138,14 @@ You can set an arbitrary condition under which file traversal will stop using [c
137138
138139
1. If you use the crawler as a one-time object for a single iteration, set the token when creating it:
139140

140-
```python
141+
```python
141142
for path in Crawler('.', token=TimeoutToken(0.0001)): # Limit the iteration time to 0.0001 seconds.
142143
print(path)
143144
```
144145

145146
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:
146147

147-
```python
148+
```python
148149
crawler = Crawler('.')
149150

150151
for path in crawler.go(token=TimeoutToken(0.0001)): # Limit the iteration time to 0.0001 seconds.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "dirstree"
7-
version = "0.0.8"
7+
version = "0.0.9"
88
authors = [{ name = "Evgeniy Blinov", email = "zheni-b@yandex.ru" }]
99
description = 'Another library for iterating through the contents of a directory'
1010
readme = "README.md"

0 commit comments

Comments
 (0)