dekshell 0.2.23__py3-none-any.whl → 0.2.25__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.
@@ -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):
@@ -126,6 +120,11 @@ def _eval_lines(expression, default=_eval_default):
126
120
  return default
127
121
 
128
122
 
123
+ def _defined(name):
124
+ default = object()
125
+ return _eval_mixin(name, default=default) is not default
126
+
127
+
129
128
  def _install(name):
130
129
  def posix(exe):
131
130
  s = f"{exe} install -y {name}"
@@ -214,6 +213,7 @@ path_common_methods = {
214
213
  }
215
214
 
216
215
  default_methods = {
216
+ 'defined': _defined,
217
217
  'io': _io,
218
218
  'reduce': reduce,
219
219
  'chain': chain,
@@ -239,7 +239,7 @@ default_methods = {
239
239
  'tree': _tree,
240
240
  'exists': os.path.exists,
241
241
  'empty': path_is_empty,
242
- 'parent': _parent_dir,
242
+ 'parent': path_parent,
243
243
  'abs': normal_path,
244
244
  'rel': os.path.relpath,
245
245
  'cr': come_real_path,
@@ -300,11 +300,18 @@ default_methods = {
300
300
 
301
301
  'me': lambda x: x,
302
302
  'first': lambda x, default=None: next(iter(x), default),
303
+
303
304
  'true': lambda x=True: _is_true(x),
304
305
  'false': lambda x=False: not _is_true(x),
305
306
 
306
- 'equal': lambda x, y: x == y,
307
- 'notequal': lambda x, y: x != y,
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
+
308
315
  'beep': lambda x=True: sound_notify(x),
309
316
 
310
317
  'invoke': lambda __placeholder__filepath, *args, **kwargs: InvokeMarker.execute_file(
@@ -11,6 +11,7 @@ cmd_call_prefix_simple = '>'
11
11
  cmd_call_prefix = cmd_call_prefix_simple * 2
12
12
  cmd_call_prefix_chain = '*'
13
13
  cmd_call_eval_prefix = '='
14
+ cmd_call_eval_trans_prefix = cmd_call_eval_prefix + ':'
14
15
  cmd_call_eval_escape = '\\'
15
16
 
16
17
 
@@ -268,7 +269,10 @@ class MarkerBase:
268
269
  value = f(*value)
269
270
  return value
270
271
  else:
271
- if expression.startswith(cmd_call_eval_prefix):
272
+ if expression.startswith(cmd_call_eval_trans_prefix):
273
+ expression = expression[len(cmd_call_eval_trans_prefix):]
274
+ expression = cls.translate_case(context, expression, True)
275
+ elif expression.startswith(cmd_call_eval_prefix):
272
276
  expression = expression[len(cmd_call_eval_prefix):]
273
277
  return cls.eval(context, expression)
274
278
 
@@ -1,10 +1,10 @@
1
1
  from .base import MarkerBase, MarkerWithEnd, MarkerNoTranslator, cmd_call_prefix_simple, \
2
- cmd_call_prefix_chain
2
+ cmd_call_prefix_chain, cmd_call_eval_prefix, cmd_call_eval_trans_prefix
3
3
  from .empty import EmptyMarker
4
4
 
5
5
 
6
6
  class ExecMarker(MarkerNoTranslator):
7
- tag_head = '='
7
+ tag_head = cmd_call_eval_prefix
8
8
 
9
9
  def execute(self, context, command, marker_node, marker_set):
10
10
  args = self.split_raw(command, 1, self.tag_head)
@@ -13,7 +13,7 @@ class ExecMarker(MarkerNoTranslator):
13
13
 
14
14
 
15
15
  class ExecTranslatorMarker(MarkerBase):
16
- tag_head = '=:'
16
+ tag_head = cmd_call_eval_trans_prefix
17
17
 
18
18
  def execute(self, context, command, marker_node, marker_set):
19
19
  args = self.split_raw(command, 1, self.tag_head)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dekshell
3
- Version: 0.2.23
3
+ Version: 0.2.25
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.23.dist-info/METADATA,sha256=-yW7n04nStm4XlwzlCpJAdpY7BLC3qG0Gg2pTgJzmWs,573
2
- dekshell-0.2.23.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
- dekshell-0.2.23.dist-info/entry_points.txt,sha256=d-kbfULiUTZWIBBsrQF3J_-wESncF-4K2rwHT08grlI,75
1
+ dekshell-0.2.25.dist-info/METADATA,sha256=UFqA_plZ8cNmlxdtBwbPzo7pnm2a8FZ91rk5IyuUfHg,573
2
+ dekshell-0.2.25.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
3
+ dekshell-0.2.25.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
7
7
  dekshell/core/__init__.py,sha256=w-IeR-tO61Mv4ubZyw9LvyagudyD8SXH0YD3yKApNXk,5405
8
8
  dekshell/core/contexts/__init__.py,sha256=ynsfv37azOKfI2UKd0iPl2M6iBW-k5cb1BqSLOWuJpI,482
9
- dekshell/core/contexts/methods.py,sha256=J1xYu469PCDiCHcktBzERn_ankONavPmJVYerFBVjzQ,9499
9
+ dekshell/core/contexts/methods.py,sha256=7z2c0kHY5ktMiMje4fCueAHWhl4sWsjQVivSD8OSNaQ,9707
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=Rcc77ToE4cFlJvGwezRez4nAcfbdzgAhDRHaew5wvk0,13456
12
+ dekshell/core/markers/base/__init__.py,sha256=DDYlAIiVwmXCv4PiH042FRTwxn6Wxdnt0PsV_BSbYaY,13729
13
13
  dekshell/core/markers/base/core.py,sha256=ztB28fDPeqUkXCHchxjU2JO7R1klp_iUj2d6e8IlGCA,11567
14
14
  dekshell/core/markers/base/shell.py,sha256=DhaekMMTuABYP4GyZA05eejFfgxb1lQBwI88dlFv90E,479
15
15
  dekshell/core/markers/commands.py,sha256=mDRj4dSfKbDaZ_ts4lPXd6wftvGFI4VKkRoIzxV7otA,1696
@@ -18,7 +18,7 @@ dekshell/core/markers/define.py,sha256=LpMSfz9ziXq2aFJ6oMpUFFo93TpBx7GxKYNzCeht4
18
18
  dekshell/core/markers/echo.py,sha256=1H61qQbY9tZnrKsdTI_shTmDY5ZaSGipDuBSRptAuZw,660
19
19
  dekshell/core/markers/empty.py,sha256=pWKsHlrp6uXWU6blqOs0IgN_3kYm1OmDQiKGPERabAo,79
20
20
  dekshell/core/markers/env.py,sha256=6ZtiMNdKFbGR_DBjG6C7A8L_lJsiymN5Y5AbnTzyMrE,1158
21
- dekshell/core/markers/exec.py,sha256=CiDqcwY4T1kMFNwSXTniJZezv4Qa_rA09ieFP5VJhiA,2616
21
+ dekshell/core/markers/exec.py,sha256=4_7FRUEgbAtt0_9r8TmOar_Zi6VXxe6E7p3RL6sVgQg,2705
22
22
  dekshell/core/markers/for_.py,sha256=uNOEwyDsjffttEBtUYasdlj7FP_sGnQzWuTV5d5esHY,2142
23
23
  dekshell/core/markers/function.py,sha256=RPh56_rYbWXCTkNPiJu8zNEj-OE6txKgEw7Im9fBM3c,3592
24
24
  dekshell/core/markers/if_.py,sha256=bBG1fDCZd5alE5FSm0QhgHl6ZJn5awiqZAXnPnO-thc,1112
@@ -37,4 +37,4 @@ dekshell/utils/cmd.py,sha256=FfWNRRRdiiTs3xoXvaAyZ-3OzsWFRnd3m5k6sIexrhc,1209
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.23.dist-info/RECORD,,
40
+ dekshell-0.2.25.dist-info/RECORD,,