zrb 0.0.72__py3-none-any.whl → 0.0.73__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.
- zrb/task/base_task.py +36 -20
- zrb/task/docker_compose_task.py +1 -1
- {zrb-0.0.72.dist-info → zrb-0.0.73.dist-info}/METADATA +1 -1
- {zrb-0.0.72.dist-info → zrb-0.0.73.dist-info}/RECORD +7 -7
- {zrb-0.0.72.dist-info → zrb-0.0.73.dist-info}/LICENSE +0 -0
- {zrb-0.0.72.dist-info → zrb-0.0.73.dist-info}/WHEEL +0 -0
- {zrb-0.0.72.dist-info → zrb-0.0.73.dist-info}/entry_points.txt +0 -0
zrb/task/base_task.py
CHANGED
@@ -344,56 +344,70 @@ class TaskModel(
|
|
344
344
|
if override or key not in self._env_map:
|
345
345
|
self._env_map[key] = val
|
346
346
|
|
347
|
-
def render_any(
|
347
|
+
def render_any(
|
348
|
+
self, val: Any, data: Optional[Mapping[str, Any]] = None
|
349
|
+
) -> Any:
|
348
350
|
if isinstance(val, str):
|
349
|
-
return self.render_str(val)
|
351
|
+
return self.render_str(val, data)
|
350
352
|
return val
|
351
353
|
|
352
|
-
def render_float(
|
354
|
+
def render_float(
|
355
|
+
self, val: Union[str, float], data: Optional[Mapping[str, Any]] = None
|
356
|
+
) -> float:
|
353
357
|
if isinstance(val, str):
|
354
|
-
return float(self.render_str(val))
|
358
|
+
return float(self.render_str(val, data))
|
355
359
|
return val
|
356
360
|
|
357
|
-
def render_int(
|
361
|
+
def render_int(
|
362
|
+
self, val: Union[str, int], data: Optional[Mapping[str, Any]] = None
|
363
|
+
) -> int:
|
358
364
|
if isinstance(val, str):
|
359
|
-
return int(self.render_str(val))
|
365
|
+
return int(self.render_str(val, data))
|
360
366
|
return val
|
361
367
|
|
362
|
-
def render_bool(
|
368
|
+
def render_bool(
|
369
|
+
self, val: Union[str, bool], data: Optional[Mapping[str, Any]] = None
|
370
|
+
) -> bool:
|
363
371
|
if isinstance(val, str):
|
364
|
-
return to_boolean(self.render_str(val))
|
372
|
+
return to_boolean(self.render_str(val, data))
|
365
373
|
return val
|
366
374
|
|
367
|
-
def render_str(
|
375
|
+
def render_str(
|
376
|
+
self, val: str, data: Optional[Mapping[str, Any]] = None
|
377
|
+
) -> str:
|
368
378
|
if val in self._rendered_str:
|
369
379
|
return self._rendered_str[val]
|
370
380
|
if not is_probably_jinja(val):
|
371
381
|
return val
|
372
382
|
template = jinja2.Template(val)
|
373
|
-
|
374
|
-
self.log_debug(f'Render string
|
383
|
+
render_data = self._get_render_data(additional_data=data)
|
384
|
+
self.log_debug(f'Render string: {val}, with data: {render_data}')
|
375
385
|
try:
|
376
|
-
rendered_text = template.render(
|
386
|
+
rendered_text = template.render(render_data)
|
377
387
|
self.log_debug(f'Get rendered result: {rendered_text}')
|
378
388
|
except Exception:
|
379
|
-
raise Exception(f'Fail to render "{val}" with data: {
|
389
|
+
raise Exception(f'Fail to render "{val}" with data: {render_data}')
|
380
390
|
self._rendered_str[val] = rendered_text
|
381
391
|
return rendered_text
|
382
392
|
|
383
|
-
def render_file(
|
393
|
+
def render_file(
|
394
|
+
self, location: str, data: Optional[Mapping[str, Any]] = None
|
395
|
+
) -> str:
|
384
396
|
location_dir = os.path.dirname(location)
|
385
397
|
env = jinja2.Environment(
|
386
398
|
loader=AnyExtensionFileSystemLoader([location_dir])
|
387
399
|
)
|
388
400
|
template = env.get_template(location)
|
389
|
-
|
390
|
-
|
391
|
-
self.log_debug(f'Render template
|
392
|
-
rendered_text = template.render(
|
401
|
+
render_data = self._get_render_data(additional_data=data)
|
402
|
+
render_data['TEMPLATE_DIR'] = location_dir
|
403
|
+
self.log_debug(f'Render template: {template} with data: {render_data}')
|
404
|
+
rendered_text = template.render(render_data)
|
393
405
|
self.log_debug(f'Get rendered result: {rendered_text}')
|
394
406
|
return rendered_text
|
395
407
|
|
396
|
-
def _get_render_data(
|
408
|
+
def _get_render_data(
|
409
|
+
self, additional_data: Optional[Mapping[str, Any]] = None
|
410
|
+
) -> Mapping[str, Any]:
|
397
411
|
if self._render_data is not None:
|
398
412
|
return self._render_data
|
399
413
|
render_data = dict(DEFAULT_RENDER_DATA)
|
@@ -401,6 +415,8 @@ class TaskModel(
|
|
401
415
|
'env': self._env_map,
|
402
416
|
'input': self._input_map,
|
403
417
|
})
|
418
|
+
if additional_data is not None:
|
419
|
+
render_data.update(additional_data)
|
404
420
|
self._render_data = render_data
|
405
421
|
return render_data
|
406
422
|
|
@@ -565,7 +581,7 @@ class BaseTask(TaskModel):
|
|
565
581
|
|
566
582
|
def get_upstreams(self) -> Iterable[TTask]:
|
567
583
|
return self._upstreams
|
568
|
-
|
584
|
+
|
569
585
|
def add_upstreams(self, *upstreams: TTask):
|
570
586
|
if not self._can_add_upstream:
|
571
587
|
raise Exception(f'Cannot add upstreams on `{self._name}`')
|
zrb/task/docker_compose_task.py
CHANGED
@@ -618,10 +618,10 @@ zrb/helper/string/double_quote.py,sha256=uYIdgotgVvMWxffJhrgb1TQI5v1-QdA0UByE2xG
|
|
618
618
|
zrb/helper/string/jinja.py,sha256=yXX79mYJ-s1wRqGJpms1xKTrZE6Ts_OE_YDLIazrBvI,261
|
619
619
|
zrb/helper/string/parse_replacement.py,sha256=g4GHaZqncBIZyyZrcZJtylz6gySEU18A27S4XPTEDEI,222
|
620
620
|
zrb/task/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
621
|
-
zrb/task/base_task.py,sha256
|
621
|
+
zrb/task/base_task.py,sha256=Cauf0Gaak9a0rpxxwCivSmQBWiAHk7ara4mXxAb3wJE,30625
|
622
622
|
zrb/task/cmd_task.py,sha256=LBCukVTK-1FQG58JHRyyPEeguFl5q-xy27hns7NlvNM,8612
|
623
623
|
zrb/task/decorator.py,sha256=xw2iE_nin5FEOxtkUy-1j1Dr_h4_Iy3VyCX9ngcaFiA,1590
|
624
|
-
zrb/task/docker_compose_task.py,sha256=
|
624
|
+
zrb/task/docker_compose_task.py,sha256=dTJ3d61P235QvGIB3pLwZiZo2LQ1rYYurO8haWc4nTs,10452
|
625
625
|
zrb/task/flow_task.py,sha256=SV8qZ69wQjsqdKYdRO3GeNzV0PKzZpXb-UYppmQnvXg,5101
|
626
626
|
zrb/task/http_checker.py,sha256=POMrs_kswhOPICXE8mxthI2vmHXP1lGw9VRnVlf06xg,4515
|
627
627
|
zrb/task/path_checker.py,sha256=4GaqHVRdk4LHVJOoxs9e9fGXrBP8U7qZMRkcr-LqVZU,2875
|
@@ -640,8 +640,8 @@ zrb/task_input/input.py,sha256=I4KrdJR3muxAWgd8zX6CErogHYcFM80Si0DmC5-YJGE,69
|
|
640
640
|
zrb/task_input/int_input.py,sha256=YTxeRvHGe60hUto3vGtjA3GVLsR2zPtlIca20XO_94A,1568
|
641
641
|
zrb/task_input/password_input.py,sha256=-ygMqy3JoHtZB5aA7uwlwgntFBJKBasfP3eX9iaOxKE,1521
|
642
642
|
zrb/task_input/str_input.py,sha256=RUw5zTUDAo1kyl5kcUpXyk073xh09N04D41PmH76RVk,1568
|
643
|
-
zrb-0.0.
|
644
|
-
zrb-0.0.
|
645
|
-
zrb-0.0.
|
646
|
-
zrb-0.0.
|
647
|
-
zrb-0.0.
|
643
|
+
zrb-0.0.73.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
|
644
|
+
zrb-0.0.73.dist-info/LICENSE,sha256=hVM_U_SOdNZ9mLpaAZ5qn3HRXQXucGX9rliGPEifzVs,1073
|
645
|
+
zrb-0.0.73.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
646
|
+
zrb-0.0.73.dist-info/METADATA,sha256=t8XtpN_RCnKUx_GS9Oa2aChvOP07hCfOpjPz_xFTZTo,8574
|
647
|
+
zrb-0.0.73.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|