dekshell 0.2.35__py3-none-any.whl → 0.2.37__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.
@@ -14,7 +14,7 @@ from dektools.time import DateTime
14
14
  from dektools.file import read_text
15
15
  from dektools.env import is_on_cicd
16
16
  from dektools.ps.process import process_attrs
17
- from dektools.extraction.filter.utils import Method, MethodSimple, AttrProxy
17
+ from dektools.context.utils import Method, MethodSimple, AttrProxy
18
18
  from ...utils.serializer import serializer
19
19
  from ..redirect import shell_name
20
20
  from ..markers.base.core import get_inner_vars
@@ -34,15 +34,15 @@ class MarkerBase:
34
34
  trans_marker_encode = '/'
35
35
  trans_marker_env = '$$'
36
36
  trans_marker_env_full = '$'
37
- trans_marker__set = '|'.join((re.escape(x) for x in [
38
- trans_marker_command_rc_silence,
39
- trans_marker_command_rc,
40
- trans_marker_command_output,
41
- trans_marker_decode,
42
- trans_marker_encode,
43
- trans_marker_env,
44
- trans_marker_env_full,
45
- ]))
37
+ # trans_marker__set = '|'.join((re.escape(x) for x in [
38
+ # trans_marker_command_rc_silence,
39
+ # trans_marker_command_rc,
40
+ # trans_marker_command_output,
41
+ # trans_marker_decode,
42
+ # trans_marker_encode,
43
+ # trans_marker_env,
44
+ # trans_marker_env_full,
45
+ # ]))
46
46
  trans_marker__as_var = '='
47
47
  trans_marker__ignore = '?'
48
48
  trans_marker__begin = "{"
@@ -151,18 +151,23 @@ class MarkerBase:
151
151
 
152
152
  @classmethod
153
153
  def _translate(cls, context, s):
154
- def handler(expression, marker, _):
154
+ def handler(expression, _, __):
155
+ expression = expression.lstrip()
155
156
  as_var = False
156
157
  ignore = False
157
- m = re.match(
158
- r'(%s|%s)*' % (re.escape(cls.trans_marker__as_var), re.escape(cls.trans_marker__ignore)), expression)
159
- if m:
160
- index = m.span()[1]
161
- mm = expression[:index]
162
- as_var = cls.trans_marker__as_var in mm
163
- ignore = cls.trans_marker__ignore in mm
164
- expression = expression[index:]
165
- value = handler_core(expression, ignore, marker)
158
+ while True:
159
+ change = 0
160
+ if not as_var and expression.startswith(cls.trans_marker__as_var):
161
+ expression = expression[len(cls.trans_marker__as_var):].lstrip()
162
+ as_var = True
163
+ change +=1
164
+ if not ignore and expression.startswith(cls.trans_marker__ignore):
165
+ expression = expression[len(cls.trans_marker__ignore):].lstrip()
166
+ ignore = True
167
+ change +=1
168
+ if change in (0, 2):
169
+ break
170
+ value = handler_core(expression, ignore)
166
171
  if as_var:
167
172
  return context.add_variable_temp(value)
168
173
  return value
@@ -176,24 +181,30 @@ class MarkerBase:
176
181
  else:
177
182
  raise
178
183
 
179
- def handler_core(expression, ignore, marker):
180
- key = marker[len(cls.trans_marker__begin):]
181
- if key.startswith(cls.trans_marker_command_rc_silence):
184
+ def handler_core(expression, ignore):
185
+ if expression.startswith(cls.trans_marker_command_rc_silence):
186
+ expression = expression[len(cls.trans_marker_command_rc_silence):]
182
187
  return shell_exitcode(expression, env=context.environ_full())
183
- elif key.startswith(cls.trans_marker_command_rc):
188
+ elif expression.startswith(cls.trans_marker_command_rc):
189
+ expression = expression[len(cls.trans_marker_command_rc):]
184
190
  return shell_wrapper(expression, check=False, env=context.environ_full())
185
- elif key.startswith(cls.trans_marker_command_output):
191
+ elif expression.startswith(cls.trans_marker_command_output):
192
+ expression = expression[len(cls.trans_marker_command_output):]
186
193
  return shell_output(expression, env=context.environ_full())
187
- elif key.startswith(cls.trans_marker_env):
194
+ elif expression.startswith(cls.trans_marker_env):
195
+ expression = expression[len(cls.trans_marker_env):]
188
196
  return os.getenv(expression.strip(), default_value)
189
- elif key.startswith(cls.trans_marker_env_full):
197
+ elif expression.startswith(cls.trans_marker_env_full):
198
+ expression = expression[len(cls.trans_marker_env_full):]
190
199
  return context.get_env(expression.strip(), default_value)
