dekshell 0.2.20__tar.gz → 0.2.22__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.20 → dekshell-0.2.22}/PKG-INFO +1 -1
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/contexts/methods.py +9 -1
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/__init__.py +1 -1
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/base/__init__.py +1 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/base/core.py +27 -2
- dekshell-0.2.20/dekshell/core/markers/empty.py → dekshell-0.2.22/dekshell/core/markers/base/shell.py +3 -14
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/commands.py +25 -0
- dekshell-0.2.22/dekshell/core/markers/empty.py +5 -0
- dekshell-0.2.22/dekshell/core/markers/redirect.py +51 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/shell.py +2 -1
- {dekshell-0.2.20 → dekshell-0.2.22}/pyproject.toml +1 -1
- dekshell-0.2.20/dekshell/core/markers/redirect.py +0 -43
- {dekshell-0.2.20 → dekshell-0.2.22}/README.md +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/click/__entry__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/click/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/contexts/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/contexts/properties.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/comment.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/define.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/echo.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/env.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/exec.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/for_.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/function.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/if_.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/input.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/invoke.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/pip_.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/var.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/markers/while_.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/plugin/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/core/redirect.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/__init__.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/beep.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/cmd.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/pkg.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/serializer.py +0 -0
- {dekshell-0.2.20 → dekshell-0.2.22}/dekshell/utils/shell.py +0 -0
|
@@ -175,6 +175,14 @@ def _pymd(name):
|
|
|
175
175
|
return None
|
|
176
176
|
|
|
177
177
|
|
|
178
|
+
def _pyms(path=None):
|
|
179
|
+
if not path:
|
|
180
|
+
path = _eval_mixin('fp', None)
|
|
181
|
+
if not path:
|
|
182
|
+
path = os.getcwd()
|
|
183
|
+
return seek_py_module_path(path)
|
|
184
|
+
|
|
185
|
+
|
|
178
186
|
def _time_mark(begin=True, name=None):
|
|
179
187
|
var_prefix = '__time_marker__'
|
|
180
188
|
if name is None:
|
|
@@ -202,7 +210,7 @@ path_common_methods = {
|
|
|
202
210
|
'pybin': lambda x, p=None: search_bin_by_path_tree(p or os.getcwd(), x, False),
|
|
203
211
|
'pym': _pym,
|
|
204
212
|
'pymd': _pymd,
|
|
205
|
-
'pyms':
|
|
213
|
+
'pyms': _pyms,
|
|
206
214
|
}
|
|
207
215
|
|
|
208
216
|
default_methods = {
|
|
@@ -44,7 +44,7 @@ def generate_markers(*args, **kwargs):
|
|
|
44
44
|
RedirectMarker, ShiftMarker,
|
|
45
45
|
TimeoutMarker, RetryMarker,
|
|
46
46
|
IgnoreMarker,
|
|
47
|
-
PrefixShellMarker,
|
|
47
|
+
IgnoreErrorShellMarker, PrefixShellMarker,
|
|
48
48
|
AssignCallMarker, AssignInvokerMarker, AssignGotoMarker, AssignTimeoutMarker, AssignRetryMarker,
|
|
49
49
|
AssignExecMarker, AssignEvalMarker, AssignCmdcallMarker, AssignCmdcallChainMarker,
|
|
50
50
|
AssignMultiLineRawStrMarker, AssignMultiLineStrMarker, AssignRawStrMarker, AssignStrMarker,
|
|
@@ -140,7 +140,7 @@ class MarkerNode:
|
|
|
140
140
|
self.payload = payload
|
|
141
141
|
|
|
142
142
|
def __repr__(self):
|
|
143
|
-
return f'Node({self.marker.__class__.__name__})'
|
|
143
|
+
return f'Node({self.marker.__class__.__name__},line={self.line_number})'
|
|
144
144
|
|
|
145
145
|
@property
|
|
146
146
|
def debug_info(self):
|
|
@@ -154,6 +154,18 @@ class MarkerNode:
|
|
|
154
154
|
|
|
155
155
|
return obj2str(walk(self))
|
|
156
156
|
|
|
157
|
+
@property
|
|
158
|
+
def ignore_stack_check(self):
|
|
159
|
+
def walk(node):
|
|
160
|
+
if not node.marker.stack_check:
|
|
161
|
+
return node
|
|
162
|
+
for child in node.children:
|
|
163
|
+
r = walk(child)
|
|
164
|
+
if r:
|
|
165
|
+
return r
|
|
166
|
+
|
|
167
|
+
return walk(self)
|
|
168
|
+
|
|
157
169
|
def is_type(self, *markers_cls):
|
|
158
170
|
return isinstance(self.marker, markers_cls)
|
|
159
171
|
|
|
@@ -282,6 +294,12 @@ class MarkerSet:
|
|
|
282
294
|
self.markers = self.transformer_cls.inject(markers)
|
|
283
295
|
self.shell_exec = shell_exec
|
|
284
296
|
self.shell_cmd = shell_cmd
|
|
297
|
+
self.stack_errors = {}
|
|
298
|
+
|
|
299
|
+
def check_stack_error(self, node):
|
|
300
|
+
error = self.stack_errors.get(node.index)
|
|
301
|
+
if error:
|
|
302
|
+
raise error
|
|
285
303
|
|
|
286
304
|
def is_marker_branch(self, marker):
|
|
287
305
|
return marker.__class__ in self.markers_branch_set
|
|
@@ -318,7 +336,14 @@ class MarkerSet:
|
|
|
318
336
|
if marker.tag_tail is not None: # block command
|
|
319
337
|
stack.append(node)
|
|
320
338
|
if len(stack) != 1:
|
|
321
|
-
|
|
339
|
+
node = stack[0].ignore_stack_check
|
|
340
|
+
error = ValueError(
|
|
341
|
+
f'Stack should have just one root node in final, your scripts contains syntax errors: {stack}')
|
|
342
|
+
if node:
|
|
343
|
+
print(error)
|
|
344
|
+
self.stack_errors[node.index] = error
|
|
345
|
+
else:
|
|
346
|
+
raise error
|
|
322
347
|
return stack[0]
|
|
323
348
|
|
|
324
349
|
def execute(self, commands, context, ln=None):
|
dekshell-0.2.20/dekshell/core/markers/empty.py → dekshell-0.2.22/dekshell/core/markers/base/shell.py
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
from dektools.shell import shell_command
|
|
2
|
-
from .
|
|
2
|
+
from . import MarkerShellBase
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class ShellCommand:
|
|
6
|
+
shell_call = shell_command
|
|
7
|
+
|
|
6
8
|
def __init__(self, kwargs):
|
|
7
9
|
self.kwargs = kwargs
|
|
8
10
|
|
|
@@ -17,16 +19,3 @@ class ShellCommand:
|
|
|
17
19
|
class MarkerShell(MarkerShellBase):
|
|
18
20
|
tag_head = ""
|
|
19
21
|
shell_cls = ShellCommand
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class PrefixShellMarker(MarkerShell):
|
|
23
|
-
tag_head = "@"
|
|
24
|
-
|
|
25
|
-
def execute(self, context, command, marker_node, marker_set):
|
|
26
|
-
_, command = self.split_raw(command, 1, self.tag_head)
|
|
27
|
-
if command:
|
|
28
|
-
self.execute_core(context, command, marker_node, marker_set)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class EmptyMarker(MarkerShell):
|
|
32
|
-
pass
|
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
from dektools.shell import shell_wrapper
|
|
1
3
|
from .base import MarkerWithEnd
|
|
4
|
+
from .base.shell import MarkerShell, ShellCommand
|
|
2
5
|
from .empty import EmptyMarker
|
|
3
6
|
|
|
4
7
|
|
|
8
|
+
class PrefixShellMarker(MarkerShell):
|
|
9
|
+
tag_head = "@"
|
|
10
|
+
|
|
11
|
+
def execute(self, context, command, marker_node, marker_set):
|
|
12
|
+
_, command = self.split_raw(command, 1, self.tag_head)
|
|
13
|
+
if command:
|
|
14
|
+
self.execute_core(context, command, marker_node, marker_set)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IgnoreErrorShellCommand(ShellCommand):
|
|
18
|
+
def shell(self, *args, **kwargs):
|
|
19
|
+
try:
|
|
20
|
+
shell_wrapper(*args, **kwargs)
|
|
21
|
+
except subprocess.SubprocessError:
|
|
22
|
+
return None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class IgnoreErrorShellMarker(PrefixShellMarker):
|
|
26
|
+
tag_head = "!"
|
|
27
|
+
shell_cls = IgnoreErrorShellCommand
|
|
28
|
+
|
|
29
|
+
|
|
5
30
|
class CommandsMarker(MarkerWithEnd):
|
|
6
31
|
tag_head = "@@"
|
|
7
32
|
target_marker_cls = EmptyMarker
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from dektools.shell import shell_wrapper
|
|
3
|
+
from dektools.attr import DeepObject
|
|
4
|
+
from ...core.redirect import redirect_shell_by_path_tree
|
|
5
|
+
from ...utils.cmd import ak2cmd, key_args, key_kwargs
|
|
6
|
+
from ..contexts.properties import make_shell_properties, current_shell
|
|
7
|
+
from .base import MarkerBase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MarkerRedirect(MarkerBase):
|
|
11
|
+
def execute(self, context, command, marker_node, marker_set):
|
|
12
|
+
filepath = self.split_raw(command, 1, self.tag_head)[1]
|
|
13
|
+
if not filepath:
|
|
14
|
+
filepath = self.get_filepath(context)
|
|
15
|
+
path_shell = redirect_shell_by_path_tree(filepath)
|
|
16
|
+
self.execute_core(context, marker_node, marker_set, path_shell)
|
|
17
|
+
|
|
18
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
|
|
21
|
+
def get_filepath(self, context):
|
|
22
|
+
try:
|
|
23
|
+
return self.eval(context, "fp")
|
|
24
|
+
except NameError:
|
|
25
|
+
return os.getcwd()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RedirectMarker(MarkerRedirect):
|
|
29
|
+
tag_head = "redirect"
|
|
30
|
+
stack_check = False
|
|
31
|
+
|
|
32
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
33
|
+
if path_shell:
|
|
34
|
+
shell_properties = make_shell_properties(path_shell)
|
|
35
|
+
if shell_properties['shell'] != current_shell:
|
|
36
|
+
fp = self.get_filepath(context)
|
|
37
|
+
fpp = os.path.dirname(fp).replace('/', os.sep)
|
|
38
|
+
shell = shell_properties['sh']['rfc' if os.getcwd() == fpp else 'rf']
|
|
39
|
+
args, kwargs = self.eval(context, f'({key_args}, {key_kwargs})')
|
|
40
|
+
argv = ak2cmd(args, kwargs)
|
|
41
|
+
shell_wrapper(f'{shell} {fp} {argv}', env=context.environ_full())
|
|
42
|
+
return self.exit()
|
|
43
|
+
marker_set.check_stack_error(marker_node)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ShiftMarker(MarkerRedirect):
|
|
47
|
+
tag_head = "shift"
|
|
48
|
+
|
|
49
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
50
|
+
if path_shell:
|
|
51
|
+
context.update_variables(DeepObject(make_shell_properties(path_shell)).__dict__)
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
|
|
3
|
-
from dektools.shell import shell_wrapper
|
|
4
|
-
from dektools.attr import DeepObject
|
|
5
|
-
from ...core.redirect import redirect_shell_by_path_tree
|
|
6
|
-
from ...utils.cmd import ak2cmd, key_args, key_kwargs
|
|
7
|
-
from ..contexts.properties import make_shell_properties, current_shell
|
|
8
|
-
from .base import MarkerBase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MarkerRedirect(MarkerBase):
|
|
12
|
-
def execute(self, context, command, marker_node, marker_set):
|
|
13
|
-
filepath = self.split_raw(command, 1, self.tag_head)[1]
|
|
14
|
-
if not filepath:
|
|
15
|
-
filepath = self.eval(context, 'fp')
|
|
16
|
-
path_shell = redirect_shell_by_path_tree(filepath)
|
|
17
|
-
if path_shell:
|
|
18
|
-
self.execute_core(context, path_shell)
|
|
19
|
-
|
|
20
|
-
def execute_core(self, context, path_shell):
|
|
21
|
-
raise NotImplementedError
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class RedirectMarker(MarkerRedirect):
|
|
25
|
-
tag_head = "redirect"
|
|
26
|
-
|
|
27
|
-
def execute_core(self, context, path_shell):
|
|
28
|
-
shell_properties = make_shell_properties(path_shell)
|
|
29
|
-
if shell_properties['shell'] != current_shell:
|
|
30
|
-
fp = self.eval(context, "fp")
|
|
31
|
-
fpp = os.path.dirname(fp).replace('/', os.sep)
|
|
32
|
-
shell = shell_properties['sh']['rfc' if os.getcwd() == fpp else 'rf']
|
|
33
|
-
args, kwargs = self.eval(context, f'({key_args}, {key_kwargs})')
|
|
34
|
-
argv = ak2cmd(args, kwargs)
|
|
35
|
-
shell_wrapper(f'{shell} {fp} {argv}', env=context.environ_full())
|
|
36
|
-
self.exit()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ShiftMarker(MarkerRedirect):
|
|
40
|
-
tag_head = "shift"
|
|
41
|
-
|
|
42
|
-
def execute_core(self, context, path_shell):
|
|
43
|
-
context.update_variables(DeepObject(make_shell_properties(path_shell)).__dict__)
|
|
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
|