pyletree 2.2.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyletree-2.2.0/src/pyletree.egg-info → pyletree-2.4.0}/PKG-INFO +291 -12
- pyletree-2.4.0/README.md +569 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/pyproject.toml +1 -1
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree/__main__.py +2 -2
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree/cli.py +3 -9
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree/pyletree.py +49 -51
- {pyletree-2.2.0 → pyletree-2.4.0/src/pyletree.egg-info}/PKG-INFO +291 -12
- pyletree-2.2.0/README.md +0 -290
- {pyletree-2.2.0 → pyletree-2.4.0}/LICENSE +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/setup.cfg +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree/__init__.py +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree.egg-info/SOURCES.txt +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree.egg-info/dependency_links.txt +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree.egg-info/entry_points.txt +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree.egg-info/requires.txt +0 -0
- {pyletree-2.2.0 → pyletree-2.4.0}/src/pyletree.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyletree
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Generate directory tree diagrams from the command line
|
|
5
5
|
Author: Davi Reis Furtado, Leodanis Pozo Ramos
|
|
6
6
|
License: MIT License
|
|
@@ -37,7 +37,7 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
38
|
<img src="https://img.shields.io/badge/python-3.8%2B-blue">
|
|
39
39
|
<img src="https://img.shields.io/badge/license-MIT-green">
|
|
40
|
-
<img src="https://img.shields.io/badge/version-2.
|
|
40
|
+
<img src="https://img.shields.io/badge/version-2.4.0-orange">
|
|
41
41
|
|
|
42
42
|
<br>
|
|
43
43
|
|
|
@@ -56,11 +56,16 @@ Dynamic: license-file
|
|
|
56
56
|
- [General](#general)
|
|
57
57
|
- [Modes](#modes)
|
|
58
58
|
- [Ordering](#ordering)
|
|
59
|
+
- [Size](#size)
|
|
59
60
|
- [Display](#display)
|
|
60
61
|
- [Ignoring](#ignoring)
|
|
61
62
|
- [Depth](#depth)
|
|
63
|
+
- [Output Formats](#output-formats)
|
|
62
64
|
- [Examples](#examples)
|
|
63
65
|
- [Python API](#python-api)
|
|
66
|
+
- [Basic Usage](#basic-usage)
|
|
67
|
+
- [Parameters](#parameters)
|
|
68
|
+
- [Methods](#methods)
|
|
64
69
|
- [Sample Output](#sample-output)
|
|
65
70
|
- [Features](#features)
|
|
66
71
|
- [Release History](#release-history)
|
|
@@ -117,23 +122,39 @@ pyletree -h
|
|
|
117
122
|
|
|
118
123
|
- `-d`, `--dirs-first` List directories before files
|
|
119
124
|
- `-f`, `--files-first` List files before directories
|
|
125
|
+
- `-r`, `--reverse` Reverse alphabetical sort order
|
|
120
126
|
|
|
121
127
|
> Alphabetical order is always applied as base sorting.
|
|
122
128
|
|
|
129
|
+
### Size
|
|
130
|
+
|
|
131
|
+
- `-fs`, `--file-size` Display individual file sizes
|
|
132
|
+
- `-ds`, `--dir-size` Display cumulative sizes for directories
|
|
133
|
+
- `-b`, `--big-first` Order entries by size (largest first)
|
|
134
|
+
- `-s`, `--small-first` Order entries by size (smallest first)
|
|
135
|
+
|
|
136
|
+
> Size sorting (`-b`/`-s`) is mutually exclusive with ordering (`-d`/`-f`).
|
|
137
|
+
|
|
123
138
|
### Display
|
|
124
139
|
|
|
125
140
|
- `-n`, `--no-pipes` Remove vertical pipes between branches
|
|
141
|
+
- `-p`, `--path-tree` Generate a view focused exclusively on full paths
|
|
142
|
+
- `-o [N]` Text-only mode: tree in plain text with `N` spaces indentation (default: 2). Cannot be used with `-n`
|
|
126
143
|
|
|
127
144
|
### Ignoring
|
|
128
145
|
|
|
129
146
|
- `-g [DIR ...]`, `--git [DIR ...]` Ignore `.git` folder and respect rules from given `.git` directories or directories containing `.git` (defaults to current dir if omitted but flag is used)
|
|
130
147
|
- `-gi [DIR_OR_FILE ...]`, `--gitignore [DIR_OR_FILE ...]` Respect `.gitignore` rules from given paths/dirs (defaults to current dir if omitted)
|
|
131
|
-
- `-i`, `--ignore PATTERN [PATTERN ...]` Ignore files/directories
|
|
132
|
-
- `-fi`, `--filter PATTERN [PATTERN ...]` Include only files or directories matching gitignore-style patterns
|
|
148
|
+
- `-i PATTERN [PATTERN ...]`, `--ignore PATTERN [PATTERN ...]` Ignore files/directories matching gitignore-style patterns
|
|
149
|
+
- `-fi PATTERN [PATTERN ...]`, `--filter PATTERN [PATTERN ...]` Include only files or directories matching gitignore-style patterns
|
|
133
150
|
|
|
134
151
|
### Depth
|
|
135
152
|
|
|
136
|
-
- `-dl`, `--depth-level N` Limit depth
|
|
153
|
+
- `-dl N`, `--depth-level N` Limit tree depth (must be >= 0)
|
|
154
|
+
|
|
155
|
+
### Output Formats
|
|
156
|
+
|
|
157
|
+
- `-dt [N]`, `--dict-tree [N]` Output the tree structure as a JSON dictionary. `N` defines indentation spaces (default: 2). Use `0` for compact output
|
|
137
158
|
|
|
138
159
|
## Examples
|
|
139
160
|
|
|
@@ -164,7 +185,7 @@ pyletree . -dl 2
|
|
|
164
185
|
Dictionary output:
|
|
165
186
|
|
|
166
187
|
```bash
|
|
167
|
-
pyletree . -dt
|
|
188
|
+
pyletree . -dt 4
|
|
168
189
|
```
|
|
169
190
|
|
|
170
191
|
Ignore entries:
|
|
@@ -191,9 +212,65 @@ No pipes mode:
|
|
|
191
212
|
pyletree . -n
|
|
192
213
|
```
|
|
193
214
|
|
|
215
|
+
Show file sizes:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pyletree . -fs
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Show directory sizes:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
pyletree . -ds
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Sort by size (biggest first):
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
pyletree . -b -fs
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Sort by size (smallest first):
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
pyletree . -s -fs
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Reverse alphabetical order:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
pyletree . -r
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Path tree mode:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
pyletree . -p
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Text-only mode (4-space indent):
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pyletree . -o 4
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Git mode (ignore `.git` and apply `.gitignore` rules):
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
pyletree . -g
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Combine options:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
pyletree src/ -d -fs -dl 3 -i __pycache__
|
|
267
|
+
```
|
|
268
|
+
|
|
194
269
|
## Python API
|
|
195
270
|
|
|
196
|
-
You can also use Pyletree programmatically in your own Python code using the `FileTree` class. It returns an iterable that can also be printed directly
|
|
271
|
+
You can also use Pyletree programmatically in your own Python code using the `FileTree` class. It returns an iterable that can also be printed directly.
|
|
272
|
+
|
|
273
|
+
### Basic Usage
|
|
197
274
|
|
|
198
275
|
```python
|
|
199
276
|
from pyletree import FileTree
|
|
@@ -217,6 +294,102 @@ custom_tree = FileTree(
|
|
|
217
294
|
print(custom_tree)
|
|
218
295
|
```
|
|
219
296
|
|
|
297
|
+
### Parameters
|
|
298
|
+
|
|
299
|
+
All parameters (except `root_dir`) are keyword-only:
|
|
300
|
+
|
|
301
|
+
| Parameter | Type | Default | Description |
|
|
302
|
+
|---|---|---|---|
|
|
303
|
+
| `root_dir` | `str \| Path` | `'.'` | Root directory path |
|
|
304
|
+
| `dir_only` | `bool` | `False` | Show directories only |
|
|
305
|
+
| `files_only` | `bool` | `False` | Show files only |
|
|
306
|
+
| `dirs_first` | `bool` | `False` | List directories before files |
|
|
307
|
+
| `files_first` | `bool` | `False` | List files before directories |
|
|
308
|
+
| `no_pipes` | `bool` | `False` | Remove vertical pipes between branches |
|
|
309
|
+
| `ignore` | `list[str] \| None` | `None` | Gitignore-style patterns to ignore |
|
|
310
|
+
| `filter` | `list[str] \| None` | `None` | Gitignore-style patterns to include only |
|
|
311
|
+
| `use_gitignore` | `bool \| str \| Path \| list` | `False` | Respect `.gitignore` rules. `True` uses current dir, or pass path(s) |
|
|
312
|
+
| `depth_level` | `int \| None` | `None` | Limit tree depth |
|
|
313
|
+
| `path_tree` | `bool` | `False` | Display full paths instead of names |
|
|
314
|
+
| `text_only` | `bool` | `False` | Plain text mode (no special characters) |
|
|
315
|
+
| `text_only_indent` | `int` | `2` | Indentation spaces for text-only mode |
|
|
316
|
+
| `file_size` | `bool` | `False` | Show individual file sizes |
|
|
317
|
+
| `dir_size` | `bool` | `False` | Show cumulative directory sizes |
|
|
318
|
+
| `sort_size` | `str \| None` | `None` | Sort by size: `'big'` or `'small'` |
|
|
319
|
+
| `reverse` | `bool` | `False` | Reverse alphabetical sort order |
|
|
320
|
+
|
|
321
|
+
### Methods
|
|
322
|
+
|
|
323
|
+
#### `getTree() -> str`
|
|
324
|
+
|
|
325
|
+
Returns the tree as a formatted string:
|
|
326
|
+
|
|
327
|
+
```python
|
|
328
|
+
tree = FileTree('src/')
|
|
329
|
+
output = tree.getTree()
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### `getDictTree() -> dict`
|
|
333
|
+
|
|
334
|
+
Returns the tree as a nested dictionary. Files map to `None` (or their size string if `file_size=True`):
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
tree = FileTree('src/')
|
|
338
|
+
data = tree.getDictTree()
|
|
339
|
+
# {'src/': {'main.py': None, 'utils.py': None}}
|
|
340
|
+
|
|
341
|
+
# With file sizes
|
|
342
|
+
tree = FileTree('src/', file_size=True)
|
|
343
|
+
data = tree.getDictTree()
|
|
344
|
+
# {'src/': {'main.py': '1.2 KB', 'utils.py': '856 B'}}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
#### `getPath(pattern) -> list[Path]`
|
|
348
|
+
|
|
349
|
+
Search for files or directories matching a pattern. Returns a list of resolved `Path` objects:
|
|
350
|
+
|
|
351
|
+
```python
|
|
352
|
+
tree = FileTree()
|
|
353
|
+
|
|
354
|
+
# Exact name match
|
|
355
|
+
tree.getPath('main.py')
|
|
356
|
+
|
|
357
|
+
# Glob pattern
|
|
358
|
+
tree.getPath('*.py')
|
|
359
|
+
|
|
360
|
+
# Path pattern
|
|
361
|
+
tree.getPath('src/*.py')
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### `dict(tree)`
|
|
365
|
+
|
|
366
|
+
`FileTree` supports `dict()` conversion through `keys()` and `__getitem__()`:
|
|
367
|
+
|
|
368
|
+
```python
|
|
369
|
+
tree = FileTree('src/')
|
|
370
|
+
data = dict(tree)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
#### Iterating
|
|
374
|
+
|
|
375
|
+
`FileTree` is iterable — each iteration yields one line of the tree:
|
|
376
|
+
|
|
377
|
+
```python
|
|
378
|
+
tree = FileTree()
|
|
379
|
+
for line in tree:
|
|
380
|
+
print(line)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### String conversion
|
|
384
|
+
|
|
385
|
+
`str(tree)` or `print(tree)` returns the full tree as a string:
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
tree = FileTree()
|
|
389
|
+
print(tree) # prints the tree
|
|
390
|
+
text = str(tree) # stores as string
|
|
391
|
+
```
|
|
392
|
+
|
|
220
393
|
## Sample Output
|
|
221
394
|
|
|
222
395
|
### Default
|
|
@@ -246,24 +419,130 @@ project/
|
|
|
246
419
|
└── README.md
|
|
247
420
|
```
|
|
248
421
|
|
|
422
|
+
### Text-only mode (`-o`)
|
|
423
|
+
|
|
424
|
+
```text
|
|
425
|
+
project/
|
|
426
|
+
src/
|
|
427
|
+
main.py
|
|
428
|
+
utils.py
|
|
429
|
+
tests/
|
|
430
|
+
test_main.py
|
|
431
|
+
README.md
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Path tree (`-p`)
|
|
435
|
+
|
|
436
|
+
```text
|
|
437
|
+
C:/Users/user/project/
|
|
438
|
+
│
|
|
439
|
+
├── C:/Users/user/project/src/
|
|
440
|
+
│ ├── C:/Users/user/project/src/main.py
|
|
441
|
+
│ └── C:/Users/user/project/src/utils.py
|
|
442
|
+
│
|
|
443
|
+
├── C:/Users/user/project/tests/
|
|
444
|
+
│ └── C:/Users/user/project/tests/test_main.py
|
|
445
|
+
│
|
|
446
|
+
└── C:/Users/user/project/README.md
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### File sizes (`-fs`)
|
|
450
|
+
|
|
451
|
+
```text
|
|
452
|
+
project/
|
|
453
|
+
│
|
|
454
|
+
├── src/
|
|
455
|
+
│ ├── main.py (1.2 KB)
|
|
456
|
+
│ └── utils.py (856 B)
|
|
457
|
+
│
|
|
458
|
+
├── tests/
|
|
459
|
+
│ └── test_main.py (420 B)
|
|
460
|
+
│
|
|
461
|
+
└── README.md (3.1 KB)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Directory sizes (`-ds`)
|
|
465
|
+
|
|
466
|
+
```text
|
|
467
|
+
project/ (5.6 KB)
|
|
468
|
+
│
|
|
469
|
+
├── src/ (2.1 KB)
|
|
470
|
+
│ ├── main.py
|
|
471
|
+
│ └── utils.py
|
|
472
|
+
│
|
|
473
|
+
├── tests/ (420 B)
|
|
474
|
+
│ └── test_main.py
|
|
475
|
+
│
|
|
476
|
+
└── README.md
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Dictionary output (`-dt`)
|
|
480
|
+
|
|
481
|
+
```json
|
|
482
|
+
{
|
|
483
|
+
"project/": {
|
|
484
|
+
"src/": {
|
|
485
|
+
"main.py": null,
|
|
486
|
+
"utils.py": null
|
|
487
|
+
},
|
|
488
|
+
"tests/": {
|
|
489
|
+
"test_main.py": null
|
|
490
|
+
},
|
|
491
|
+
"README.md": null
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
249
496
|
## Features
|
|
250
497
|
|
|
251
498
|
- Clean and readable tree output
|
|
252
499
|
- `.gitignore` support (it does not ignore either the `.git` directory or the `.gitignore` file; if you want to ignore them, add them to the ignore patterns)
|
|
253
500
|
- Custom ignore patterns
|
|
501
|
+
- Include-only filter patterns with smart directory inclusion
|
|
254
502
|
- Depth limiting
|
|
255
|
-
- Flexible sorting
|
|
503
|
+
- Flexible sorting (alphabetical, directories/files first, by size)
|
|
504
|
+
- Reverse sort order
|
|
505
|
+
- File and directory size display
|
|
506
|
+
- Path-focused tree view
|
|
507
|
+
- Text-only mode with configurable indentation
|
|
508
|
+
- Dictionary (JSON) output format
|
|
256
509
|
- Optional compact mode (`--no-pipes`)
|
|
510
|
+
- Full Python API with `FileTree` class
|
|
257
511
|
|
|
258
512
|
## Release History
|
|
259
513
|
|
|
514
|
+
### 2.4.0
|
|
515
|
+
|
|
516
|
+
#### API Changes
|
|
517
|
+
|
|
518
|
+
- `FileTree` instance attributes are now **public**. All user-configured parameters (`root_dir`, `dir_only`, `files_only`, `dirs_first`, `files_first`, `no_pipes`, `ignore`, `depth_level`, `path_tree`, `text_only`, `text_only_indent`, `file_size`, `dir_size`, `sort_size`, `reverse`) can be accessed directly without the `_` prefix.
|
|
519
|
+
- Example: `tree.root_dir`, `tree.depth_level`, `tree.dir_only`
|
|
520
|
+
- Internal attributes (`_tree_deque`, `_size_cache`, `_gitignore_list`, `_filter_cache`, `_ignore_spec`, `_filter_spec`) remain private.
|
|
521
|
+
|
|
522
|
+
#### Documentation
|
|
523
|
+
|
|
524
|
+
- Complete README with all CLI options, full API reference, and expanded examples.
|
|
525
|
+
|
|
526
|
+
### 2.3.1
|
|
527
|
+
|
|
528
|
+
- Improve README.md
|
|
529
|
+
- Improve code
|
|
530
|
+
|
|
531
|
+
### 2.3.0
|
|
532
|
+
|
|
533
|
+
#### Enhancements
|
|
534
|
+
|
|
535
|
+
- Integrated `-di`/`--dict-indent` into `-dt`/`--dict-tree`.
|
|
536
|
+
- Example: `pyletree . -dt 4` (4-space indentation)
|
|
537
|
+
- Example: `pyletree . -dt 0` (compact, no indentation)
|
|
538
|
+
|
|
260
539
|
### 2.2.0
|
|
261
540
|
|
|
262
541
|
#### Enhancements
|
|
263
542
|
|
|
264
|
-
- `-dt`/`--dict-tree` | Enhanced Dictionary Output: improved dictionary format with configurable indentation. Now returns `{root: {tree...}}` format and supports custom indentation via `-
|
|
265
|
-
- Example: `pyletree . -dt
|
|
266
|
-
- Example: `pyletree . -dt
|
|
543
|
+
- `-dt`/`--dict-tree` | Enhanced Dictionary Output: improved dictionary format with configurable indentation. Now returns `{root: {tree...}}` format and supports custom indentation via `-dt N`/`--dict-tree N` (default 2).
|
|
544
|
+
- Example: `pyletree . -dt 4` (4-space indentation)
|
|
545
|
+
- Example: `pyletree . -dt 0` (compact, no indentation)
|
|
267
546
|
- Better structured output for programmatic use
|
|
268
547
|
|
|
269
548
|
### 2.1.0
|
|
@@ -292,7 +571,7 @@ project/
|
|
|
292
571
|
|
|
293
572
|
#### Filtering & Data Structures
|
|
294
573
|
|
|
295
|
-
- `-dt`/`--dict-tree` | Dictionary format: output the tree structure as a native Python dictionary. Use `-
|
|
574
|
+
- `-dt`/`--dict-tree` | Dictionary format: output the tree structure as a native Python dictionary. Use `-dt N`/`--dict-tree N` for indentation (default 2). Format: {root: {tree...}}
|
|
296
575
|
- Global File Filter: support for excluding/including files based on patterns or extensions.
|
|
297
576
|
- Add patterns to `-i` / `--ignore` option.
|
|
298
577
|
|