dekshell 0.2.24__py3-none-any.whl → 0.2.26__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.
- dekshell/click/__entry__.py +4 -0
- dekshell/core/__init__.py +7 -6
- dekshell/core/contexts/methods.py +15 -14
- dekshell/core/markers/base/__init__.py +3 -3
- dekshell/core/markers/base/core.py +2 -2
- dekshell/core/markers/base/shell.py +1 -1
- dekshell/utils/cmd.py +4 -3
- {dekshell-0.2.24.dist-info → dekshell-0.2.26.dist-info}/METADATA +1 -1
- {dekshell-0.2.24.dist-info → dekshell-0.2.26.dist-info}/RECORD +11 -11
- {dekshell-0.2.24.dist-info → dekshell-0.2.26.dist-info}/WHEEL +0 -0
- {dekshell-0.2.24.dist-info → dekshell-0.2.26.dist-info}/entry_points.txt +0 -0
dekshell/click/__entry__.py
CHANGED
dekshell/core/__init__.py
CHANGED
|
@@ -37,11 +37,11 @@ def shell_command_file(filepath, **kwargs):
|
|
|
37
37
|
filepath = normal_path(filepath, unix=True)
|
|
38
38
|
with codecs.open(filepath, encoding='utf-8') as f:
|
|
39
39
|
kwargs['source'] = dict(desc=filepath)
|
|
40
|
-
kwargs['context'] = (kwargs.get('context') or {})
|
|
40
|
+
kwargs['context'] = {**(kwargs.get('context') or {}), **dict(
|
|
41
41
|
fp=filepath,
|
|
42
42
|
fpp=os.path.dirname(filepath),
|
|
43
43
|
fpy=seek_py_module_path(filepath),
|
|
44
|
-
)
|
|
44
|
+
)}
|
|
45
45
|
return shell_command_batch(f.read(), **kwargs)
|
|
46
46
|
|
|
47
47
|
|
|
@@ -56,9 +56,10 @@ default_configs = {
|
|
|
56
56
|
'descper': dict(desc_begin_per=True, desc_took_per=True),
|
|
57
57
|
'source': lambda src: dict(source=dict(desc=src))
|
|
58
58
|
}
|
|
59
|
-
default_configs
|
|
60
|
-
|
|
61
|
-
'
|
|
59
|
+
default_configs = {
|
|
60
|
+
**default_configs,
|
|
61
|
+
'notify': {**default_configs['beep'], **default_configs['deschead']},
|
|
62
|
+
'notifyper': {**default_configs['beep'], **default_configs['deschead'], **default_configs['descper']},
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
|
|
@@ -114,7 +115,7 @@ def shell_command_batch_core(
|
|
|
114
115
|
generate_markers(*(marker or []), **(plugin_kwargs or {})),
|
|
115
116
|
shell_exec, shell_cmd
|
|
116
117
|
)
|
|
117
|
-
context_final = get_all_context()
|
|
118
|
+
context_final = {**get_all_context(), **(context or {})}
|
|
118
119
|
tz = get_tz(tz)
|
|
119
120
|
ts_begin = time.time()
|
|
120
121
|
commands, ln = _get_commands(commands)
|
|
@@ -4,6 +4,7 @@ import sys
|
|
|
4
4
|
import time
|
|
5
5
|
import tempfile
|
|
6
6
|
import getpass
|
|
7
|
+
import operator
|
|
7
8
|
from importlib import import_module
|
|
8
9
|
from functools import reduce
|
|
9
10
|
from itertools import chain
|
|
@@ -11,7 +12,7 @@ from pathlib import Path
|
|
|
11
12
|
from io import BytesIO, StringIO
|
|
12
13
|
from dektools.file import sure_dir, write_file, read_text, remove_path, sure_parent_dir, normal_path, \
|
|
13
14
|
format_path_desc, read_file, split_ext, path_ext, clear_dir, copy_recurse_ignore, path_is_empty, \
|
|
14
|
-
read_lines, seek_py_module_path, come_real_path, status_of_dir, diff_of_dir, \
|
|
15
|
+
read_lines, seek_py_module_path, come_real_path, status_of_dir, diff_of_dir, path_parent, \
|
|
15
16
|
split_file, combine_split_files, remove_split_files, meta_split_file, tree, iglob, \
|
|
16
17
|
where, where_list, which, which_list
|
|
17
18
|
from dektools.hash import hash_file
|
|
@@ -41,13 +42,6 @@ def _is_true(x):
|
|
|
41
42
|
return x not in {'false', '0', 'none', 'null', '', ' ', False, 0, None, b'', b'\0'}
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
def _parent_dir(path, num=1):
|
|
45
|
-
cursor = path
|
|
46
|
-
for i in range(int(num)):
|
|
47
|
-
cursor = os.path.dirname(cursor)
|
|
48
|
-
return cursor
|
|
49
|
-
|
|
50
|
-
|
|
51
45
|
def _list_dir_one(path, file):
|
|
52
46
|
path = normal_path(path)
|
|
53
47
|
for item in os.listdir(path):
|
|
@@ -223,9 +217,9 @@ default_methods = {
|
|
|
223
217
|
'io': _io,
|
|
224
218
|
'reduce': reduce,
|
|
225
219
|
'chain': chain,
|
|
226
|
-
'echo': lambda *x, **y: print(*x, **dict(flush=True)
|
|
227
|
-
'echos': lambda *x, **y: print(*x, **dict(end='', flush=True)
|
|
228
|
-
'echox': lambda *x, **y: print(*x, **dict(file=sys.stderr, flush=True)
|
|
220
|
+
'echo': lambda *x, **y: print(*x, **{**dict(flush=True), **y}),
|
|
221
|
+
'echos': lambda *x, **y: print(*x, **{**dict(end='', flush=True), **y}),
|
|
222
|
+
'echox': lambda *x, **y: print(*x, **{**dict(file=sys.stderr, flush=True), **y}),
|
|
229
223
|
'pprint': pprint,
|
|
230
224
|
'o2s': obj2str,
|
|
231
225
|
'now': now,
|
|
@@ -245,7 +239,7 @@ default_methods = {
|
|
|
245
239
|
'tree': _tree,
|
|
246
240
|
'exists': os.path.exists,
|
|
247
241
|
'empty': path_is_empty,
|
|
248
|
-
'parent':
|
|
242
|
+
'parent': path_parent,
|
|
249
243
|
'abs': normal_path,
|
|
250
244
|
'rel': os.path.relpath,
|
|
251
245
|
'cr': come_real_path,
|
|
@@ -306,11 +300,18 @@ default_methods = {
|
|
|
306
300
|
|
|
307
301
|
'me': lambda x: x,
|
|
308
302
|
'first': lambda x, default=None: next(iter(x), default),
|
|
303
|
+
|
|
309
304
|
'true': lambda x=True: _is_true(x),
|
|
310
305
|
'false': lambda x=False: not _is_true(x),
|
|
311
306
|
|
|
312
|
-
'
|
|
313
|
-
'
|
|
307
|
+
'not_': lambda x: not x,
|
|
308
|
+
'or_': lambda *x: reduce(operator.or_, x),
|
|
309
|
+
'and_': lambda *x: reduce(operator.and_, x),
|
|
310
|
+
'eq': lambda x, y: x == y,
|
|
311
|
+
'neq': lambda x, y: x != y,
|
|
312
|
+
'is_': lambda x, y: x is y,
|
|
313
|
+
'nis': lambda x, y: x is not y,
|
|
314
|
+
|
|
314
315
|
'beep': lambda x=True: sound_notify(x),
|
|
315
316
|
|
|
316
317
|
'invoke': lambda __placeholder__filepath, *args, **kwargs: InvokeMarker.execute_file(
|
|
@@ -235,7 +235,7 @@ class MarkerBase:
|
|
|
235
235
|
def eval(context, s, v=None):
|
|
236
236
|
if not s:
|
|
237
237
|
return None
|
|
238
|
-
return eval(s, context.variables_full()
|
|
238
|
+
return eval(s, {**context.variables_full(), **(v or {})})
|
|
239
239
|
|
|
240
240
|
@classmethod
|
|
241
241
|
def eval_mixin(cls, context, expression, translate=True):
|
|
@@ -278,7 +278,7 @@ class MarkerBase:
|
|
|
278
278
|
|
|
279
279
|
@staticmethod
|
|
280
280
|
def eval_lines(context, s, v=None):
|
|
281
|
-
globals_ = context.variables_full()
|
|
281
|
+
globals_ = {**context.variables_full(), **(v or {})}
|
|
282
282
|
locals_ = {}
|
|
283
283
|
exec(s, globals_, locals_)
|
|
284
284
|
return locals_
|
|
@@ -402,7 +402,7 @@ class MarkerShellBase(MarkerBase):
|
|
|
402
402
|
|
|
403
403
|
@classmethod
|
|
404
404
|
def execute_core(cls, context, command, marker_node, marker_set, kwargs=None):
|
|
405
|
-
kwargs = (marker_node.payload or {})
|
|
405
|
+
kwargs = {**(marker_node.payload or {}), **(kwargs or {})}
|
|
406
406
|
return marker_set.shell_cmd(command, cls.shell_cls(kwargs), env=context.environ_full())
|
|
407
407
|
|
|
408
408
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
|
-
from types import NoneType
|
|
4
3
|
from dektools.output import obj2str
|
|
5
4
|
from dektools.str import hex_random
|
|
6
5
|
from dektools.dict import MapChainContext
|
|
6
|
+
from dektools.typing import NoneType
|
|
7
7
|
from . import MarkerBase, TransformerMarker, ExitException, QuitContextException
|
|
8
8
|
|
|
9
9
|
|
|
@@ -350,6 +350,6 @@ class MarkerSet:
|
|
|
350
350
|
try:
|
|
351
351
|
root = self.generate_tree(commands, ln)
|
|
352
352
|
return root.execute(
|
|
353
|
-
self.context_cls().update_variables((context or {})
|
|
353
|
+
self.context_cls().update_variables({**(context or {}), **dict(__inner_marker_set__=self)}), self)
|
|
354
354
|
except ExitException:
|
|
355
355
|
pass
|
dekshell/utils/cmd.py
CHANGED
|
@@ -34,12 +34,13 @@ def ak2cmd(args=None, kwargs=None):
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def pack_context(args, kwargs):
|
|
37
|
-
return {
|
|
37
|
+
return {
|
|
38
|
+
**{f'{key_arg}{i}': arg for i, arg in enumerate(args)}, **{key_args: tuple(args), key_kwargs: kwargs}, **kwargs}
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
def pack_context_argv():
|
|
41
|
-
return {f"{key_argv}{i}": x for i, x in enumerate(sys.argv)}
|
|
42
|
+
return {**{f"{key_argv}{i}": x for i, x in enumerate(sys.argv)}, **{key_argv: sys.argv}}
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def pack_context_full(args=None, kwargs=None):
|
|
45
|
-
return pack_context(args or [], kwargs or {})
|
|
46
|
+
return {**pack_context(args or [], kwargs or {}), **pack_context_argv()}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
dekshell-0.2.
|
|
2
|
-
dekshell-0.2.
|
|
3
|
-
dekshell-0.2.
|
|
1
|
+
dekshell-0.2.26.dist-info/METADATA,sha256=jKY1znFqUZbTul0uoKqPFnEz0J-3F3FgvypZomH-sQM,573
|
|
2
|
+
dekshell-0.2.26.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
|
3
|
+
dekshell-0.2.26.dist-info/entry_points.txt,sha256=d-kbfULiUTZWIBBsrQF3J_-wESncF-4K2rwHT08grlI,75
|
|
4
4
|
dekshell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
dekshell/click/__entry__.py,sha256=
|
|
5
|
+
dekshell/click/__entry__.py,sha256=fFvrYPXiTLxLS7XLPLPHy_DYTcNE7XL_LZUcVHfIrjA,82
|
|
6
6
|
dekshell/click/__init__.py,sha256=rFzB_exzPQaIcbbms5PdHAU3NGdl2MBaYbq9v7g7BOI,1870
|
|
7
|
-
dekshell/core/__init__.py,sha256=
|
|
7
|
+
dekshell/core/__init__.py,sha256=7d3AjVUGIjXIXRYYiJ03rz5ZONTTojmGfgwpjGmKqtU,5448
|
|
8
8
|
dekshell/core/contexts/__init__.py,sha256=ynsfv37azOKfI2UKd0iPl2M6iBW-k5cb1BqSLOWuJpI,482
|
|
9
|
-
dekshell/core/contexts/methods.py,sha256
|
|
9
|
+
dekshell/core/contexts/methods.py,sha256=ksoOgBHDRM6uiGHw3ubCk4x7ExJKvJ6H3eGhaM-SNDE,9722
|
|
10
10
|
dekshell/core/contexts/properties.py,sha256=esr51c6wDTDsuFXF2uj7WfyIGSq9H0dzqDqWzeMTNQE,2382
|
|
11
11
|
dekshell/core/markers/__init__.py,sha256=_HJsxjjsyYbL7Pj6jhoeJ1WJI92qwCbdl-BKvQcGHlA,1949
|
|
12
|
-
dekshell/core/markers/base/__init__.py,sha256=
|
|
13
|
-
dekshell/core/markers/base/core.py,sha256=
|
|
14
|
-
dekshell/core/markers/base/shell.py,sha256=
|
|
12
|
+
dekshell/core/markers/base/__init__.py,sha256=8WQ1b4J9JBjcPmgAPz5gmXbUf2WgGG41XrktRAvoW-A,13744
|
|
13
|
+
dekshell/core/markers/base/core.py,sha256=LW1KiJBaRhXFOswpChRB9K7VvGQdY1H84wcr-8L9i-k,11582
|
|
14
|
+
dekshell/core/markers/base/shell.py,sha256=fiFsTUDI8pSDDUCk834OI4ajri2qNWFJkLVhmUk2uAs,484
|
|
15
15
|
dekshell/core/markers/commands.py,sha256=mDRj4dSfKbDaZ_ts4lPXd6wftvGFI4VKkRoIzxV7otA,1696
|
|
16
16
|
dekshell/core/markers/comment.py,sha256=28iccgLs_0bRdXLhHyQR2I_kzlWdeMSqqNUFW-2vkes,818
|
|
17
17
|
dekshell/core/markers/define.py,sha256=LpMSfz9ziXq2aFJ6oMpUFFo93TpBx7GxKYNzCeht4fQ,516
|
|
@@ -33,8 +33,8 @@ dekshell/core/plugin/__init__.py,sha256=jAB_KnnHJsyJR_zIfBU_HNLngyhcyyqVv05PdlNZ
|
|
|
33
33
|
dekshell/core/redirect.py,sha256=6YCJpG0TkQ4WMt7LBtDD_W1T-C-QkLtGRQw0S60qe54,1058
|
|
34
34
|
dekshell/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
dekshell/utils/beep.py,sha256=teuQgHbWDr8BD1xCJ4Pt79X6N1-eq1tTlyGunK6wBIM,120
|
|
36
|
-
dekshell/utils/cmd.py,sha256=
|
|
36
|
+
dekshell/utils/cmd.py,sha256=A0lEixQ7Ui0UxmeuymniyqCZXss9qQdX1C0COM7EEkQ,1234
|
|
37
37
|
dekshell/utils/pkg.py,sha256=TgYqRqawoJfjkxt6UAHnp9ttmpjuHiWRFbqxADOS1VE,1337
|
|
38
38
|
dekshell/utils/serializer.py,sha256=aIdF2Wzo-qHmIshv46jn1XD0X66vQ1JFdU-g3ZFbH2w,386
|
|
39
39
|
dekshell/utils/shell.py,sha256=0NoA2-SOOMinbmZZipwzL-npBbzPOdWEfdPVYqq5G5g,92
|
|
40
|
-
dekshell-0.2.
|
|
40
|
+
dekshell-0.2.26.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|