dekshell 0.2.15__tar.gz → 0.2.17__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.
- {dekshell-0.2.15 → dekshell-0.2.17}/PKG-INFO +1 -1
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/__init__.py +2 -1
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/contexts/methods.py +41 -6
- {dekshell-0.2.15 → dekshell-0.2.17}/pyproject.toml +1 -1
- {dekshell-0.2.15 → dekshell-0.2.17}/README.md +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/click/__entry__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/click/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/contexts/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/contexts/properties.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/base/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/base/core.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/commands.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/comment.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/define.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/echo.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/empty.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/env.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/exec.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/for_.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/function.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/if_.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/input.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/invoke.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/pip_.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/redirect.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/shell.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/var.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/markers/while_.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/plugin/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/core/redirect.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/__init__.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/beep.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/cmd.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/pkg.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/serializer.py +0 -0
- {dekshell-0.2.15 → dekshell-0.2.17}/dekshell/utils/shell.py +0 -0
|
@@ -7,7 +7,7 @@ from collections import OrderedDict
|
|
|
7
7
|
from dektools.time import get_tz
|
|
8
8
|
from dektools.format import format_duration
|
|
9
9
|
from dektools.shell import shell_command, shell_wrapper
|
|
10
|
-
from dektools.file import normal_path
|
|
10
|
+
from dektools.file import normal_path, seek_py_module_path
|
|
11
11
|
from dektools.escape import str_escape_wrap
|
|
12
12
|
from .contexts import get_all_context
|
|
13
13
|
from .markers import generate_markers, CommentConfigMarker
|
|
@@ -40,6 +40,7 @@ def shell_command_file(filepath, **kwargs):
|
|
|
40
40
|
kwargs['context'] = (kwargs.get('context') or {}) | dict(
|
|
41
41
|
fp=filepath,
|
|
42
42
|
fpp=os.path.dirname(filepath),
|
|
43
|
+
fpy=seek_py_module_path(filepath),
|
|
43
44
|
)
|
|
44
45
|
return shell_command_batch(f.read(), **kwargs)
|
|
45
46
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import shutil
|
|
3
3
|
import sys
|
|
4
|
+
import time
|
|
4
5
|
import tempfile
|
|
5
6
|
import getpass
|
|
6
7
|
from importlib import import_module
|
|
@@ -10,7 +11,7 @@ from pathlib import Path
|
|
|
10
11
|
from io import BytesIO, StringIO
|
|
11
12
|
from dektools.file import sure_dir, write_file, read_text, remove_path, sure_parent_dir, normal_path, \
|
|
12
13
|
format_path_desc, read_file, split_ext, path_ext, clear_dir, copy_recurse_ignore, path_is_empty, \
|
|
13
|
-
read_lines, \
|
|
14
|
+
read_lines, seek_py_module_path, \
|
|
14
15
|
split_file, combine_split_files, remove_split_files, meta_split_file, tree, iglob, \
|
|
15
16
|
where, where_list, which, which_list
|
|
16
17
|
from dektools.hash import hash_file
|
|
@@ -23,6 +24,7 @@ from dektools.download import download_from_http
|
|
|
23
24
|
from dektools.ps.process import process_detail, process_kill, process_list_all
|
|
24
25
|
from dektools.time import now
|
|
25
26
|
from dektools.str import shlex_split, shlex_quote
|
|
27
|
+
from dektools.format import format_duration
|
|
26
28
|
from dektools.shell import shell_wrapper, is_user_admin, shell_timeout, shell_retry
|
|
27
29
|
from dektools.match import GeneralMatcher, glob2re, glob_compile, glob_match
|
|
28
30
|
from dektools.cmd.git import git_clean_dir, git_apply, git_parse_modules, git_fetch_min, git_list_remotes, git_head
|
|
@@ -99,15 +101,26 @@ def _remove_path(path):
|
|
|
99
101
|
_remove_path(item)
|
|
100
102
|
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
_eval_default = object()
|
|
103
105
|
|
|
104
106
|
|
|
105
|
-
def
|
|
107
|
+
def _eval_mixin(expression, default=_eval_default, translate=False):
|
|
106
108
|
context = get_inner_vars('__inner_context__', full=True)
|
|
107
109
|
try:
|
|
108
110
|
return MarkerBase.eval_mixin(context, expression, translate)
|
|
109
111
|
except NameError:
|
|
110
|
-
if default is
|
|
112
|
+
if default is _eval_default:
|
|
113
|
+
raise
|
|
114
|
+
else:
|
|
115
|
+
return default
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _eval_lines(expression, default=_eval_default):
|
|
119
|
+
context = get_inner_vars('__inner_context__', full=True)
|
|
120
|
+
try:
|
|
121
|
+
return MarkerBase.eval_lines(context, expression)
|
|
122
|
+
except NameError:
|
|
123
|
+
if default is _eval_default:
|
|
111
124
|
raise
|
|
112
125
|
else:
|
|
113
126
|
return default
|
|
@@ -162,6 +175,21 @@ def _pymd(name):
|
|
|
162
175
|
return None
|
|
163
176
|
|
|
164
177
|
|
|
178
|
+
def _time_mark(begin=True, name=None):
|
|
179
|
+
var_prefix = '__time_marker__'
|
|
180
|
+
name = 'default' if name is None else name
|
|
181
|
+
marker_set = get_inner_vars('__inner_marker_set__', full=True)
|
|
182
|
+
_now = time.time_ns()
|
|
183
|
+
if begin:
|
|
184
|
+
marker_set.vars.add_item(var_prefix + name, _now)
|
|
185
|
+
else:
|
|
186
|
+
t = marker_set.vars.get_item(var_prefix + name, None)
|
|
187
|
+
if t is None:
|
|
188
|
+
return ''
|
|
189
|
+
else:
|
|
190
|
+
return format_duration(int((_now - t) / 10 ** 6))
|
|
191
|
+
|
|
192
|
+
|
|
165
193
|
path_common_methods = {
|
|
166
194
|
'cd': _cd,
|
|
167
195
|
'cwd': lambda: os.getcwd(),
|
|
@@ -171,14 +199,14 @@ path_common_methods = {
|
|
|
171
199
|
'where_list': where_list,
|
|
172
200
|
'pybin': lambda x, p=None: search_bin_by_path_tree(p or os.getcwd(), x, False),
|
|
173
201
|
'pym': _pym,
|
|
174
|
-
'pymd': _pymd
|
|
202
|
+
'pymd': _pymd,
|
|
203
|
+
'pyms': seek_py_module_path,
|
|
175
204
|
}
|
|
176
205
|
|
|
177
206
|
default_methods = {
|
|
178
207
|
'io': _io,
|
|
179
208
|
'reduce': reduce,
|
|
180
209
|
'chain': chain,
|
|
181
|
-
'xeval': _xeval,
|
|
182
210
|
'echo': lambda *x, **y: print(*x, **dict(flush=True) | y),
|
|
183
211
|
'echos': lambda *x, **y: print(*x, **dict(end='', flush=True) | y),
|
|
184
212
|
'echox': lambda *x, **y: print(*x, **dict(file=sys.stderr, flush=True) | y),
|
|
@@ -193,6 +221,8 @@ default_methods = {
|
|
|
193
221
|
'timeout': shell_timeout,
|
|
194
222
|
'retry': shell_retry,
|
|
195
223
|
'run': shell_wrapper,
|
|
224
|
+
'eval': _eval_mixin,
|
|
225
|
+
'exec': _eval_lines,
|
|
196
226
|
},
|
|
197
227
|
'path': {
|
|
198
228
|
**path_common_methods,
|
|
@@ -233,6 +263,11 @@ default_methods = {
|
|
|
233
263
|
'hash': lambda x, name='sha256', args=None: hash_file(name, x, args=args),
|
|
234
264
|
},
|
|
235
265
|
**path_common_methods,
|
|
266
|
+
'time': {
|
|
267
|
+
'now': now,
|
|
268
|
+
'begin': lambda name=None: _time_mark(True, name),
|
|
269
|
+
'end': lambda name=None: _time_mark(False, name),
|
|
270
|
+
},
|
|
236
271
|
'pu': {
|
|
237
272
|
'ps': process_list_all,
|
|
238
273
|
'kill': process_kill,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|