dyngle 1.2.0__py3-none-any.whl → 1.3.1__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.

Potentially problematic release.


This version of dyngle might be problematic. Click here for more details.

@@ -130,8 +130,11 @@ def expression(text: str) -> Callable[[dict], str]:
130
130
  def definition(live_data: LiveData | dict | None = None) -> str:
131
131
  """The expression function itself"""
132
132
 
133
- # Allow for blankness and testability
134
- live_data = LiveData(live_data)
133
+ # We only work if passed some data to use - also we don't know our name
134
+ # so can't report it.
135
+
136
+ if live_data is None:
137
+ raise DyngleError('Expression called with no argument')
135
138
 
136
139
  # Translate names to underscore-separated instead of hyphen-separated
137
140
  # so they work within the Python namespace.
@@ -140,11 +143,17 @@ def expression(text: str) -> Callable[[dict], str]:
140
143
  locals = LiveData({k.replace('-', '_'): v for k, v in items})
141
144
 
142
145
  # Create a resolve function which allows references using the hyphen
143
- # syntax too
146
+ # syntax too - note it relies on the original live_data object (not the
147
+ # locals with the key replacement). We're converting it to LiveData in
148
+ # case for some reason we were passed a raw dict.
149
+
150
+ live_data = LiveData(live_data)
144
151
 
145
152
  def resolve(key):
146
153
  return live_data.resolve(key, str_only=False)
147
- locals = locals | {'resolve': resolve}
154
+
155
+ # Passing the live_data in again allows function(data) in expressions
156
+ locals = locals | {'resolve': resolve, 'data': live_data}
148
157
 
149
158
  # Perform the Python eval, expanded above
150
159
  return _evaluate(text, locals)
dyngle/model/live_data.py CHANGED
@@ -5,6 +5,7 @@ from numbers import Number
5
5
  from yaml import safe_dump
6
6
 
7
7
  from dyngle.error import DyngleError
8
+ from dyngle.model.safe_path import SafePath
8
9
 
9
10
 
10
11
  class LiveData(UserDict):
@@ -27,7 +28,7 @@ class LiveData(UserDict):
27
28
  def _stringify(value) -> str:
28
29
  if isinstance(value, bool):
29
30
  return '.' if value is True else ''
30
- elif isinstance(value, (Number, str, date, timedelta)):
31
+ elif isinstance(value, (Number, str, date, timedelta, SafePath)):
31
32
  return str(value)
32
33
  elif isinstance(value, (list, dict, tuple)):
33
34
  return safe_dump(value)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dyngle
3
- Version: 1.2.0
3
+ Version: 1.3.1
4
4
  Summary: Run lightweight local workflows
5
5
  License: MIT
6
6
  Author: Steampunk Wizard
@@ -4,12 +4,12 @@ dyngle/command/__init__.py,sha256=1S86gbef8MYvG-TWD5JRIWzFg7qV5xKhp9QXx9zEx5c,94
4
4
  dyngle/command/run_command.py,sha256=gYTQjATRMu_81HLP-hrMz7GNw9Lcz2VjuhP7h_qYLcE,1514
5
5
  dyngle/error.py,sha256=CGcTa8L4O1qsHEYnzp_JBbkvntJTv2Qz46wj_TI8NLk,39
6
6
  dyngle/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- dyngle/model/expression.py,sha256=9nwfahjOHtScjdDzjwWIleo60lJjtXGrPGfroCbslvg,4431
8
- dyngle/model/live_data.py,sha256=yWiTgb9w9KaJ2yynGEudfu89Z3hOoHcLdUXfEJRtZG4,1197
7
+ dyngle/model/expression.py,sha256=XvHlWqnN-4gkN4ck5iTuwP3OqXXbRzTwIRTX0lzJAdY,4889
8
+ dyngle/model/live_data.py,sha256=FxbMjfaiBIUorEbhRx5I0o-WAFFWdjYaqzw_zhFq86w,1251
9
9
  dyngle/model/operation.py,sha256=nSz-8Eh03xAvQlc6Wzn56t-dMArp9uJWY_8XJJZEIwc,1743
10
10
  dyngle/model/safe_path.py,sha256=Hk2AhP6e3yKGh3kKrLLwhvAlMNx-j2jObBYJL-_doAU,3339
11
11
  dyngle/model/template.py,sha256=MeXu--ZNtj_ujABU1GjjcQ1Ea_o_M-50LocuXFeOLRE,887
12
- dyngle-1.2.0.dist-info/METADATA,sha256=0jg6HNybNbzJZZRr6-hEUDDMhHJVDNVrLdBZ3m8P7kA,9710
13
- dyngle-1.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
14
- dyngle-1.2.0.dist-info/entry_points.txt,sha256=rekiGhtweiHKm9g1jdGb3FhzqDrk1kigJDeSNollZSA,48
15
- dyngle-1.2.0.dist-info/RECORD,,
12
+ dyngle-1.3.1.dist-info/METADATA,sha256=4LWgQs_wTqwVRx-xPyNh8M3I8K2I6lRPUHiuR0t0qLw,9710
13
+ dyngle-1.3.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
14
+ dyngle-1.3.1.dist-info/entry_points.txt,sha256=rekiGhtweiHKm9g1jdGb3FhzqDrk1kigJDeSNollZSA,48
15
+ dyngle-1.3.1.dist-info/RECORD,,
File without changes