emmykit 0.3.2__py3-none-any.whl
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.
- emmykit/__init__.py +517 -0
- emmykit/_version.py +13 -0
- emmykit/constants.py +65 -0
- emmykit/datetime_utils.py +800 -0
- emmykit/diff_view.py +362 -0
- emmykit/docker_utils.py +118 -0
- emmykit/embedded_scripts.py +560 -0
- emmykit/extensions.py +323 -0
- emmykit/file_io.py +56 -0
- emmykit/files.py +329 -0
- emmykit/hosts.py +153 -0
- emmykit/html_files.py +140 -0
- emmykit/humanize.py +146 -0
- emmykit/inflect_utils.py +179 -0
- emmykit/introspection.py +467 -0
- emmykit/io_subprocess.py +231 -0
- emmykit/json_io.py +335 -0
- emmykit/lint.py +827 -0
- emmykit/llm.py +2158 -0
- emmykit/logging_utils.py +255 -0
- emmykit/media.py +513 -0
- emmykit/net_targets.py +46 -0
- emmykit/network.py +581 -0
- emmykit/numeric_helpers.py +62 -0
- emmykit/options.py +67 -0
- emmykit/paths_ensure.py +25 -0
- emmykit/prompts.py +49 -0
- emmykit/py.typed +0 -0
- emmykit/python_env.py +139 -0
- emmykit/safe_paths.py +316 -0
- emmykit/system.py +225 -0
- emmykit/text.py +205 -0
- emmykit/text_constants.py +21 -0
- emmykit/treeview.py +217 -0
- emmykit-0.3.2.dist-info/METADATA +4461 -0
- emmykit-0.3.2.dist-info/RECORD +38 -0
- emmykit-0.3.2.dist-info/WHEEL +4 -0
- emmykit-0.3.2.dist-info/licenses/LICENSE +201 -0
emmykit/__init__.py
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
"""emmykit — personal Python utilities, layered package extracted from univ_defs.py."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
# === Stdlib re-exports (preserved from univ_defs.py's public surface) ===
|
|
6
|
+
import errno
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import sys
|
|
11
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
12
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
13
|
+
from dataclasses import dataclass, field, replace
|
|
14
|
+
from enum import Enum
|
|
15
|
+
from itertools import chain
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import (
|
|
18
|
+
Any,
|
|
19
|
+
Final,
|
|
20
|
+
Literal,
|
|
21
|
+
Protocol,
|
|
22
|
+
TextIO,
|
|
23
|
+
Type,
|
|
24
|
+
TypeAlias,
|
|
25
|
+
overload,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# === Layer 0 ===
|
|
29
|
+
from emmykit.constants import (
|
|
30
|
+
ANSI_CYAN,
|
|
31
|
+
ANSI_GREEN,
|
|
32
|
+
ANSI_RED,
|
|
33
|
+
ANSI_RESET,
|
|
34
|
+
ANSI_YELLOW,
|
|
35
|
+
BACKTICK,
|
|
36
|
+
DEFAULT_ENCODING,
|
|
37
|
+
DEFAULT_EXCLUDE_DIRS,
|
|
38
|
+
EM_DASH,
|
|
39
|
+
HORIZONTAL_ELLIPSIS,
|
|
40
|
+
IGNORE_THESE_ERRORS,
|
|
41
|
+
IGNORED_CODES,
|
|
42
|
+
LDQUOTE,
|
|
43
|
+
LSQUOTE,
|
|
44
|
+
RDQUOTE,
|
|
45
|
+
RSQUOTE,
|
|
46
|
+
)
|
|
47
|
+
from emmykit.embedded_scripts import (
|
|
48
|
+
MULTIREPLACE_SCRIPT,
|
|
49
|
+
MYAUDIT_SCRIPT,
|
|
50
|
+
MYDIFF_SCRIPT,
|
|
51
|
+
PRINTALL_SCRIPT,
|
|
52
|
+
SETUP_CARTOPY_SCRIPT,
|
|
53
|
+
TREEVIEW_SCRIPT,
|
|
54
|
+
UNIV_DEFS_SYS_PATH_SCRIPT,
|
|
55
|
+
)
|
|
56
|
+
from emmykit.extensions import (
|
|
57
|
+
ALL_KNOWN_EXTENSIONS,
|
|
58
|
+
ALL_KNOWN_EXTENSIONS_SET,
|
|
59
|
+
ARCHIVE_EXTENSIONS,
|
|
60
|
+
ARCHIVE_EXTENSIONS_SET,
|
|
61
|
+
AUDIO_EXTENSIONS,
|
|
62
|
+
AUDIO_EXTENSIONS_SET,
|
|
63
|
+
BOOK_EXTENSIONS,
|
|
64
|
+
BOOK_EXTENSIONS_SET,
|
|
65
|
+
HTML_EXTENSIONS,
|
|
66
|
+
HTML_EXTENSIONS_SET,
|
|
67
|
+
IMAGE_EXTENSIONS,
|
|
68
|
+
IMAGE_EXTENSIONS_SET,
|
|
69
|
+
PLAYLIST_EXTENSIONS,
|
|
70
|
+
PLAYLIST_EXTENSIONS_SET,
|
|
71
|
+
PYTHON_EXTENSIONS,
|
|
72
|
+
PYTHON_EXTENSIONS_SET,
|
|
73
|
+
SUBTITLE_EXTENSIONS,
|
|
74
|
+
SUBTITLE_EXTENSIONS_SET,
|
|
75
|
+
TEXT_ENCODINGS,
|
|
76
|
+
TEXT_ENCODINGS_SET,
|
|
77
|
+
TEXT_EXTENSIONS,
|
|
78
|
+
TEXT_EXTENSIONS_SET,
|
|
79
|
+
VIDEO_EXTENSIONS,
|
|
80
|
+
VIDEO_EXTENSIONS_SET,
|
|
81
|
+
)
|
|
82
|
+
from emmykit.net_targets import (
|
|
83
|
+
DNS_TEST_NAMES,
|
|
84
|
+
HTTP_PROBES,
|
|
85
|
+
IPV4_TARGETS,
|
|
86
|
+
IPV6_TARGETS,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# === Layer 1 ===
|
|
90
|
+
from emmykit._version import PY_VERSION, __version__
|
|
91
|
+
from emmykit.options import Options, PlotOptions
|
|
92
|
+
from emmykit.text_constants import (
|
|
93
|
+
CHARACTERS_TO_SPACE,
|
|
94
|
+
QUOTES_TO_DELETE,
|
|
95
|
+
REPLACE_WITH_SPACE,
|
|
96
|
+
TRANSLATION_TABLE,
|
|
97
|
+
)
|
|
98
|
+
from emmykit.numeric_helpers import is_float, seconds_in_unit
|
|
99
|
+
from emmykit.paths_ensure import ensure_path
|
|
100
|
+
from emmykit.inflect_utils import InflectEngine, my_plural
|
|
101
|
+
from emmykit.logging_utils import (
|
|
102
|
+
FlushingStreamHandler,
|
|
103
|
+
MaxLevelFilter,
|
|
104
|
+
MemoryHandler,
|
|
105
|
+
configure_logging,
|
|
106
|
+
fallback_logging_config,
|
|
107
|
+
print_all_errors,
|
|
108
|
+
return_method_name,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# === Layer 2 ===
|
|
112
|
+
from emmykit.safe_paths import (
|
|
113
|
+
ensure_dir,
|
|
114
|
+
ensure_file,
|
|
115
|
+
safe_ctime,
|
|
116
|
+
safe_exists,
|
|
117
|
+
safe_is_dir,
|
|
118
|
+
safe_is_file,
|
|
119
|
+
safe_mtime,
|
|
120
|
+
safe_size,
|
|
121
|
+
safe_stat,
|
|
122
|
+
)
|
|
123
|
+
from emmykit.file_io import my_atomic_write
|
|
124
|
+
|
|
125
|
+
# === Layer 3 ===
|
|
126
|
+
from emmykit.io_subprocess import (
|
|
127
|
+
MyPopenResult,
|
|
128
|
+
my_critical_error,
|
|
129
|
+
my_fopen,
|
|
130
|
+
my_popen,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# === Layer 4 ===
|
|
134
|
+
from emmykit.prompts import prompt_then_choose, prompt_then_confirm
|
|
135
|
+
from emmykit.introspection import (
|
|
136
|
+
compile_code,
|
|
137
|
+
if_filepath_then_read,
|
|
138
|
+
load_ast_var,
|
|
139
|
+
normalize_to_dict,
|
|
140
|
+
show_function_source,
|
|
141
|
+
)
|
|
142
|
+
from emmykit.humanize import human_bytesize, round_out, sci_exp
|
|
143
|
+
from emmykit.datetime_utils import (
|
|
144
|
+
ADAPTIVE_FORMAT_LEVELS,
|
|
145
|
+
AdaptiveDateFormatter,
|
|
146
|
+
AnyDateTimeType,
|
|
147
|
+
Precision,
|
|
148
|
+
adaptive_date_labels,
|
|
149
|
+
decimal_year_to_datetime,
|
|
150
|
+
extract_timestamp,
|
|
151
|
+
format_date_range,
|
|
152
|
+
human_timespan,
|
|
153
|
+
parse_datetime,
|
|
154
|
+
parse_timezone,
|
|
155
|
+
)
|
|
156
|
+
from emmykit.json_io import (
|
|
157
|
+
from_jsonable,
|
|
158
|
+
load_options_from_json,
|
|
159
|
+
save_options_to_json,
|
|
160
|
+
to_jsonable,
|
|
161
|
+
)
|
|
162
|
+
from emmykit.diff_view import (
|
|
163
|
+
diff_and_confirm,
|
|
164
|
+
highlight_changes,
|
|
165
|
+
is_python_script,
|
|
166
|
+
my_diff,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
# === Layer 5 ===
|
|
170
|
+
from emmykit.text import (
|
|
171
|
+
contains_mojibake,
|
|
172
|
+
decode_cp1252,
|
|
173
|
+
decode_utf8,
|
|
174
|
+
ensure_utf8_meta,
|
|
175
|
+
fix_mojibake,
|
|
176
|
+
fix_text,
|
|
177
|
+
my_capitalize,
|
|
178
|
+
my_title_case,
|
|
179
|
+
normalize_for_search,
|
|
180
|
+
)
|
|
181
|
+
from emmykit.hosts import (
|
|
182
|
+
COMPUTER_NAME,
|
|
183
|
+
IS_NASA_COMPUTER,
|
|
184
|
+
NASA_CASEFOLDED_COMPUTER_NAME_PREFIXES,
|
|
185
|
+
NASA_COMPUTER_NAME_PREFIXES,
|
|
186
|
+
analyze_computer_name_results,
|
|
187
|
+
get_computer_name,
|
|
188
|
+
get_hostname_os_uname,
|
|
189
|
+
get_hostname_platform,
|
|
190
|
+
get_hostname_socket,
|
|
191
|
+
get_hostname_subprocess_hostname,
|
|
192
|
+
get_hostname_subprocess_scutil,
|
|
193
|
+
)
|
|
194
|
+
from emmykit.network import CheckResult, is_internet_available
|
|
195
|
+
from emmykit.python_env import (
|
|
196
|
+
check_python_version,
|
|
197
|
+
detect_shell,
|
|
198
|
+
find_additional_alias_files,
|
|
199
|
+
find_preferred_python_version,
|
|
200
|
+
find_shell_rc_file,
|
|
201
|
+
)
|
|
202
|
+
from emmykit.files import (
|
|
203
|
+
calculate_checksum,
|
|
204
|
+
download_file,
|
|
205
|
+
filename_format,
|
|
206
|
+
query_free_space,
|
|
207
|
+
verify_script,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# === Layer 6 ===
|
|
211
|
+
from emmykit.lint import (
|
|
212
|
+
FormatChecker,
|
|
213
|
+
ask_and_autopep8,
|
|
214
|
+
ask_and_replace,
|
|
215
|
+
check_python_formatting,
|
|
216
|
+
get_autopep8_fixable_codes,
|
|
217
|
+
interactive_flake8,
|
|
218
|
+
multireplace,
|
|
219
|
+
run_flake8,
|
|
220
|
+
run_mypy,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# === Layer 7 ===
|
|
224
|
+
from emmykit.treeview import treeview_new_files
|
|
225
|
+
from emmykit.docker_utils import (
|
|
226
|
+
ensure_daemon_running,
|
|
227
|
+
ensure_docker_installed,
|
|
228
|
+
ensure_image_built,
|
|
229
|
+
run_with_docker_fixes,
|
|
230
|
+
)
|
|
231
|
+
from emmykit.system import (
|
|
232
|
+
check_if_command_exists,
|
|
233
|
+
detect_country,
|
|
234
|
+
get_effective_free_memory,
|
|
235
|
+
is_process_running,
|
|
236
|
+
kill_process,
|
|
237
|
+
open_filemanager_with_dirs,
|
|
238
|
+
open_terminal_and_run_command,
|
|
239
|
+
start_only_one_instance,
|
|
240
|
+
)
|
|
241
|
+
from emmykit.media import (
|
|
242
|
+
ensure_even_dimensions,
|
|
243
|
+
extract_and_concatenate_segments,
|
|
244
|
+
find_ffmpeg,
|
|
245
|
+
get_video_duration_seconds,
|
|
246
|
+
open_dir_in_VLC,
|
|
247
|
+
open_in_vlc,
|
|
248
|
+
open_playlist_in_VLC,
|
|
249
|
+
set_system_volume,
|
|
250
|
+
)
|
|
251
|
+
from emmykit.html_files import (
|
|
252
|
+
combine_html_files,
|
|
253
|
+
remove_prefix_from_filename,
|
|
254
|
+
remove_prefix_from_html_title,
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# === Layer 8 ===
|
|
258
|
+
from emmykit.llm import (
|
|
259
|
+
LLMConfig,
|
|
260
|
+
LLMs,
|
|
261
|
+
ModelInfo,
|
|
262
|
+
SelectionContext,
|
|
263
|
+
SelectionStrategy,
|
|
264
|
+
StrategyFn,
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
__all__ = [
|
|
268
|
+
"ADAPTIVE_FORMAT_LEVELS",
|
|
269
|
+
"ALL_KNOWN_EXTENSIONS",
|
|
270
|
+
"ALL_KNOWN_EXTENSIONS_SET",
|
|
271
|
+
"ANSI_CYAN",
|
|
272
|
+
"ANSI_GREEN",
|
|
273
|
+
"ANSI_RED",
|
|
274
|
+
"ANSI_RESET",
|
|
275
|
+
"ANSI_YELLOW",
|
|
276
|
+
"ARCHIVE_EXTENSIONS",
|
|
277
|
+
"ARCHIVE_EXTENSIONS_SET",
|
|
278
|
+
"AUDIO_EXTENSIONS",
|
|
279
|
+
"AUDIO_EXTENSIONS_SET",
|
|
280
|
+
"AdaptiveDateFormatter",
|
|
281
|
+
"Any",
|
|
282
|
+
"AnyDateTimeType",
|
|
283
|
+
"BACKTICK",
|
|
284
|
+
"BOOK_EXTENSIONS",
|
|
285
|
+
"BOOK_EXTENSIONS_SET",
|
|
286
|
+
"CHARACTERS_TO_SPACE",
|
|
287
|
+
"COMPUTER_NAME",
|
|
288
|
+
"Callable",
|
|
289
|
+
"CheckResult",
|
|
290
|
+
"DEFAULT_ENCODING",
|
|
291
|
+
"DEFAULT_EXCLUDE_DIRS",
|
|
292
|
+
"DNS_TEST_NAMES",
|
|
293
|
+
"EM_DASH",
|
|
294
|
+
"Enum",
|
|
295
|
+
"Final",
|
|
296
|
+
"FlushingStreamHandler",
|
|
297
|
+
"FormatChecker",
|
|
298
|
+
"HORIZONTAL_ELLIPSIS",
|
|
299
|
+
"HTML_EXTENSIONS",
|
|
300
|
+
"HTML_EXTENSIONS_SET",
|
|
301
|
+
"HTTP_PROBES",
|
|
302
|
+
"IGNORED_CODES",
|
|
303
|
+
"IGNORE_THESE_ERRORS",
|
|
304
|
+
"IMAGE_EXTENSIONS",
|
|
305
|
+
"IMAGE_EXTENSIONS_SET",
|
|
306
|
+
"IPV4_TARGETS",
|
|
307
|
+
"IPV6_TARGETS",
|
|
308
|
+
"IS_NASA_COMPUTER",
|
|
309
|
+
"InflectEngine",
|
|
310
|
+
"Iterable",
|
|
311
|
+
"LDQUOTE",
|
|
312
|
+
"LLMConfig",
|
|
313
|
+
"LLMs",
|
|
314
|
+
"LSQUOTE",
|
|
315
|
+
"Literal",
|
|
316
|
+
"MULTIREPLACE_SCRIPT",
|
|
317
|
+
"MYAUDIT_SCRIPT",
|
|
318
|
+
"MYDIFF_SCRIPT",
|
|
319
|
+
"MaxLevelFilter",
|
|
320
|
+
"MemoryHandler",
|
|
321
|
+
"ModelInfo",
|
|
322
|
+
"MyPopenResult",
|
|
323
|
+
"NASA_CASEFOLDED_COMPUTER_NAME_PREFIXES",
|
|
324
|
+
"NASA_COMPUTER_NAME_PREFIXES",
|
|
325
|
+
"Options",
|
|
326
|
+
"PLAYLIST_EXTENSIONS",
|
|
327
|
+
"PLAYLIST_EXTENSIONS_SET",
|
|
328
|
+
"PRINTALL_SCRIPT",
|
|
329
|
+
"PYTHON_EXTENSIONS",
|
|
330
|
+
"PYTHON_EXTENSIONS_SET",
|
|
331
|
+
"PY_VERSION",
|
|
332
|
+
"Path",
|
|
333
|
+
"PlotOptions",
|
|
334
|
+
"Precision",
|
|
335
|
+
"Protocol",
|
|
336
|
+
"QUOTES_TO_DELETE",
|
|
337
|
+
"RDQUOTE",
|
|
338
|
+
"REPLACE_WITH_SPACE",
|
|
339
|
+
"RSQUOTE",
|
|
340
|
+
"SETUP_CARTOPY_SCRIPT",
|
|
341
|
+
"SUBTITLE_EXTENSIONS",
|
|
342
|
+
"SUBTITLE_EXTENSIONS_SET",
|
|
343
|
+
"SelectionContext",
|
|
344
|
+
"SelectionStrategy",
|
|
345
|
+
"Sequence",
|
|
346
|
+
"StrategyFn",
|
|
347
|
+
"TEXT_ENCODINGS",
|
|
348
|
+
"TEXT_ENCODINGS_SET",
|
|
349
|
+
"TEXT_EXTENSIONS",
|
|
350
|
+
"TEXT_EXTENSIONS_SET",
|
|
351
|
+
"TRANSLATION_TABLE",
|
|
352
|
+
"TREEVIEW_SCRIPT",
|
|
353
|
+
"TextIO",
|
|
354
|
+
"ThreadPoolExecutor",
|
|
355
|
+
"Type",
|
|
356
|
+
"TypeAlias",
|
|
357
|
+
"UNIV_DEFS_SYS_PATH_SCRIPT",
|
|
358
|
+
"VIDEO_EXTENSIONS",
|
|
359
|
+
"VIDEO_EXTENSIONS_SET",
|
|
360
|
+
"adaptive_date_labels",
|
|
361
|
+
"analyze_computer_name_results",
|
|
362
|
+
"annotations",
|
|
363
|
+
"ask_and_autopep8",
|
|
364
|
+
"ask_and_replace",
|
|
365
|
+
"calculate_checksum",
|
|
366
|
+
"chain",
|
|
367
|
+
"check_if_command_exists",
|
|
368
|
+
"check_python_formatting",
|
|
369
|
+
"check_python_version",
|
|
370
|
+
"combine_html_files",
|
|
371
|
+
"compile_code",
|
|
372
|
+
"configure_logging",
|
|
373
|
+
"contains_mojibake",
|
|
374
|
+
"dataclass",
|
|
375
|
+
"decimal_year_to_datetime",
|
|
376
|
+
"decode_cp1252",
|
|
377
|
+
"decode_utf8",
|
|
378
|
+
"detect_country",
|
|
379
|
+
"detect_shell",
|
|
380
|
+
"diff_and_confirm",
|
|
381
|
+
"download_file",
|
|
382
|
+
"ensure_daemon_running",
|
|
383
|
+
"ensure_dir",
|
|
384
|
+
"ensure_docker_installed",
|
|
385
|
+
"ensure_even_dimensions",
|
|
386
|
+
"ensure_file",
|
|
387
|
+
"ensure_image_built",
|
|
388
|
+
"ensure_path",
|
|
389
|
+
"ensure_utf8_meta",
|
|
390
|
+
"errno",
|
|
391
|
+
"extract_and_concatenate_segments",
|
|
392
|
+
"extract_timestamp",
|
|
393
|
+
"fallback_logging_config",
|
|
394
|
+
"field",
|
|
395
|
+
"filename_format",
|
|
396
|
+
"find_additional_alias_files",
|
|
397
|
+
"find_ffmpeg",
|
|
398
|
+
"find_preferred_python_version",
|
|
399
|
+
"find_shell_rc_file",
|
|
400
|
+
"fix_mojibake",
|
|
401
|
+
"fix_text",
|
|
402
|
+
"format_date_range",
|
|
403
|
+
"from_jsonable",
|
|
404
|
+
"get_autopep8_fixable_codes",
|
|
405
|
+
"get_computer_name",
|
|
406
|
+
"get_effective_free_memory",
|
|
407
|
+
"get_hostname_os_uname",
|
|
408
|
+
"get_hostname_platform",
|
|
409
|
+
"get_hostname_socket",
|
|
410
|
+
"get_hostname_subprocess_hostname",
|
|
411
|
+
"get_hostname_subprocess_scutil",
|
|
412
|
+
"get_video_duration_seconds",
|
|
413
|
+
"highlight_changes",
|
|
414
|
+
"human_bytesize",
|
|
415
|
+
"human_timespan",
|
|
416
|
+
"if_filepath_then_read",
|
|
417
|
+
"interactive_flake8",
|
|
418
|
+
"is_float",
|
|
419
|
+
"is_internet_available",
|
|
420
|
+
"is_process_running",
|
|
421
|
+
"is_python_script",
|
|
422
|
+
"kill_process",
|
|
423
|
+
"load_ast_var",
|
|
424
|
+
"load_options_from_json",
|
|
425
|
+
"logging",
|
|
426
|
+
"multireplace",
|
|
427
|
+
"my_atomic_write",
|
|
428
|
+
"my_capitalize",
|
|
429
|
+
"my_critical_error",
|
|
430
|
+
"my_diff",
|
|
431
|
+
"my_fopen",
|
|
432
|
+
"my_plural",
|
|
433
|
+
"my_popen",
|
|
434
|
+
"my_title_case",
|
|
435
|
+
"normalize_for_search",
|
|
436
|
+
"normalize_to_dict",
|
|
437
|
+
"open_dir_in_VLC",
|
|
438
|
+
"open_filemanager_with_dirs",
|
|
439
|
+
"open_in_vlc",
|
|
440
|
+
"open_playlist_in_VLC",
|
|
441
|
+
"open_terminal_and_run_command",
|
|
442
|
+
"os",
|
|
443
|
+
"overload",
|
|
444
|
+
"parse_datetime",
|
|
445
|
+
"parse_timezone",
|
|
446
|
+
"print_all_errors",
|
|
447
|
+
"prompt_then_choose",
|
|
448
|
+
"prompt_then_confirm",
|
|
449
|
+
"query_free_space",
|
|
450
|
+
"re",
|
|
451
|
+
"remove_prefix_from_filename",
|
|
452
|
+
"remove_prefix_from_html_title",
|
|
453
|
+
"replace",
|
|
454
|
+
"return_method_name",
|
|
455
|
+
"round_out",
|
|
456
|
+
"run_flake8",
|
|
457
|
+
"run_mypy",
|
|
458
|
+
"run_with_docker_fixes",
|
|
459
|
+
"safe_ctime",
|
|
460
|
+
"safe_exists",
|
|
461
|
+
"safe_is_dir",
|
|
462
|
+
"safe_is_file",
|
|
463
|
+
"safe_mtime",
|
|
464
|
+
"safe_size",
|
|
465
|
+
"safe_stat",
|
|
466
|
+
"save_options_to_json",
|
|
467
|
+
"sci_exp",
|
|
468
|
+
"seconds_in_unit",
|
|
469
|
+
"set_system_volume",
|
|
470
|
+
"show_function_source",
|
|
471
|
+
"start_only_one_instance",
|
|
472
|
+
"sys",
|
|
473
|
+
"to_jsonable",
|
|
474
|
+
"treeview_new_files",
|
|
475
|
+
"verify_script",
|
|
476
|
+
]
|
|
477
|
+
|
|
478
|
+
# Remove submodule attributes that Python auto-attaches to the package when
|
|
479
|
+
# `from emmykit.<sub> import ...` runs. These are not part of the public
|
|
480
|
+
# surface promised by the baseline; the baseline lists only names that were
|
|
481
|
+
# in `dir(univ_defs)`, and `univ_defs.py` was a flat module with no submodules.
|
|
482
|
+
for _sub in (
|
|
483
|
+
"_version",
|
|
484
|
+
"constants",
|
|
485
|
+
"datetime_utils",
|
|
486
|
+
"diff_view",
|
|
487
|
+
"docker_utils",
|
|
488
|
+
"embedded_scripts",
|
|
489
|
+
"extensions",
|
|
490
|
+
"file_io",
|
|
491
|
+
"files",
|
|
492
|
+
"hosts",
|
|
493
|
+
"html_files",
|
|
494
|
+
"humanize",
|
|
495
|
+
"inflect_utils",
|
|
496
|
+
"introspection",
|
|
497
|
+
"io_subprocess",
|
|
498
|
+
"json_io",
|
|
499
|
+
"lint",
|
|
500
|
+
"llm",
|
|
501
|
+
"logging_utils",
|
|
502
|
+
"media",
|
|
503
|
+
"net_targets",
|
|
504
|
+
"network",
|
|
505
|
+
"numeric_helpers",
|
|
506
|
+
"options",
|
|
507
|
+
"paths_ensure",
|
|
508
|
+
"prompts",
|
|
509
|
+
"python_env",
|
|
510
|
+
"safe_paths",
|
|
511
|
+
"system",
|
|
512
|
+
"text",
|
|
513
|
+
"text_constants",
|
|
514
|
+
"treeview",
|
|
515
|
+
):
|
|
516
|
+
globals().pop(_sub, None)
|
|
517
|
+
del _sub
|
emmykit/_version.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""_version — extracted from univ_defs.py."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Final
|
|
6
|
+
|
|
7
|
+
__all__ = ["__version__", "PY_VERSION"]
|
|
8
|
+
|
|
9
|
+
# Annotation deliberately omitted so hatchling's default version-extraction
|
|
10
|
+
# regex (`__version__\s*=\s*['"]([^'"]+)['"]`) can read this line.
|
|
11
|
+
__version__ = "0.3.2"
|
|
12
|
+
|
|
13
|
+
PY_VERSION: Final[float] = 3.12
|
emmykit/constants.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""constants — extracted from univ_defs.py."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import errno
|
|
6
|
+
from typing import Final
|
|
7
|
+
|
|
8
|
+
DEFAULT_ENCODING: str = "utf-8"
|
|
9
|
+
|
|
10
|
+
ANSI_RED: str = "\033[91m"
|
|
11
|
+
|
|
12
|
+
ANSI_GREEN: str = "\033[92m" # this is bold/bright green on Linux but orange on my Mac
|
|
13
|
+
|
|
14
|
+
ANSI_YELLOW: str = "\033[93m"
|
|
15
|
+
|
|
16
|
+
ANSI_CYAN: str = "\033[94m" # this is blue on Linux but cyan on my Mac
|
|
17
|
+
|
|
18
|
+
ANSI_RESET: str = "\033[0m"
|
|
19
|
+
|
|
20
|
+
IGNORED_CODES: list[str] = [
|
|
21
|
+
"W503", # line break before binary operator (W503 and W504 are mutually exclusive, so ignore both)
|
|
22
|
+
"W504", # line break after binary operator (W503 and W504 are mutually exclusive, so ignore both)
|
|
23
|
+
"E117", # over-indented line (comment) (I like to play with indentation so this cramps my style)
|
|
24
|
+
"E127", # continuation line over-indented for visual indent (I like to play with indentation so this cramps my style)
|
|
25
|
+
"E122", # continuation line missing indentation or outdented (I like to play with indentation so this cramps my style)
|
|
26
|
+
"E128", # continuation line under-indented for visual indent (I like to play with indentation so this cramps my style)
|
|
27
|
+
"E201", # whitespace after "(" (I like to play with white space so this cramps my style)
|
|
28
|
+
"E202", # whitespace before ")" (I like to play with white space so this cramps my style)
|
|
29
|
+
"E203", # whitespace before ":" (I like to play with white space so this cramps my style)
|
|
30
|
+
"E211", # whitespace before "(" (I like to play with white space so this cramps my style)
|
|
31
|
+
"E221", # multiple spaces before operator (I like to play with white space so this cramps my style)
|
|
32
|
+
"E222", # multiple spaces after operator (I like to play with white space so this cramps my style)
|
|
33
|
+
"E226", # missing whitespace around arithmetic operator (the fix doesn't work on the right side even with --aggressive)
|
|
34
|
+
"E227", # missing whitespace around bitwise or shift operator (the fix doesn't work on the right side even with --aggressive)
|
|
35
|
+
"E241", # multiple spaces after "," (I like to play with white space so this cramps my style)
|
|
36
|
+
"E251", # unexpected spaces around keyword / parameter equals (I like to play with white space so this cramps my style)
|
|
37
|
+
"E262", # inline comment should start with "# " (*shrug* I don't wanna)
|
|
38
|
+
"E271", # multiple spaces after keyword (I like to play with white space so this cramps my style)
|
|
39
|
+
"E272", # multiple spaces before keyword (I like to play with white space so this cramps my style)
|
|
40
|
+
"E701", # multiple statements on one line (colon) (I like to group commands together: this cramps my style)
|
|
41
|
+
"E702", # multiple statements on one line (semicolon) (I like to group commands together: this cramps my style)
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
BACKTICK = "\u0060" # U+0060 "GRAVE ACCENT" (the backtick)
|
|
45
|
+
|
|
46
|
+
LSQUOTE = "\u2018" # U+2018 "LEFT SINGLE QUOTATION MARK" (curly apostrophe)
|
|
47
|
+
|
|
48
|
+
RSQUOTE = "\u2019" # U+2019 "RIGHT SINGLE QUOTATION MARK" (curly apostrophe)
|
|
49
|
+
|
|
50
|
+
LDQUOTE = "\u201C" # U+201C "LEFT DOUBLE QUOTATION MARK"
|
|
51
|
+
|
|
52
|
+
RDQUOTE = "\u201D" # U+201D "RIGHT DOUBLE QUOTATION MARK"
|
|
53
|
+
|
|
54
|
+
HORIZONTAL_ELLIPSIS = "\u2026" # U+2026 "HORIZONTAL ELLIPSIS" (three closely spaced periods)
|
|
55
|
+
|
|
56
|
+
EM_DASH = "\u2014" # U+2014 "EM DASH"
|
|
57
|
+
|
|
58
|
+
IGNORE_THESE_ERRORS: Final[frozenset[int]] = frozenset(
|
|
59
|
+
e for e in {
|
|
60
|
+
errno.EACCES, errno.EPERM, errno.ELOOP, errno.ENOTDIR, errno.ENOENT,
|
|
61
|
+
getattr(errno, "ESTALE", None), # NFS: stale file handle (may not exist)
|
|
62
|
+
} if e is not None
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
DEFAULT_EXCLUDE_DIRS: set[str] = {".git", "__pycache__", ".venv", "venv", "build", "dist"}
|