dekshell 0.2.20__py3-none-any.whl → 0.2.21__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/core/markers/__init__.py +1 -1
- dekshell/core/markers/base/__init__.py +1 -0
- dekshell/core/markers/base/core.py +27 -2
- dekshell/core/markers/base/shell.py +21 -0
- dekshell/core/markers/commands.py +25 -0
- dekshell/core/markers/empty.py +1 -28
- dekshell/core/markers/redirect.py +18 -16
- dekshell/core/markers/shell.py +2 -1
- {dekshell-0.2.20.dist-info → dekshell-0.2.21.dist-info}/METADATA +1 -1
- {dekshell-0.2.20.dist-info → dekshell-0.2.21.dist-info}/RECORD +12 -11
- {dekshell-0.2.20.dist-info → dekshell-0.2.21.dist-info}/WHEEL +0 -0
- {dekshell-0.2.20.dist-info → dekshell-0.2.21.dist-info}/entry_points.txt +0 -0
|
@@ -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):
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from dektools.shell import shell_command
|
|
2
|
+
from . import MarkerShellBase
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ShellCommand:
|
|
6
|
+
shell_call = shell_command
|
|
7
|
+
|
|
8
|
+
def __init__(self, kwargs):
|
|
9
|
+
self.kwargs = kwargs
|
|
10
|
+
|
|
11
|
+
def __call__(self, *args, **kwargs):
|
|
12
|
+
kwargs = kwargs | self.kwargs
|
|
13
|
+
return self.shell(*args, **kwargs)
|
|
14
|
+
|
|
15
|
+
def shell(self, *args, **kwargs):
|
|
16
|
+
return shell_command(*args, **kwargs)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class MarkerShell(MarkerShellBase):
|
|
20
|
+
tag_head = ""
|
|
21
|
+
shell_cls = ShellCommand
|
|
@@ -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
|
dekshell/core/markers/empty.py
CHANGED
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
from
|
|
2
|
-
from .base import MarkerShellBase
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class ShellCommand:
|
|
6
|
-
def __init__(self, kwargs):
|
|
7
|
-
self.kwargs = kwargs
|
|
8
|
-
|
|
9
|
-
def __call__(self, *args, **kwargs):
|
|
10
|
-
kwargs = kwargs | self.kwargs
|
|
11
|
-
return self.shell(*args, **kwargs)
|
|
12
|
-
|
|
13
|
-
def shell(self, *args, **kwargs):
|
|
14
|
-
return shell_command(*args, **kwargs)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class MarkerShell(MarkerShellBase):
|
|
18
|
-
tag_head = ""
|
|
19
|
-
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)
|
|
1
|
+
from .base.shell import MarkerShell
|
|
29
2
|
|
|
30
3
|
|
|
31
4
|
class EmptyMarker(MarkerShell):
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
|
|
3
2
|
from dektools.shell import shell_wrapper
|
|
4
3
|
from dektools.attr import DeepObject
|
|
5
4
|
from ...core.redirect import redirect_shell_by_path_tree
|
|
@@ -14,30 +13,33 @@ class MarkerRedirect(MarkerBase):
|
|
|
14
13
|
if not filepath:
|
|
15
14
|
filepath = self.eval(context, 'fp')
|
|
16
15
|
path_shell = redirect_shell_by_path_tree(filepath)
|
|
17
|
-
|
|
18
|
-
self.execute_core(context, path_shell)
|
|
16
|
+
self.execute_core(context, marker_node, marker_set, path_shell)
|
|
19
17
|
|
|
20
|
-
def execute_core(self, context, path_shell):
|
|
18
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
21
19
|
raise NotImplementedError
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
class RedirectMarker(MarkerRedirect):
|
|
25
23
|
tag_head = "redirect"
|
|
24
|
+
stack_check = False
|
|
26
25
|
|
|
27
|
-
def execute_core(self, context, path_shell):
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
27
|
+
if 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
|
+
return self.exit()
|
|
37
|
+
marker_set.check_stack_error(marker_node)
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
class ShiftMarker(MarkerRedirect):
|
|
40
41
|
tag_head = "shift"
|
|
41
42
|
|
|
42
|
-
def execute_core(self, context, path_shell):
|
|
43
|
-
|
|
43
|
+
def execute_core(self, context, marker_node, marker_set, path_shell):
|
|
44
|
+
if path_shell:
|
|
45
|
+
context.update_variables(DeepObject(make_shell_properties(path_shell)).__dict__)
|
dekshell/core/markers/shell.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
dekshell-0.2.
|
|
2
|
-
dekshell-0.2.
|
|
3
|
-
dekshell-0.2.
|
|
1
|
+
dekshell-0.2.21.dist-info/METADATA,sha256=hMyPkDtXMgxohQMAE8K0woOezydn3-JXNBHnFD9kUdg,573
|
|
2
|
+
dekshell-0.2.21.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
|
3
|
+
dekshell-0.2.21.dist-info/entry_points.txt,sha256=d-kbfULiUTZWIBBsrQF3J_-wESncF-4K2rwHT08grlI,75
|
|
4
4
|
dekshell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
dekshell/click/__entry__.py,sha256=CMuxUzXoEe4TcHFZwv-MNFwHnu1HSZCDpXFpqQ814uM,42
|
|
6
6
|
dekshell/click/__init__.py,sha256=rFzB_exzPQaIcbbms5PdHAU3NGdl2MBaYbq9v7g7BOI,1870
|
|
@@ -8,14 +8,15 @@ dekshell/core/__init__.py,sha256=w-IeR-tO61Mv4ubZyw9LvyagudyD8SXH0YD3yKApNXk,540
|
|
|
8
8
|
dekshell/core/contexts/__init__.py,sha256=ynsfv37azOKfI2UKd0iPl2M6iBW-k5cb1BqSLOWuJpI,482
|
|
9
9
|
dekshell/core/contexts/methods.py,sha256=6THhB6X6VqpHKLQIW3bOrd3J9yxHems2PRt8dR6xiT0,9344
|
|
10
10
|
dekshell/core/contexts/properties.py,sha256=esr51c6wDTDsuFXF2uj7WfyIGSq9H0dzqDqWzeMTNQE,2382
|
|
11
|
-
dekshell/core/markers/__init__.py,sha256=
|
|
12
|
-
dekshell/core/markers/base/__init__.py,sha256=
|
|
13
|
-
dekshell/core/markers/base/core.py,sha256=
|
|
14
|
-
dekshell/core/markers/
|
|
11
|
+
dekshell/core/markers/__init__.py,sha256=yAZJEIK7eeaZvlIDwTFe2d3yKZiTUVGJQbHOnhNFOMQ,1891
|
|
12
|
+
dekshell/core/markers/base/__init__.py,sha256=Rcc77ToE4cFlJvGwezRez4nAcfbdzgAhDRHaew5wvk0,13456
|
|
13
|
+
dekshell/core/markers/base/core.py,sha256=ztB28fDPeqUkXCHchxjU2JO7R1klp_iUj2d6e8IlGCA,11567
|
|
14
|
+
dekshell/core/markers/base/shell.py,sha256=DhaekMMTuABYP4GyZA05eejFfgxb1lQBwI88dlFv90E,479
|
|
15
|
+
dekshell/core/markers/commands.py,sha256=mDRj4dSfKbDaZ_ts4lPXd6wftvGFI4VKkRoIzxV7otA,1696
|
|
15
16
|
dekshell/core/markers/comment.py,sha256=28iccgLs_0bRdXLhHyQR2I_kzlWdeMSqqNUFW-2vkes,818
|
|
16
17
|
dekshell/core/markers/define.py,sha256=LpMSfz9ziXq2aFJ6oMpUFFo93TpBx7GxKYNzCeht4fQ,516
|
|
17
18
|
dekshell/core/markers/echo.py,sha256=1H61qQbY9tZnrKsdTI_shTmDY5ZaSGipDuBSRptAuZw,660
|
|
18
|
-
dekshell/core/markers/empty.py,sha256=
|
|
19
|
+
dekshell/core/markers/empty.py,sha256=pWKsHlrp6uXWU6blqOs0IgN_3kYm1OmDQiKGPERabAo,79
|
|
19
20
|
dekshell/core/markers/env.py,sha256=6ZtiMNdKFbGR_DBjG6C7A8L_lJsiymN5Y5AbnTzyMrE,1158
|
|
20
21
|
dekshell/core/markers/exec.py,sha256=3vQc-jH7toU_89rNFTipowr0ZrNn79pqmNbYuHxCPDI,2370
|
|
21
22
|
dekshell/core/markers/for_.py,sha256=uNOEwyDsjffttEBtUYasdlj7FP_sGnQzWuTV5d5esHY,2142
|
|
@@ -24,8 +25,8 @@ dekshell/core/markers/if_.py,sha256=bBG1fDCZd5alE5FSm0QhgHl6ZJn5awiqZAXnPnO-thc,
|
|
|
24
25
|
dekshell/core/markers/input.py,sha256=O0yvGtt1uhbpE2gOReLseAmshVpZYMW3zV-OabZt0lw,1182
|
|
25
26
|
dekshell/core/markers/invoke.py,sha256=To_U_FscoCbf7osvjC5MQTk2gjH5Mu_-06Kb22YQPTo,1441
|
|
26
27
|
dekshell/core/markers/pip_.py,sha256=mxXa_oqcrk4Qz-HvhlkMoirsl-SbM9Fz610leNqP1o0,832
|
|
27
|
-
dekshell/core/markers/redirect.py,sha256=
|
|
28
|
-
dekshell/core/markers/shell.py,sha256=
|
|
28
|
+
dekshell/core/markers/redirect.py,sha256=WGaWW-7efaCIOYhs3gQgtKJC4lmFsBx2AQ4bs5Bu_UQ,1828
|
|
29
|
+
dekshell/core/markers/shell.py,sha256=43BDAAzMdmgZmemkW5buh_w4LL1GDGw-s9fNZo6vhag,1929
|
|
29
30
|
dekshell/core/markers/var.py,sha256=O-lpWhnLOkKMwF1jR0rVwyHLa8YUWwacCs80wFzwfdQ,4838
|
|
30
31
|
dekshell/core/markers/while_.py,sha256=e7lI5jsIM-qxNHMY_wUyCMvvesdXQibR5Ez2jNO9csc,1195
|
|
31
32
|
dekshell/core/plugin/__init__.py,sha256=jAB_KnnHJsyJR_zIfBU_HNLngyhcyyqVv05PdlNZtF8,428
|
|
@@ -36,4 +37,4 @@ dekshell/utils/cmd.py,sha256=FfWNRRRdiiTs3xoXvaAyZ-3OzsWFRnd3m5k6sIexrhc,1209
|
|
|
36
37
|
dekshell/utils/pkg.py,sha256=TgYqRqawoJfjkxt6UAHnp9ttmpjuHiWRFbqxADOS1VE,1337
|
|
37
38
|
dekshell/utils/serializer.py,sha256=aIdF2Wzo-qHmIshv46jn1XD0X66vQ1JFdU-g3ZFbH2w,386
|
|
38
39
|
dekshell/utils/shell.py,sha256=0NoA2-SOOMinbmZZipwzL-npBbzPOdWEfdPVYqq5G5g,92
|
|
39
|
-
dekshell-0.2.
|
|
40
|
+
dekshell-0.2.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|