191
- elif key.startswith(cls.trans_marker_decode):
200
+ elif expression.startswith(cls.trans_marker_decode):
201
+ expression = expression[len(cls.trans_marker_decode):]
192
202
  value = evaluate(expression, ignore, empty_value)
193
203
  if value is empty_value:
194
204
  return default_value
195
205
  return serializer.load(value)
196
- elif key.startswith(cls.trans_marker_encode):
206
+ elif expression.startswith(cls.trans_marker_encode):
207
+ expression = expression[len(cls.trans_marker_encode):]
197
208
  value = evaluate(expression, ignore, empty_value)
198
209
  if value is empty_value:
199
210
  return default_value
@@ -205,7 +216,9 @@ class MarkerBase:
205
216
  default_value = ''
206
217
 
207
218
  translate = deep_format(
208
- s, f"{re.escape(cls.trans_marker__begin)}({cls.trans_marker__set})?",
219
+ s,
220
+ # f"{re.escape(cls.trans_marker__begin)}({cls.trans_marker__set})?",
221
+ f"{re.escape(cls.trans_marker__begin)}",
209
222
  re.escape(cls.trans_marker__end), handler, cls.trans_marker__escape)
210
223
  return translate
211
224
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dekshell
3
- Version: 0.2.35
3
+ Version: 0.2.37
4
4
  Author-Email: sanzenwin <sanzenwin@gmail.com>
5
5
  License: MIT
6
6
  Requires-Python: >=3.8
@@ -1,15 +1,15 @@
1
- dekshell-0.2.35.dist-info/METADATA,sha256=hDvwRVi1ZNokJ-7ORpier5GMGRIADdI1qi8DJyFoU5c,573
2
- dekshell-0.2.35.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- dekshell-0.2.35.dist-info/entry_points.txt,sha256=d-kbfULiUTZWIBBsrQF3J_-wESncF-4K2rwHT08grlI,75
1
+ dekshell-0.2.37.dist-info/METADATA,sha256=hLoHPx1Bk_khnud7HIp4MmP75nyOyNr3O5Ab5B80ORQ,573
2
+ dekshell-0.2.37.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ dekshell-0.2.37.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=r-AHdO9CEEVvTN20-8Jozr6Zh8XSv_BnktYRwrlhtrE,2046
7
7
  dekshell/core/__init__.py,sha256=isDEKwk1odLdvTQNCILCtVNBuXp1uFVPz_uTDNihkVU,5547
8
8
  dekshell/core/contexts/__init__.py,sha256=ynsfv37azOKfI2UKd0iPl2M6iBW-k5cb1BqSLOWuJpI,482
9
9
  dekshell/core/contexts/methods.py,sha256=KxCVtJV3NXFKuCB-MYnQ2EJgFoegRwx5gtTGsmN-64g,10548
10
- dekshell/core/contexts/properties.py,sha256=R6TBvQAH4IIkLZV8wfroUXguy9cxYsKmPEE_FCV2dA8,3417
10
+ dekshell/core/contexts/properties.py,sha256=Q6eg90Upe321Si69MKjZR6mYzDbbMJ9u3JjwvXpDfIM,3407
11
11
  dekshell/core/markers/__init__.py,sha256=yRQazZ1dxMltFao_RQnDnawSnQcjN_4B930MjJhaZ40,1968
12
- dekshell/core/markers/base/__init__.py,sha256=W5f_Mcn9MLM8kOVqu05NUaDpn3xUNURe_NYerUoH6Js,16021
12
+ dekshell/core/markers/base/__init__.py,sha256=CsbNYGQ2Od3XdekR9RFMJ7mo9Roj-LlXS62SY50fiAY,16826
13
13
  dekshell/core/markers/base/core.py,sha256=InsUA3md2gC6GyXQsvARfeNTrfbVD3gGOYxTM8VqqPA,11679
14
14
  dekshell/core/markers/base/shell.py,sha256=fiFsTUDI8pSDDUCk834OI4ajri2qNWFJkLVhmUk2uAs,484
15
15
  dekshell/core/markers/commands.py,sha256=mDRj4dSfKbDaZ_ts4lPXd6wftvGFI4VKkRoIzxV7otA,1696
@@ -37,4 +37,4 @@ dekshell/utils/cmd.py,sha256=K9FbXgHcGFchHA58xI0_t4YK4yb8XkWbxsNoztYRx3Y,518
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.35.dist-info/RECORD,,
40
+ dekshell-0.2.37.dist-info/RECORD,,