pyletree 1.0.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-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Real Python
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyletree
3
+ Version: 1.0.0
4
+ Summary: Generate directory tree diagrams from the command line
5
+ Author: Davi Reis Furtado, Leodanis Pozo Ramos
6
+ License: MIT License
7
+
8
+ Copyright (c) 2021 Real Python
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/davi-furtado/pyletree
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pathspec
33
+ Dynamic: license-file
34
+
35
+ <div align="center">
36
+ <h1 align="center">Pyletree</h1>
37
+
38
+ <img src="https://img.shields.io/badge/python-3.8%2B-blue">
39
+ <img src="https://img.shields.io/badge/license-MIT-green">
40
+ <img src="https://img.shields.io/badge/version-1.0.0-orange">
41
+ </div>
42
+
43
+ <p align="right"><i>Pyletree is a simple and fast CLI tool to generate directory tree diagrams.</i></p>
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install pyletree
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ```bash
54
+ pyletree [ROOT_DIR]
55
+ ```
56
+
57
+ If no directory is provided, the current directory is used:
58
+
59
+ ```bash
60
+ pyletree
61
+ ```
62
+
63
+ Show help:
64
+
65
+ ```bash
66
+ pyletree -h
67
+ ```
68
+
69
+ ## Options
70
+
71
+ ### General
72
+
73
+ - `-h`, `--help` Show help message
74
+ - `-v`, `--version` Show version
75
+
76
+ ### Modes
77
+
78
+ - `-d`, `--dir-only` Show directories only
79
+ - `-f`, `--files-only` Show files only
80
+
81
+ ### Ordering
82
+
83
+ - `-df`, `--dirs-first` List directories before files
84
+ - `-ff`, `--files-first` List files before directories
85
+
86
+ > Alphabetical order is always applied as base sorting.
87
+
88
+ ### Display
89
+
90
+ - `-n`, `--no-pipes` Remove vertical pipes between branches
91
+
92
+ ### Ignoring
93
+
94
+ - `-i`, `--ignore PATTERN [PATTERN ...]` Ignore files/directories
95
+ - `-gi`, `--gitignore` Respect `.gitignore` rules
96
+
97
+ ### Depth
98
+
99
+ - `-dl`, `--depth-level N` Limit depth
100
+
101
+ ### Output
102
+
103
+ - `-o`, `--output-file FILE` Save output to file (Markdown format)
104
+
105
+ ## Examples
106
+
107
+ Basic:
108
+
109
+ ```bash
110
+ pyletree
111
+ ```
112
+
113
+ Directories first:
114
+
115
+ ```bash
116
+ pyletree . -df
117
+ ```
118
+
119
+ Files only:
120
+
121
+ ```bash
122
+ pyletree . -f
123
+ ```
124
+
125
+ Limit depth:
126
+
127
+ ```bash
128
+ pyletree . -dl 2
129
+ ```
130
+
131
+ Ignore entries:
132
+
133
+ ```bash
134
+ pyletree . -i node_modules dist .git
135
+ ```
136
+
137
+ Use `.gitignore`:
138
+
139
+ ```bash
140
+ pyletree . -gi
141
+ ```
142
+
143
+ No pipes mode:
144
+
145
+ ```bash
146
+ pyletree . -n
147
+ ```
148
+
149
+ Save to file:
150
+
151
+ ```bash
152
+ pyletree . -o tree.md
153
+ ```
154
+
155
+ ## Sample Output
156
+
157
+ ### Default
158
+
159
+ ```text
160
+ project/
161
+
162
+ ├── src/
163
+ │ ├── main.py
164
+ │ └── utils.py
165
+
166
+ ├── tests/
167
+ │ └── test_main.py
168
+
169
+ └── README.md
170
+ ```
171
+
172
+ ### No pipes (`-n`)
173
+
174
+ ```text
175
+ project/
176
+ ├── src/
177
+ │ ├── main.py
178
+ │ └── utils.py
179
+ ├── tests/
180
+ │ └── test_main.py
181
+ └── README.md
182
+ ```
183
+
184
+ ## Features
185
+
186
+ - Clean and readable tree output
187
+ - `.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)
188
+ - Custom ignore patterns
189
+ - Depth limiting
190
+ - Flexible sorting
191
+ - Optional compact mode (`--no-pipes`)
192
+
193
+ ## Release History
194
+
195
+ ### 1.0.0
196
+
197
+ - Initial release
198
+
199
+ ## Authors
200
+
201
+ Davi Reis Furtado
202
+
203
+ **Original RP Tree Author:**
204
+ Leodanis Pozo Ramos
205
+
206
+ ## License
207
+
208
+ _Pyletree_ is distributed under the MIT license. See [LICENSE](LICENSE) for more information.
@@ -0,0 +1,174 @@
1
+ <div align="center">
2
+ <h1 align="center">Pyletree</h1>
3
+
4
+ <img src="https://img.shields.io/badge/python-3.8%2B-blue">
5
+ <img src="https://img.shields.io/badge/license-MIT-green">
6
+ <img src="https://img.shields.io/badge/version-1.0.0-orange">
7
+ </div>
8
+
9
+ <p align="right"><i>Pyletree is a simple and fast CLI tool to generate directory tree diagrams.</i></p>
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install pyletree
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ pyletree [ROOT_DIR]
21
+ ```
22
+
23
+ If no directory is provided, the current directory is used:
24
+
25
+ ```bash
26
+ pyletree
27
+ ```
28
+
29
+ Show help:
30
+
31
+ ```bash
32
+ pyletree -h
33
+ ```
34
+
35
+ ## Options
36
+
37
+ ### General
38
+
39
+ - `-h`, `--help` Show help message
40
+ - `-v`, `--version` Show version
41
+
42
+ ### Modes
43
+
44
+ - `-d`, `--dir-only` Show directories only
45
+ - `-f`, `--files-only` Show files only
46
+
47
+ ### Ordering
48
+
49
+ - `-df`, `--dirs-first` List directories before files
50
+ - `-ff`, `--files-first` List files before directories
51
+
52
+ > Alphabetical order is always applied as base sorting.
53
+
54
+ ### Display
55
+
56
+ - `-n`, `--no-pipes` Remove vertical pipes between branches
57
+
58
+ ### Ignoring
59
+
60
+ - `-i`, `--ignore PATTERN [PATTERN ...]` Ignore files/directories
61
+ - `-gi`, `--gitignore` Respect `.gitignore` rules
62
+
63
+ ### Depth
64
+
65
+ - `-dl`, `--depth-level N` Limit depth
66
+
67
+ ### Output
68
+
69
+ - `-o`, `--output-file FILE` Save output to file (Markdown format)
70
+
71
+ ## Examples
72
+
73
+ Basic:
74
+
75
+ ```bash
76
+ pyletree
77
+ ```
78
+
79
+ Directories first:
80
+
81
+ ```bash
82
+ pyletree . -df
83
+ ```
84
+
85
+ Files only:
86
+
87
+ ```bash
88
+ pyletree . -f
89
+ ```
90
+
91
+ Limit depth:
92
+
93
+ ```bash
94
+ pyletree . -dl 2
95
+ ```
96
+
97
+ Ignore entries:
98
+
99
+ ```bash
100
+ pyletree . -i node_modules dist .git
101
+ ```
102
+
103
+ Use `.gitignore`:
104
+
105
+ ```bash
106
+ pyletree . -gi
107
+ ```
108
+
109
+ No pipes mode:
110
+
111
+ ```bash
112
+ pyletree . -n
113
+ ```
114
+
115
+ Save to file:
116
+
117
+ ```bash
118
+ pyletree . -o tree.md
119
+ ```
120
+
121
+ ## Sample Output
122
+
123
+ ### Default
124
+
125
+ ```text
126
+ project/
127
+
128
+ ├── src/
129
+ │ ├── main.py
130
+ │ └── utils.py
131
+
132
+ ├── tests/
133
+ │ └── test_main.py
134
+
135
+ └── README.md
136
+ ```
137
+
138
+ ### No pipes (`-n`)
139
+
140
+ ```text
141
+ project/
142
+ ├── src/
143
+ │ ├── main.py
144
+ │ └── utils.py
145
+ ├── tests/
146
+ │ └── test_main.py
147
+ └── README.md
148
+ ```
149
+
150
+ ## Features
151
+
152
+ - Clean and readable tree output
153
+ - `.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)
154
+ - Custom ignore patterns
155
+ - Depth limiting
156
+ - Flexible sorting
157
+ - Optional compact mode (`--no-pipes`)
158
+
159
+ ## Release History
160
+
161
+ ### 1.0.0
162
+
163
+ - Initial release
164
+
165
+ ## Authors
166
+
167
+ Davi Reis Furtado
168
+
169
+ **Original RP Tree Author:**
170
+ Leodanis Pozo Ramos
171
+
172
+ ## License
173
+
174
+ _Pyletree_ is distributed under the MIT license. See [LICENSE](LICENSE) for more information.
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ['setuptools>=61.0']
3
+ build-backend = 'setuptools.build_meta'
4
+
5
+ [project]
6
+ name = 'pyletree'
7
+ version = '1.0.0'
8
+ description = 'Generate directory tree diagrams from the command line'
9
+ readme = 'README.md'
10
+ license = { file = 'LICENSE' }
11
+ authors = [
12
+ { name = 'Davi Reis Furtado' },
13
+ { name = 'Leodanis Pozo Ramos' }
14
+ ]
15
+ requires-python = '>=3.8'
16
+ dependencies = [
17
+ 'pathspec'
18
+ ]
19
+
20
+ [project.scripts]
21
+ pyletree = 'pyletree.__main__:main'
22
+
23
+ [project.urls]
24
+ Homepage = 'https://github.com/davi-furtado/pyletree'
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ '''Top-level package for Pyletree (based on RP Tree).'''
2
+
3
+ __all__ = ['__version__']
4
+
5
+ __version__ = '1.0.0'
@@ -0,0 +1,48 @@
1
+ '''Entry point for Pyletree CLI.'''
2
+
3
+ import pathlib
4
+ import sys
5
+
6
+ from .cli import parse_cmd_line_arguments
7
+ from .pyletree import DirectoryTree
8
+
9
+
10
+ def main() -> None:
11
+ args = parse_cmd_line_arguments()
12
+ root_dir = pathlib.Path(args.root_dir).resolve()
13
+
14
+ if not root_dir.exists():
15
+ print(f'Error: directory not found: {root_dir}', file=sys.stderr)
16
+ sys.exit(1)
17
+
18
+ if not root_dir.is_dir():
19
+ print(f'Error: path is not a directory: {root_dir}', file=sys.stderr)
20
+ sys.exit(1)
21
+
22
+ try:
23
+ tree = DirectoryTree(
24
+ root_dir=root_dir,
25
+ dir_only=args.dir_only,
26
+ files_only=args.files_only,
27
+ dirs_first=args.dirs_first,
28
+ files_first=args.files_first,
29
+ no_pipes=args.no_pipes,
30
+ ignore=args.ignore,
31
+ use_gitignore=args.gitignore,
32
+ depth_level=args.depth_level,
33
+ output_file=args.output_file,
34
+ )
35
+
36
+ tree.generate()
37
+
38
+ except KeyboardInterrupt:
39
+ print('\nOperation cancelled.', file=sys.stderr)
40
+ sys.exit(130)
41
+
42
+ except Exception as e:
43
+ print(f'Error: {e}', file=sys.stderr)
44
+ sys.exit(1)
45
+
46
+
47
+ if __name__ == '__main__':
48
+ main()
@@ -0,0 +1,108 @@
1
+ '''This module provides the Pyletree CLI.'''
2
+
3
+ import argparse
4
+
5
+ from . import __version__
6
+
7
+
8
+ def parse_cmd_line_arguments() -> argparse.Namespace:
9
+ parser = argparse.ArgumentParser(
10
+ prog='pyletree',
11
+ description='Generate a directory tree',
12
+ epilog='Thanks for using Pyletree!',
13
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
14
+ )
15
+
16
+ parser.add_argument(
17
+ '-v',
18
+ '--version',
19
+ action='version',
20
+ version=f'Pyletree v{__version__}',
21
+ )
22
+
23
+ parser.add_argument(
24
+ 'root_dir',
25
+ metavar='ROOT_DIR',
26
+ nargs='?',
27
+ default='.',
28
+ help='root directory to generate the tree from',
29
+ )
30
+
31
+ mode = parser.add_mutually_exclusive_group()
32
+ mode.add_argument(
33
+ '-d',
34
+ '--dir-only',
35
+ action='store_true',
36
+ help='show directories only',
37
+ )
38
+ mode.add_argument(
39
+ '-f',
40
+ '--files-only',
41
+ action='store_true',
42
+ help='show files only',
43
+ )
44
+
45
+ ordering = parser.add_mutually_exclusive_group()
46
+ ordering.add_argument(
47
+ '-df',
48
+ '--dirs-first',
49
+ action='store_true',
50
+ help='list directories before files',
51
+ )
52
+ ordering.add_argument(
53
+ '-ff',
54
+ '--files-first',
55
+ action='store_true',
56
+ help='list files before directories',
57
+ )
58
+
59
+ parser.add_argument(
60
+ '-n',
61
+ '--no-pipes',
62
+ action='store_true',
63
+ help='remove vertical pipes between branches',
64
+ )
65
+
66
+ parser.add_argument(
67
+ '-i',
68
+ '--ignore',
69
+ metavar='PATTERN',
70
+ nargs='*',
71
+ default=None,
72
+ help='ignore files or directories (e.g. *.py __pycache__)',
73
+ )
74
+
75
+ parser.add_argument(
76
+ '-gi',
77
+ '--gitignore',
78
+ action='store_true',
79
+ help='respect .gitignore rules',
80
+ )
81
+
82
+ parser.add_argument(
83
+ '-dl',
84
+ '--depth-level',
85
+ metavar='N',
86
+ type=int,
87
+ help='limit tree depth (>= 0)',
88
+ )
89
+
90
+ parser.add_argument(
91
+ '-o',
92
+ '--output-file',
93
+ metavar='FILE',
94
+ help='write output to file (markdown format)',
95
+ )
96
+
97
+ args = parser.parse_args()
98
+
99
+ # validações
100
+ if (args.dir_only or args.files_only) and (
101
+ args.dirs_first or args.files_first
102
+ ):
103
+ parser.error('ordering options cannot be used with --dir-only or --files-only')
104
+
105
+ if args.depth_level is not None and args.depth_level < 0:
106
+ parser.error('--depth-level must be >= 0')
107
+
108
+ return args
@@ -0,0 +1,180 @@
1
+ '''This module provides Pyletree main module.'''
2
+
3
+ from __future__ import annotations
4
+
5
+ import pathlib
6
+ import sys
7
+ from collections import deque
8
+ from fnmatch import fnmatch
9
+ from typing import Deque, List, Optional, Set
10
+
11
+ PIPE = '│'
12
+ ELBOW = '└──'
13
+ TEE = '├──'
14
+ PIPE_PREFIX = '│ '
15
+ SPACE_PREFIX = ' '
16
+
17
+
18
+ class DirectoryTree:
19
+ def __init__(
20
+ self,
21
+ root_dir: pathlib.Path,
22
+ *,
23
+ dir_only: bool = False,
24
+ files_only: bool = False,
25
+ dirs_first: bool = False,
26
+ files_first: bool = False,
27
+ no_pipes: bool = False,
28
+ ignore: Optional[List[str]] = None,
29
+ use_gitignore: bool = False,
30
+ depth_level: Optional[int] = None,
31
+ output_file: Optional[str] = None,
32
+ ) -> None:
33
+ self._output_file = output_file
34
+ self._generator = _TreeGenerator(
35
+ root_dir=root_dir,
36
+ dir_only=dir_only,
37
+ files_only=files_only,
38
+ dirs_first=dirs_first,
39
+ files_first=files_first,
40
+ no_pipes=no_pipes,
41
+ ignore=ignore,
42
+ use_gitignore=use_gitignore,
43
+ depth_level=depth_level,
44
+ )
45
+
46
+ def generate(self) -> None:
47
+ tree = self._generator.build_tree()
48
+
49
+ if self._output_file:
50
+ tree.appendleft('```')
51
+ tree.append('```')
52
+ with open(self._output_file, 'w', encoding='utf-8') as f:
53
+ for line in tree:
54
+ print(line, file=f)
55
+ else:
56
+ for line in tree:
57
+ print(line)
58
+
59
+
60
+ class _TreeGenerator:
61
+ def __init__(
62
+ self,
63
+ *,
64
+ root_dir: pathlib.Path,
65
+ dir_only: bool,
66
+ files_only: bool,
67
+ dirs_first: bool,
68
+ files_first: bool,
69
+ no_pipes: bool,
70
+ ignore: Optional[List[str]],
71
+ use_gitignore: bool,
72
+ depth_level: Optional[int],
73
+ ) -> None:
74
+ self._root_dir = root_dir.resolve()
75
+ self._dir_only = dir_only
76
+ self._files_only = files_only
77
+ self._dirs_first = dirs_first
78
+ self._files_first = files_first
79
+ self._no_pipes = no_pipes
80
+ self._ignore: Set[str] = set(ignore or [])
81
+ self._depth_level = depth_level
82
+ self._tree: Deque[str] = deque()
83
+
84
+ self._gitignore = None
85
+ if use_gitignore:
86
+ try:
87
+ import pathspec
88
+
89
+ gitignore = self._root_dir / '.gitignore'
90
+ if gitignore.exists():
91
+ patterns = gitignore.read_text().splitlines()
92
+ self._gitignore = pathspec.PathSpec.from_lines(
93
+ 'gitwildmatch', patterns
94
+ )
95
+ except ImportError:
96
+ print('Warning: pathspec not installed', file=sys.stderr)
97
+
98
+ def build_tree(self) -> Deque[str]:
99
+ root_name = self._root_dir.name or str(self._root_dir)
100
+ self._tree.append(f'{root_name}/')
101
+
102
+ if not self._no_pipes:
103
+ entries = self._prepare_entries(self._root_dir)
104
+ if entries:
105
+ self._tree.append(PIPE)
106
+
107
+ self._tree_body(self._root_dir, prefix='', depth=0)
108
+ return self._tree
109
+
110
+ def _tree_body(
111
+ self,
112
+ directory: pathlib.Path,
113
+ prefix: str,
114
+ depth: int,
115
+ ) -> None:
116
+ if self._depth_level is not None and depth >= self._depth_level:
117
+ return
118
+
119
+ entries = self._prepare_entries(directory)
120
+ if not entries:
121
+ return
122
+
123
+ last_index = len(entries) - 1
124
+
125
+ for index, entry in enumerate(entries):
126
+ is_last = index == last_index
127
+ connector = ELBOW if is_last else TEE
128
+
129
+ self._tree.append(
130
+ f'{prefix}{connector} {entry.name}{'/' if entry.is_dir() else ''}'
131
+ )
132
+
133
+ if entry.is_dir():
134
+ new_prefix = prefix + (SPACE_PREFIX if is_last else PIPE_PREFIX)
135
+ self._tree_body(entry, new_prefix, depth + 1)
136
+
137
+ if not self._no_pipes and not is_last:
138
+ self._tree.append(prefix + PIPE)
139
+
140
+ def _prepare_entries(self, directory: pathlib.Path) -> List[pathlib.Path]:
141
+ try:
142
+ entries = sorted(directory.iterdir(), key=lambda e: e.name.lower())
143
+ except PermissionError:
144
+ return []
145
+
146
+ entries = [e for e in entries if not self._is_ignored(e)]
147
+
148
+ if self._dir_only:
149
+ return [e for e in entries if e.is_dir()]
150
+
151
+ if self._files_only:
152
+ return [e for e in entries if e.is_file()]
153
+
154
+ if self._dirs_first:
155
+ entries.sort(key=lambda e: (e.is_file(), e.name.lower()))
156
+ elif self._files_first:
157
+ entries.sort(key=lambda e: (e.is_dir(), e.name.lower()))
158
+
159
+ return entries
160
+
161
+ def _is_ignored(self, entry: pathlib.Path) -> bool:
162
+ for pattern in self._ignore:
163
+ if fnmatch(entry.name, pattern):
164
+ return True
165
+
166
+ if self._gitignore:
167
+ try:
168
+ rel = entry.relative_to(self._root_dir)
169
+ rel_str = str(rel)
170
+
171
+ if self._gitignore.match_file(rel_str):
172
+ return True
173
+
174
+ if entry.is_dir() and self._gitignore.match_file(rel_str + '/'):
175
+ return True
176
+
177
+ except ValueError:
178
+ pass
179
+
180
+ return False
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyletree
3
+ Version: 1.0.0
4
+ Summary: Generate directory tree diagrams from the command line
5
+ Author: Davi Reis Furtado, Leodanis Pozo Ramos
6
+ License: MIT License
7
+
8
+ Copyright (c) 2021 Real Python
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/davi-furtado/pyletree
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pathspec
33
+ Dynamic: license-file
34
+
35
+ <div align="center">
36
+ <h1 align="center">Pyletree</h1>
37
+
38
+ <img src="https://img.shields.io/badge/python-3.8%2B-blue">
39
+ <img src="https://img.shields.io/badge/license-MIT-green">
40
+ <img src="https://img.shields.io/badge/version-1.0.0-orange">
41
+ </div>
42
+
43
+ <p align="right"><i>Pyletree is a simple and fast CLI tool to generate directory tree diagrams.</i></p>
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install pyletree
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ```bash
54
+ pyletree [ROOT_DIR]
55
+ ```
56
+
57
+ If no directory is provided, the current directory is used:
58
+
59
+ ```bash
60
+ pyletree
61
+ ```
62
+
63
+ Show help:
64
+
65
+ ```bash
66
+ pyletree -h
67
+ ```
68
+
69
+ ## Options
70
+
71
+ ### General
72
+
73
+ - `-h`, `--help` Show help message
74
+ - `-v`, `--version` Show version
75
+
76
+ ### Modes
77
+
78
+ - `-d`, `--dir-only` Show directories only
79
+ - `-f`, `--files-only` Show files only
80
+
81
+ ### Ordering
82
+
83
+ - `-df`, `--dirs-first` List directories before files
84
+ - `-ff`, `--files-first` List files before directories
85
+
86
+ > Alphabetical order is always applied as base sorting.
87
+
88
+ ### Display
89
+
90
+ - `-n`, `--no-pipes` Remove vertical pipes between branches
91
+
92
+ ### Ignoring
93
+
94
+ - `-i`, `--ignore PATTERN [PATTERN ...]` Ignore files/directories
95
+ - `-gi`, `--gitignore` Respect `.gitignore` rules
96
+
97
+ ### Depth
98
+
99
+ - `-dl`, `--depth-level N` Limit depth
100
+
101
+ ### Output
102
+
103
+ - `-o`, `--output-file FILE` Save output to file (Markdown format)
104
+
105
+ ## Examples
106
+
107
+ Basic:
108
+
109
+ ```bash
110
+ pyletree
111
+ ```
112
+
113
+ Directories first:
114
+
115
+ ```bash
116
+ pyletree . -df
117
+ ```
118
+
119
+ Files only:
120
+
121
+ ```bash
122
+ pyletree . -f
123
+ ```
124
+
125
+ Limit depth:
126
+
127
+ ```bash
128
+ pyletree . -dl 2
129
+ ```
130
+
131
+ Ignore entries:
132
+
133
+ ```bash
134
+ pyletree . -i node_modules dist .git
135
+ ```
136
+
137
+ Use `.gitignore`:
138
+
139
+ ```bash
140
+ pyletree . -gi
141
+ ```
142
+
143
+ No pipes mode:
144
+
145
+ ```bash
146
+ pyletree . -n
147
+ ```
148
+
149
+ Save to file:
150
+
151
+ ```bash
152
+ pyletree . -o tree.md
153
+ ```
154
+
155
+ ## Sample Output
156
+
157
+ ### Default
158
+
159
+ ```text
160
+ project/
161
+
162
+ ├── src/
163
+ │ ├── main.py
164
+ │ └── utils.py
165
+
166
+ ├── tests/
167
+ │ └── test_main.py
168
+
169
+ └── README.md
170
+ ```
171
+
172
+ ### No pipes (`-n`)
173
+
174
+ ```text
175
+ project/
176
+ ├── src/
177
+ │ ├── main.py
178
+ │ └── utils.py
179
+ ├── tests/
180
+ │ └── test_main.py
181
+ └── README.md
182
+ ```
183
+
184
+ ## Features
185
+
186
+ - Clean and readable tree output
187
+ - `.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)
188
+ - Custom ignore patterns
189
+ - Depth limiting
190
+ - Flexible sorting
191
+ - Optional compact mode (`--no-pipes`)
192
+
193
+ ## Release History
194
+
195
+ ### 1.0.0
196
+
197
+ - Initial release
198
+
199
+ ## Authors
200
+
201
+ Davi Reis Furtado
202
+
203
+ **Original RP Tree Author:**
204
+ Leodanis Pozo Ramos
205
+
206
+ ## License
207
+
208
+ _Pyletree_ is distributed under the MIT license. See [LICENSE](LICENSE) for more information.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/pyletree/__init__.py
5
+ src/pyletree/__main__.py
6
+ src/pyletree/cli.py
7
+ src/pyletree/pyletree.py
8
+ src/pyletree.egg-info/PKG-INFO
9
+ src/pyletree.egg-info/SOURCES.txt
10
+ src/pyletree.egg-info/dependency_links.txt
11
+ src/pyletree.egg-info/entry_points.txt
12
+ src/pyletree.egg-info/requires.txt
13
+ src/pyletree.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyletree = pyletree.__main__:main
@@ -0,0 +1 @@
1
+ pathspec
@@ -0,0 +1 @@
1
+ pyletree