dh-slim 1.4.7__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.
dh_slim-1.4.7/PKG-INFO ADDED
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: dh-slim
3
+ Version: 1.4.7
4
+ Summary: Typed filesystem, terminal, and parallel-processing utilities
5
+ Author: Isaac Onagh
6
+ Author-email: Isaac Onagh <hellboynaz@gmail.com>
7
+ Platform: any
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.11
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: rich>=13
13
+ Requires-Dist: loguru>=0.7
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=8; extra == "dev"
16
+ Requires-Dist: ty; extra == "dev"
17
+ Requires-Dist: joblib>=1.3; extra == "dev"
18
+ Requires-Dist: tqdm>=4.66; extra == "dev"
19
+ Provides-Extra: parallel
20
+ Requires-Dist: joblib>=1.3; extra == "parallel"
21
+ Requires-Dist: tqdm>=4.66; extra == "parallel"
22
+
23
+ # dh
24
+
25
+ Typed Python utilities for filesystem traversal, command execution, terminal text,
26
+ and parallel processing. Requires Python 3.11+.
27
+
28
+ ```sh
29
+ python -m pip install -e '.[dev,parallel]'
30
+ ```
31
+
32
+ ```python
33
+ from dh import get_files, get_dirs, runcmd
34
+
35
+ rst_files = get_files("docs", ext=[".rst"])
36
+ directories = list(get_dirs("src"))
37
+ code, stdout, stderr = runcmd(["git", "status", "--short"], show_output=False)
38
+ ```
39
+
40
+ `dh.fileutils` contains the shared filesystem implementation. Existing
41
+ `dh.pathutils` imports remain supported. `get_files(..., dirs_only=True)` unifies
42
+ directory traversal; suffix, Python-source, binary, and directory exclusion filters
43
+ work together. Traversal uses one shared pure-Python `os.scandir` engine, with
44
+ excluded directory trees pruned before descent. No native extension is required.
45
+
46
+ ## Text helpers
47
+
48
+ ```python
49
+ from dh import levenshtein, text_distance, count_words, to_camel, to_snake, word_frequencies
50
+
51
+ assert levenshtein("kitten", "sitting") == 3
52
+ assert to_snake("HTTPServer") == "http_server"
53
+ assert to_camel("hello_world") == "helloWorld"
54
+ assert count_words("Hello, world!") == 2
55
+ assert word_frequencies("Hi hi")["hi"] == 2
56
+ ```
57
+
58
+ See [text utilities](docs/src/textutils.md) for distance and tokenization contracts.
59
+
60
+ ## Tests and types
61
+
62
+ ```sh
63
+ pytest -q
64
+ ty check
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ Read [the book sources](docs/src/index.md) or open
70
+ [`docs/html/index.html`](docs/html/index.html) for built HTML.
71
+
72
+ ```sh
73
+ python tools/build_api_docs.py
74
+ mdbook build docs
75
+ ```
76
+
77
+ See [development instructions](docs/src/development.md) for mdBook installation
78
+ and [traversal contracts](docs/src/traversal.md) for filtering details.
@@ -0,0 +1,56 @@
1
+ # dh
2
+
3
+ Typed Python utilities for filesystem traversal, command execution, terminal text,
4
+ and parallel processing. Requires Python 3.11+.
5
+
6
+ ```sh
7
+ python -m pip install -e '.[dev,parallel]'
8
+ ```
9
+
10
+ ```python
11
+ from dh import get_files, get_dirs, runcmd
12
+
13
+ rst_files = get_files("docs", ext=[".rst"])
14
+ directories = list(get_dirs("src"))
15
+ code, stdout, stderr = runcmd(["git", "status", "--short"], show_output=False)
16
+ ```
17
+
18
+ `dh.fileutils` contains the shared filesystem implementation. Existing
19
+ `dh.pathutils` imports remain supported. `get_files(..., dirs_only=True)` unifies
20
+ directory traversal; suffix, Python-source, binary, and directory exclusion filters
21
+ work together. Traversal uses one shared pure-Python `os.scandir` engine, with
22
+ excluded directory trees pruned before descent. No native extension is required.
23
+
24
+ ## Text helpers
25
+
26
+ ```python
27
+ from dh import levenshtein, text_distance, count_words, to_camel, to_snake, word_frequencies
28
+
29
+ assert levenshtein("kitten", "sitting") == 3
30
+ assert to_snake("HTTPServer") == "http_server"
31
+ assert to_camel("hello_world") == "helloWorld"
32
+ assert count_words("Hello, world!") == 2
33
+ assert word_frequencies("Hi hi")["hi"] == 2
34
+ ```
35
+
36
+ See [text utilities](docs/src/textutils.md) for distance and tokenization contracts.
37
+
38
+ ## Tests and types
39
+
40
+ ```sh
41
+ pytest -q
42
+ ty check
43
+ ```
44
+
45
+ ## Documentation
46
+
47
+ Read [the book sources](docs/src/index.md) or open
48
+ [`docs/html/index.html`](docs/html/index.html) for built HTML.
49
+
50
+ ```sh
51
+ python tools/build_api_docs.py
52
+ mdbook build docs
53
+ ```
54
+
55
+ See [development instructions](docs/src/development.md) for mdBook installation
56
+ and [traversal contracts](docs/src/traversal.md) for filtering details.
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+ [project]
5
+ name = "dh-slim"
6
+ version = "1.4.7"
7
+ description = "Typed filesystem, terminal, and parallel-processing utilities"
8
+ requires-python = ">=3.11"
9
+ dependencies = ["rich>=13", "loguru>=0.7"]
10
+ readme = "README.md"
11
+ authors = [{ name = "Isaac Onagh", email = "hellboynaz@gmail.com" }]
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Operating System :: OS Independent",
15
+ ]
16
+ [tool.setuptools.packages.find]
17
+ where = ["src"]
18
+
19
+ [project.optional-dependencies]
20
+ dev = ["pytest>=8", "ty", "joblib>=1.3", "tqdm>=4.66"]
21
+ parallel = ["joblib>=1.3", "tqdm>=4.66"]
22
+
23
+ [tool.pytest.ini_options]
24
+ testpaths = ["tests"]
25
+
26
+ [tool.ty.environment]
27
+ python-version = "3.11"
@@ -0,0 +1,38 @@
1
+ [metadata]
2
+ name = dh-slim
3
+ version = 1.4.7
4
+ author = Isaac Onagh
5
+ author_email = hellboynaz@gmail.com
6
+ platforms = any
7
+ classifiers =
8
+ Development Status :: 4 - Beta
9
+ Programming Language :: Python
10
+
11
+ [options]
12
+ zip_safe = False
13
+ packages = find_namespace:
14
+ include_package_data = True
15
+ package_dir =
16
+ =src
17
+
18
+ [options.packages.find]
19
+ where = src
20
+ exclude =
21
+ tests
22
+
23
+ [options.entry_points]
24
+
25
+ [flake8]
26
+ max_line_length = 120
27
+ extend_ignore = E203, W503
28
+ exclude =
29
+ .tox
30
+ build
31
+ dist
32
+ .eggs
33
+ docs/conf.py
34
+
35
+ [egg_info]
36
+ tag_build =
37
+ tag_date = 0
38
+
dh_slim-1.4.7/setup.py ADDED
@@ -0,0 +1 @@
1
+ __import__("setuptools").setup()
@@ -0,0 +1,278 @@
1
+ from pathlib import Path
2
+ import sys
3
+
4
+ from .atomicio import atomic_write
5
+ from .const import (
6
+ ARCHIVE_EXT,
7
+ AUDIO_EXT,
8
+ BINARY_EXT,
9
+ BOOK_EXT,
10
+ BUILTIN_NAMES,
11
+ CHUNK_SIZE,
12
+ CODE_EXT,
13
+ CONTEXT_METHOD,
14
+ CSS_COLORS,
15
+ DOC_EXT,
16
+ EMULATED,
17
+ EXT2MIME,
18
+ FONT_EXT,
19
+ IMAGE_EXT,
20
+ MAX_WORKERS,
21
+ MIME2EXT,
22
+ PKG_MAPPING,
23
+ PY_KEYWORDS,
24
+ SDCARD,
25
+ SHEBANG_MAP,
26
+ SKIP_DIRS,
27
+ STDLIB,
28
+ TEXT_EXT,
29
+ TEXT_FILENAMES,
30
+ THRESHOLD,
31
+ VIDEO_EXT,
32
+ )
33
+ from .cprint import (
34
+ Ansi,
35
+ ColorSpec,
36
+ Cube,
37
+ ansi_to_rgb,
38
+ colored,
39
+ cprint,
40
+ cprint_compat,
41
+ cstr,
42
+ cube,
43
+ gray,
44
+ rainbow,
45
+ rgb_to_ansi256,
46
+ )
47
+ from .fileutils import (
48
+ FileWalkerConfig,
49
+ ReportGenerator,
50
+ ReportItem,
51
+ append_text,
52
+ copy_dir,
53
+ format_time,
54
+ fsz,
55
+ fullpath,
56
+ get_dirs,
57
+ get_file_age,
58
+ get_files,
59
+ get_files4,
60
+ get_files_iter,
61
+ get_files_iter_config,
62
+ get_files_pathlib,
63
+ get_files_scandir,
64
+ get_filez,
65
+ get_installed_packages,
66
+ get_installed_pkgs,
67
+ get_mime_type,
68
+ get_nobinary,
69
+ get_pyfiles,
70
+ get_pyfiles_iter,
71
+ get_random_filename,
72
+ get_removed_lines,
73
+ getfiles,
74
+ gext,
75
+ gsz,
76
+ gsz_by_ext,
77
+ is_empty,
78
+ is_git_repo,
79
+ is_image,
80
+ is_python_file,
81
+ is_text_file,
82
+ is_within,
83
+ main_func,
84
+ move_dir,
85
+ normalize_filename,
86
+ normalize_path,
87
+ read_lines,
88
+ remove_blank_lines,
89
+ restore_bak,
90
+ reverse_dict,
91
+ rrs,
92
+ runcmd,
93
+ safe_delete,
94
+ should_skip,
95
+ sorted_by_size,
96
+ unique_path,
97
+ walk_files,
98
+ walk_paths,
99
+ walker,
100
+ walkfiles,
101
+ worker,
102
+ write_txt_file,
103
+ )
104
+ from .isbinary import is_binary
105
+ from .jobutils import (
106
+ EXECUTOR_METHODS,
107
+ STAR_METHODS,
108
+ UNPICKLED_METHODS,
109
+ Method,
110
+ MethodUnavailableError,
111
+ MpfError,
112
+ Outcome,
113
+ TaskError,
114
+ failures,
115
+ mpf,
116
+ values,
117
+ )
118
+
119
+ # DEFAULT_CHUNKSIZE, DEFAULT_EXECUTOR_CHUNKSIZE, PoolMethod, mpf, mpf_iter
120
+ from .utils import WORD_PATTERN, get_sha256, has_doc, is_valid_url, slugify, tokenize_text
121
+
122
+
123
+ __all__: list[str] = [
124
+ "FileWalkerConfig",
125
+ "ReportGenerator",
126
+ "ReportItem",
127
+ "append_text",
128
+ "atomic_write",
129
+ "copy_dir",
130
+ "format_time",
131
+ "fsz",
132
+ "fullpath",
133
+ "get_dirs",
134
+ "get_file_age",
135
+ "get_files",
136
+ "get_files4",
137
+ "get_files_iter",
138
+ "get_files_iter_config",
139
+ "get_files_pathlib",
140
+ "get_files_scandir",
141
+ "get_filez",
142
+ "get_installed_packages",
143
+ "get_installed_pkgs",
144
+ "get_mime_type",
145
+ "get_nobinary",
146
+ "get_pyfiles",
147
+ "get_pyfiles_iter",
148
+ "get_random_filename",
149
+ "get_removed_lines",
150
+ "getfiles",
151
+ "gext",
152
+ "gsz",
153
+ "gsz_by_ext",
154
+ "is_binary",
155
+ "is_empty",
156
+ "is_git_repo",
157
+ "is_image",
158
+ "is_python_file",
159
+ "is_text_file",
160
+ "is_within",
161
+ "main_func",
162
+ "move_dir",
163
+ "normalize_filename",
164
+ "normalize_path",
165
+ "read_lines",
166
+ "remove_blank_lines",
167
+ "restore_bak",
168
+ "reverse_dict",
169
+ "rrs",
170
+ "runcmd",
171
+ "safe_delete",
172
+ "should_skip",
173
+ "sorted_by_size",
174
+ "unique_path",
175
+ "walk_files",
176
+ "walk_paths",
177
+ "walker",
178
+ "walkfiles",
179
+ "worker",
180
+ "write_txt_file",
181
+ ]
182
+ __all__ += [
183
+ "ARCHIVE_EXT",
184
+ "AUDIO_EXT",
185
+ "BINARY_EXT",
186
+ "BOOK_EXT",
187
+ "BUILTIN_NAMES",
188
+ "CHUNK_SIZE",
189
+ "CODE_EXT",
190
+ "CONTEXT_METHOD",
191
+ "CSS_COLORS",
192
+ "DOC_EXT",
193
+ "EMULATED",
194
+ "EXT2MIME",
195
+ "FONT_EXT",
196
+ "IMAGE_EXT",
197
+ "MAX_WORKERS",
198
+ "MIME2EXT",
199
+ "PKG_MAPPING",
200
+ "PY_KEYWORDS",
201
+ "SDCARD",
202
+ "SHEBANG_MAP",
203
+ "SKIP_DIRS",
204
+ "STDLIB",
205
+ "TEXT_EXT",
206
+ "TEXT_FILENAMES",
207
+ "THRESHOLD",
208
+ "VIDEO_EXT",
209
+ ]
210
+ __all__ += [
211
+ "Ansi",
212
+ "ColorSpec",
213
+ "Cube",
214
+ "ansi_to_rgb",
215
+ "colored",
216
+ "cprint",
217
+ "cprint_compat",
218
+ "cstr",
219
+ "cube",
220
+ "gray",
221
+ "rainbow",
222
+ "rgb_to_ansi256",
223
+ ]
224
+ __all__ += [
225
+ "EXECUTOR_METHODS",
226
+ "STAR_METHODS",
227
+ "UNPICKLED_METHODS",
228
+ "Method",
229
+ "MethodUnavailableError",
230
+ "MpfError",
231
+ "Outcome",
232
+ "TaskError",
233
+ "failures",
234
+ "mpf",
235
+ "values",
236
+ ]
237
+ # __all__ += [
238
+ # "PoolMethod",
239
+ # "mpf",
240
+ # "mpf_iter",
241
+ # "DEFAULT_CHUNKSIZE",
242
+ # "DEFAULT_EXECUTOR_CHUNKSIZEa",
243
+ # ]
244
+ # __all__ += [
245
+ # "ALL_COMPLETED",
246
+ # "FIRST_COMPLETED",
247
+ # "POLL_INTERVAL_SECONDS",
248
+ # "as_completed",
249
+ # "wait",
250
+ # ]
251
+ __all__ += [
252
+ "WORD_PATTERN",
253
+ "get_sha256",
254
+ "has_doc",
255
+ "is_valid_url",
256
+ "slugify",
257
+ "tokenize_text",
258
+ ]
259
+ from .textutils import (
260
+ count_words,
261
+ is_real_text,
262
+ levenshtein,
263
+ text_distance,
264
+ to_camel,
265
+ to_snake,
266
+ word_frequencies,
267
+ )
268
+
269
+
270
+ __all__ += [
271
+ "count_words",
272
+ "is_real_text",
273
+ "levenshtein",
274
+ "text_distance",
275
+ "to_camel",
276
+ "to_snake",
277
+ "word_frequencies",
278
+ ]