zrb 0.0.86__py3-none-any.whl → 0.0.88__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/__init__.py +3 -1
- zrb/action/runner.py +7 -3
- zrb/builtin/__init__.py +1 -1
- zrb/builtin/base64.py +1 -1
- zrb/builtin/devtool/devtool_install.py +13 -4
- zrb/builtin/devtool/helix/install-language-server.sh +33 -0
- zrb/builtin/env.py +6 -3
- zrb/builtin/explain.py +3 -1
- zrb/builtin/generator/__init__.py +4 -8
- zrb/builtin/generator/app_generator/add.py +15 -6
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/add.py +62 -52
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/cmd/app-start.sh +1 -6
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +2 -2
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +4 -2
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/.gitignore +2 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/Dockerfile +10 -5
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/go.work +1 -0
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/main.go +28 -0
- zrb/builtin/generator/cmd_task/add.py +6 -6
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/{_common → common}/helper.py +6 -0
- zrb/builtin/generator/{_common → common}/task_factory.py +9 -5
- zrb/builtin/generator/docker_compose_task/add.py +8 -8
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/fastapp/add.py +24 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_common.py +2 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +3 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +2 -4
- zrb/builtin/generator/fastapp_crud/add.py +8 -121
- zrb/builtin/generator/fastapp_crud/helper.py +115 -0
- zrb/builtin/generator/fastapp_crud/{add_navigation.py → task_factory.py} +5 -3
- zrb/builtin/generator/fastapp_field/add.py +8 -280
- zrb/builtin/generator/fastapp_field/helper.py +283 -0
- zrb/builtin/generator/fastapp_module/add.py +19 -328
- zrb/builtin/generator/fastapp_module/helper.py +326 -0
- zrb/builtin/generator/pip_package/add.py +8 -8
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +1 -1
- zrb/builtin/generator/project/create.py +10 -3
- zrb/builtin/generator/project/template/template.env +1 -1
- zrb/builtin/generator/project_task/task_factory.py +33 -21
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +1 -1
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +1 -1
- zrb/builtin/generator/python_task/add.py +6 -6
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/generator/simple_python_app/add.py +28 -30
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +1 -1
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +1 -1
- zrb/builtin/git.py +1 -1
- zrb/builtin/md5.py +1 -1
- zrb/builtin/project.py +1 -1
- zrb/builtin/ubuntu.py +3 -3
- zrb/config/config.py +8 -6
- zrb/helper/accessories/color.py +5 -1
- zrb/helper/accessories/icon.py +2 -0
- zrb/helper/accessories/name.py +2 -0
- zrb/helper/advertisement.py +1 -0
- zrb/helper/cli.py +5 -1
- zrb/helper/codemod/add_argument_to_function.py +3 -0
- zrb/helper/codemod/add_argument_to_function_call.py +3 -0
- zrb/helper/codemod/add_assert_resource.py +2 -0
- zrb/helper/codemod/add_function_call.py +2 -0
- zrb/helper/codemod/add_import_module.py +3 -0
- zrb/helper/codemod/add_key_value_to_dict.py +2 -0
- zrb/helper/codemod/add_property_to_class.py +3 -0
- zrb/helper/codemod/add_upstream_to_task.py +3 -0
- zrb/helper/codemod/append_code_to_function.py +3 -0
- zrb/helper/codemod/format_code.py +2 -0
- zrb/helper/default_env.py +2 -0
- zrb/helper/docker_compose/fetch_external_env.py +3 -0
- zrb/helper/docker_compose/file.py +4 -0
- zrb/helper/env_map/fetch.py +7 -0
- zrb/helper/file/text.py +4 -0
- zrb/helper/git/detect_changes.py +4 -0
- zrb/helper/loader/load_module.py +2 -0
- zrb/helper/map/conversion.py +2 -0
- zrb/helper/string/conversion.py +5 -0
- zrb/helper/string/double_quote.py +6 -2
- zrb/helper/string/jinja.py +2 -0
- zrb/helper/string/parse_replacement.py +2 -0
- zrb/helper/util.py +13 -0
- zrb/task/any_task.py +2 -2
- zrb/task/base_task.py +15 -15
- zrb/task/base_task_composite.py +3 -3
- zrb/task/cmd_task.py +2 -2
- zrb/task/decorator.py +2 -2
- zrb/task/docker_compose_task.py +2 -2
- zrb/task/flow_task.py +5 -5
- zrb/task/http_checker.py +2 -2
- zrb/task/path_checker.py +2 -2
- zrb/task/port_checker.py +2 -2
- zrb/task/resource_maker.py +3 -5
- zrb/task_input/any_input.py +23 -0
- zrb/task_input/base_input.py +46 -43
- zrb/task_input/float_input.py +0 -1
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/METADATA +1 -1
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/RECORD +118 -114
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/main.py +0 -20
- zrb/builtin/generator/app_generator/template/_automate/snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/src/requirements.txt +0 -1
- zrb/config.toml +0 -0
- /zrb/builtin/generator/{_common → common}/__init__.py +0 -0
- /zrb/builtin/generator/{_common → common}/task_input.py +0 -0
- /zrb/builtin/{_group.py → group.py} +0 -0
- /zrb/task_input/{_constant.py → constant.py} +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/LICENSE +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/WHEEL +0 -0
- {zrb-0.0.86.dist-info → zrb-0.0.88.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,8 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import libcst as cst
|
2
3
|
|
3
4
|
|
5
|
+
@typechecked
|
4
6
|
class AddArgumentTransformer(cst.CSTTransformer):
|
5
7
|
def __init__(
|
6
8
|
self, function_name: str, argument_name: str, argument_type: str
|
@@ -26,6 +28,7 @@ class AddArgumentTransformer(cst.CSTTransformer):
|
|
26
28
|
return updated_node
|
27
29
|
|
28
30
|
|
31
|
+
@typechecked
|
29
32
|
def add_argument_to_function(
|
30
33
|
code: str, function_name: str, argument_name: str, argument_type: str
|
31
34
|
) -> str:
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import libcst as cst
|
2
3
|
|
3
4
|
|
5
|
+
@typechecked
|
4
6
|
class AddArgumentTransformer(cst.CSTTransformer):
|
5
7
|
def __init__(self, function_name: str, argument_name: str):
|
6
8
|
self.function_name = function_name
|
@@ -21,6 +23,7 @@ class AddArgumentTransformer(cst.CSTTransformer):
|
|
21
23
|
return updated_node
|
22
24
|
|
23
25
|
|
26
|
+
@typechecked
|
24
27
|
def add_argument_to_function_call(
|
25
28
|
code: str, function_name: str, argument_name: str
|
26
29
|
) -> str:
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Optional, Union, Tuple
|
2
3
|
import libcst as cst
|
3
4
|
|
4
5
|
|
6
|
+
@typechecked
|
5
7
|
def add_import_module(
|
6
8
|
code: str,
|
7
9
|
module_path: str,
|
@@ -87,6 +89,7 @@ def _get_new_import(
|
|
87
89
|
)
|
88
90
|
|
89
91
|
|
92
|
+
@typechecked
|
90
93
|
def _split_module_path(module_path) -> Tuple[str, str]:
|
91
94
|
prefix = ''
|
92
95
|
suffix = ''
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Optional
|
2
3
|
import libcst as cst
|
3
4
|
|
4
5
|
|
6
|
+
@typechecked
|
5
7
|
class AddPropertyTransformer(cst.CSTTransformer):
|
6
8
|
def __init__(
|
7
9
|
self,
|
@@ -51,6 +53,7 @@ class AddPropertyTransformer(cst.CSTTransformer):
|
|
51
53
|
return updated_node.with_changes(body=new_body)
|
52
54
|
|
53
55
|
|
56
|
+
@typechecked
|
54
57
|
def add_property_to_class(
|
55
58
|
code: str,
|
56
59
|
class_name: str,
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import libcst as cst
|
2
3
|
|
3
4
|
|
5
|
+
@typechecked
|
4
6
|
class TaskTransformer(cst.CSTTransformer):
|
5
7
|
def __init__(self, task_name: str, upstream_task_name: str):
|
6
8
|
super().__init__()
|
@@ -74,6 +76,7 @@ class TaskTransformer(cst.CSTTransformer):
|
|
74
76
|
)
|
75
77
|
|
76
78
|
|
79
|
+
@typechecked
|
77
80
|
def add_upstream_to_task(
|
78
81
|
code: str, task_name: str, upstream_task_name: str
|
79
82
|
) -> str:
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import libcst as cst
|
2
3
|
|
3
4
|
|
5
|
+
@typechecked
|
4
6
|
class AppendCodeTransformer(cst.CSTTransformer):
|
5
7
|
def __init__(self, function_name: str, new_code: str):
|
6
8
|
self.function_name = function_name
|
@@ -20,6 +22,7 @@ class AppendCodeTransformer(cst.CSTTransformer):
|
|
20
22
|
return updated_node
|
21
23
|
|
22
24
|
|
25
|
+
@typechecked
|
23
26
|
def append_code_to_function(
|
24
27
|
code: str, function_name: str, new_code: str
|
25
28
|
) -> str:
|
zrb/helper/default_env.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Optional
|
2
3
|
from .accessories.color import colored
|
3
4
|
from .log import logger
|
@@ -34,6 +35,7 @@ def inject_default_env():
|
|
34
35
|
os.environ['ZRB_PROJECT_NAME'] = zrb_project_name
|
35
36
|
|
36
37
|
|
38
|
+
@typechecked
|
37
39
|
def _get_project_dir(project_dir: str) -> Optional[str]:
|
38
40
|
project_script = os.path.join(project_dir, 'zrb_init.py')
|
39
41
|
if os.path.isfile(project_script):
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Any, List, Mapping
|
2
3
|
|
3
4
|
|
5
|
+
@typechecked
|
4
6
|
def fetch_compose_file_env_map(data: Any) -> Mapping[str, str]:
|
5
7
|
global_env_dict = {}
|
6
8
|
if 'services' not in data:
|
@@ -24,6 +26,7 @@ def fetch_compose_file_env_map(data: Any) -> Mapping[str, str]:
|
|
24
26
|
return global_env_dict
|
25
27
|
|
26
28
|
|
29
|
+
@typechecked
|
27
30
|
def parse_compose_file_env_string(env_str: str) -> Mapping[str, str]:
|
28
31
|
env_dict = {}
|
29
32
|
stack = []
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Any, Mapping
|
2
3
|
from ruamel.yaml import YAML, CommentedMap
|
3
4
|
|
4
5
|
|
6
|
+
@typechecked
|
5
7
|
def read_compose_file(file_name: str) -> Any:
|
6
8
|
yaml = YAML()
|
7
9
|
with open(file_name, 'r') as f:
|
@@ -9,12 +11,14 @@ def read_compose_file(file_name: str) -> Any:
|
|
9
11
|
return data
|
10
12
|
|
11
13
|
|
14
|
+
@typechecked
|
12
15
|
def write_compose_file(file_name: str, data: Any):
|
13
16
|
yaml = YAML()
|
14
17
|
with open(file_name, 'w') as f:
|
15
18
|
yaml.dump(data, f)
|
16
19
|
|
17
20
|
|
21
|
+
@typechecked
|
18
22
|
def add_services(file_name: str, new_services: Mapping[str, str]):
|
19
23
|
data = read_compose_file(file_name)
|
20
24
|
data = CommentedMap(data)
|
zrb/helper/env_map/fetch.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import List, Mapping
|
2
3
|
from ...task_group.group import Group
|
3
4
|
from ...task.any_task import AnyTask
|
@@ -5,6 +6,7 @@ from ...task_env.env import Env
|
|
5
6
|
from ..string.jinja import is_probably_jinja
|
6
7
|
|
7
8
|
|
9
|
+
@typechecked
|
8
10
|
def fetch_env_map_from_group(
|
9
11
|
env_map: Mapping[str, str], group: Group
|
10
12
|
) -> Mapping[str, str]:
|
@@ -18,6 +20,7 @@ def fetch_env_map_from_group(
|
|
18
20
|
return env_map
|
19
21
|
|
20
22
|
|
23
|
+
@typechecked
|
21
24
|
def fetch_env_map_from_task(
|
22
25
|
env_map: Mapping[str, str], task: AnyTask
|
23
26
|
):
|
@@ -34,6 +37,7 @@ def fetch_env_map_from_task(
|
|
34
37
|
return env_map
|
35
38
|
|
36
39
|
|
40
|
+
@typechecked
|
37
41
|
def add_envs_to_env_map(
|
38
42
|
env_map: Mapping[str, str], envs: List[Env]
|
39
43
|
) -> Mapping[str, str]:
|
@@ -46,6 +50,7 @@ def add_envs_to_env_map(
|
|
46
50
|
return env_map
|
47
51
|
|
48
52
|
|
53
|
+
@typechecked
|
49
54
|
def cascade_env_map(
|
50
55
|
env_map: Mapping[str, str],
|
51
56
|
other_env_map: Mapping[str, str]
|
@@ -57,12 +62,14 @@ def cascade_env_map(
|
|
57
62
|
return env_map
|
58
63
|
|
59
64
|
|
65
|
+
@typechecked
|
60
66
|
def get_env_name(env: Env) -> str:
|
61
67
|
if env.os_name is None:
|
62
68
|
return env.name
|
63
69
|
return env.os_name
|
64
70
|
|
65
71
|
|
72
|
+
@typechecked
|
66
73
|
def get_env_default(env: Env) -> str:
|
67
74
|
if is_probably_jinja(env.default):
|
68
75
|
return ''
|
zrb/helper/file/text.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import aiofiles
|
2
3
|
import os
|
3
4
|
|
4
5
|
|
6
|
+
@typechecked
|
5
7
|
async def read_text_file_async(file_name: str) -> str:
|
6
8
|
async with aiofiles.open(file_name, mode='r') as file:
|
7
9
|
content = await file.read()
|
8
10
|
return content
|
9
11
|
|
10
12
|
|
13
|
+
@typechecked
|
11
14
|
async def write_text_file_async(file_name: str, content: str):
|
12
15
|
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
13
16
|
async with aiofiles.open(file_name, mode='w') as file:
|
14
17
|
await file.write(content)
|
15
18
|
|
16
19
|
|
20
|
+
@typechecked
|
17
21
|
async def append_text_file_async(file_name: str, additional_content: str):
|
18
22
|
content = await read_text_file_async(file_name)
|
19
23
|
if content != '':
|
zrb/helper/git/detect_changes.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Mapping
|
2
3
|
import subprocess
|
3
4
|
|
5
|
+
|
6
|
+
@typechecked
|
4
7
|
class ModificationState():
|
5
8
|
def __init__(self):
|
6
9
|
self.plus: bool = False
|
7
10
|
self.minus: bool = False
|
8
11
|
|
9
12
|
|
13
|
+
@typechecked
|
10
14
|
def get_modified_files(commit: str) -> Mapping[str, ModificationState]:
|
11
15
|
exit_status, output = subprocess.getstatusoutput(f'git show {commit}')
|
12
16
|
if exit_status != 0:
|
zrb/helper/loader/load_module.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from ..log import logger
|
2
3
|
from ..accessories.color import colored
|
3
4
|
|
@@ -8,6 +9,7 @@ import re
|
|
8
9
|
pattern = re.compile('[^a-zA-Z0-9]')
|
9
10
|
|
10
11
|
|
12
|
+
@typechecked
|
11
13
|
def load_module(script_path: str):
|
12
14
|
if not os.path.isfile(script_path):
|
13
15
|
return
|
zrb/helper/map/conversion.py
CHANGED
zrb/helper/string/conversion.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
import keyword
|
2
3
|
import logging
|
3
4
|
import re
|
@@ -16,10 +17,12 @@ LOGGING_LEVEL_MAP = {
|
|
16
17
|
}
|
17
18
|
|
18
19
|
|
20
|
+
@typechecked
|
19
21
|
def to_cmd_name(name: str) -> str:
|
20
22
|
return NON_WORD.sub('-', name).strip('-').lower()
|
21
23
|
|
22
24
|
|
25
|
+
@typechecked
|
23
26
|
def to_variable_name(string: str) -> str:
|
24
27
|
# Replace any non-word characters with underscore
|
25
28
|
string = NON_WORD.sub('_', string).strip()
|
@@ -32,6 +35,7 @@ def to_variable_name(string: str) -> str:
|
|
32
35
|
return string
|
33
36
|
|
34
37
|
|
38
|
+
@typechecked
|
35
39
|
def to_boolean(string: str) -> bool:
|
36
40
|
if string.lower() in ['true', '1', 'yes', 'y', 'active']:
|
37
41
|
return True
|
@@ -40,6 +44,7 @@ def to_boolean(string: str) -> bool:
|
|
40
44
|
raise Exception(f'Cannot infer boolean value from "{string}"')
|
41
45
|
|
42
46
|
|
47
|
+
@typechecked
|
43
48
|
def to_logging_level(logging_level_str: str) -> int:
|
44
49
|
lower_logging_level_str = logging_level_str.lower()
|
45
50
|
if lower_logging_level_str in LOGGING_LEVEL_MAP:
|
zrb/helper/string/jinja.py
CHANGED
zrb/helper/util.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
from typeguard import typechecked
|
1
2
|
from typing import Any, Optional
|
2
3
|
from .string.conversion import to_boolean as conversion_to_boolean
|
3
4
|
import re
|
@@ -6,10 +7,12 @@ import jinja2
|
|
6
7
|
NON_ALPHA_NUM = re.compile(r'[^a-zA-Z0-9]+')
|
7
8
|
|
8
9
|
|
10
|
+
@typechecked
|
9
11
|
def _is_undefined(value: Any) -> bool:
|
10
12
|
return value is None or isinstance(value, jinja2.Undefined)
|
11
13
|
|
12
14
|
|
15
|
+
@typechecked
|
13
16
|
def coalesce(value: Any, *alternatives: Any) -> Any:
|
14
17
|
if not _is_undefined(value):
|
15
18
|
return value
|
@@ -19,6 +22,7 @@ def coalesce(value: Any, *alternatives: Any) -> Any:
|
|
19
22
|
return None
|
20
23
|
|
21
24
|
|
25
|
+
@typechecked
|
22
26
|
def coalesce_str(value: Any, *alternatives: Any) -> Any:
|
23
27
|
if not _is_undefined(value) and value != '':
|
24
28
|
return str(value)
|
@@ -28,6 +32,7 @@ def coalesce_str(value: Any, *alternatives: Any) -> Any:
|
|
28
32
|
return ''
|
29
33
|
|
30
34
|
|
35
|
+
@typechecked
|
31
36
|
def to_camel_case(text: Optional[str]) -> str:
|
32
37
|
text = str(text) if not _is_undefined(text) else ''
|
33
38
|
pascal = to_pascal_case(text)
|
@@ -36,6 +41,7 @@ def to_camel_case(text: Optional[str]) -> str:
|
|
36
41
|
return pascal[0].lower() + pascal[1:]
|
37
42
|
|
38
43
|
|
44
|
+
@typechecked
|
39
45
|
def to_pascal_case(text: Optional[str]) -> str:
|
40
46
|
text = str(text) if not _is_undefined(text) else ''
|
41
47
|
text = _to_alphanum(text)
|
@@ -44,6 +50,7 @@ def to_pascal_case(text: Optional[str]) -> str:
|
|
44
50
|
])
|
45
51
|
|
46
52
|
|
53
|
+
@typechecked
|
47
54
|
def to_kebab_case(text: Optional[str]) -> str:
|
48
55
|
text = str(text) if not _is_undefined(text) else ''
|
49
56
|
text = _to_alphanum(text)
|
@@ -52,6 +59,7 @@ def to_kebab_case(text: Optional[str]) -> str:
|
|
52
59
|
])
|
53
60
|
|
54
61
|
|
62
|
+
@typechecked
|
55
63
|
def to_snake_case(text: Optional[str]) -> str:
|
56
64
|
text = str(text) if not _is_undefined(text) else ''
|
57
65
|
text = _to_alphanum(text)
|
@@ -60,11 +68,13 @@ def to_snake_case(text: Optional[str]) -> str:
|
|
60
68
|
])
|
61
69
|
|
62
70
|
|
71
|
+
@typechecked
|
63
72
|
def _to_alphanum(text: Optional[str]) -> str:
|
64
73
|
text = str(text) if not _is_undefined(text) else ''
|
65
74
|
return NON_ALPHA_NUM.sub(' ', text)
|
66
75
|
|
67
76
|
|
77
|
+
@typechecked
|
68
78
|
def to_human_readable(text: Optional[str]) -> str:
|
69
79
|
text = str(text) if not _is_undefined(text) else ''
|
70
80
|
return ' '.join([
|
@@ -73,10 +83,12 @@ def to_human_readable(text: Optional[str]) -> str:
|
|
73
83
|
])
|
74
84
|
|
75
85
|
|
86
|
+
@typechecked
|
76
87
|
def to_capitalized_human_readable(text: Optional[str]) -> str:
|
77
88
|
return to_human_readable(text).capitalize()
|
78
89
|
|
79
90
|
|
91
|
+
@typechecked
|
80
92
|
def _to_space_separated(text: Optional[str]) -> str:
|
81
93
|
text = str(text) if not _is_undefined(text) else ''
|
82
94
|
text = text.replace('-', ' ').replace('_', ' ')
|
@@ -102,5 +114,6 @@ def _to_space_separated(text: Optional[str]) -> str:
|
|
102
114
|
return ' '.join(new_parts).strip(' ')
|
103
115
|
|
104
116
|
|
117
|
+
@typechecked
|
105
118
|
def to_boolean(text: str) -> bool:
|
106
119
|
return conversion_to_boolean(text)
|
zrb/task/any_task.py
CHANGED
@@ -4,7 +4,7 @@ from typing import (
|
|
4
4
|
from abc import ABC, abstractmethod
|
5
5
|
from ..task_env.env_file import EnvFile
|
6
6
|
from ..task_env.env import Env
|
7
|
-
from ..task_input.
|
7
|
+
from ..task_input.any_input import AnyInput
|
8
8
|
|
9
9
|
TAnyTask = TypeVar('TAnyTask', bound='AnyTask')
|
10
10
|
|
@@ -69,7 +69,7 @@ class AnyTask(ABC):
|
|
69
69
|
pass
|
70
70
|
|
71
71
|
@abstractmethod
|
72
|
-
def get_all_inputs(self) -> Iterable[
|
72
|
+
def get_all_inputs(self) -> Iterable[AnyInput]:
|
73
73
|
pass
|
74
74
|
|
75
75
|
@abstractmethod
|
zrb/task/base_task.py
CHANGED
@@ -8,8 +8,8 @@ from ..advertisement import advertisements
|
|
8
8
|
from ..task_group.group import Group
|
9
9
|
from ..task_env.env import Env
|
10
10
|
from ..task_env.env_file import EnvFile
|
11
|
-
from ..task_input.
|
12
|
-
from ..task_input.
|
11
|
+
from ..task_input.any_input import AnyInput
|
12
|
+
from ..task_input.constant import RESERVED_INPUT_NAMES
|
13
13
|
from ..helper.accessories.color import colored
|
14
14
|
from ..helper.advertisement import get_advertisement
|
15
15
|
from ..helper.string.double_quote import double_quote
|
@@ -40,7 +40,7 @@ class BaseTask(
|
|
40
40
|
name: str,
|
41
41
|
group: Optional[Group] = None,
|
42
42
|
description: str = '',
|
43
|
-
inputs: List[
|
43
|
+
inputs: List[AnyInput] = [],
|
44
44
|
envs: Iterable[Env] = [],
|
45
45
|
env_files: Iterable[EnvFile] = [],
|
46
46
|
icon: Optional[str] = None,
|
@@ -81,7 +81,7 @@ class BaseTask(
|
|
81
81
|
)
|
82
82
|
# init private properties
|
83
83
|
self._is_keyval_set = False # Flag
|
84
|
-
self._all_inputs: Optional[List[
|
84
|
+
self._all_inputs: Optional[List[AnyInput]] = None
|
85
85
|
self._is_check_triggered: bool = False
|
86
86
|
self._is_ready: bool = False
|
87
87
|
self._is_execution_triggered: bool = False
|
@@ -90,29 +90,29 @@ class BaseTask(
|
|
90
90
|
self._kwargs: Mapping[str, Any] = {}
|
91
91
|
self._allow_add_upstream: bool = True
|
92
92
|
|
93
|
-
def get_all_inputs(self) -> Iterable[
|
93
|
+
def get_all_inputs(self) -> Iterable[AnyInput]:
|
94
94
|
''''
|
95
95
|
Getting all inputs of this task and all its upstream, non-duplicated.
|
96
96
|
'''
|
97
97
|
if self._all_inputs is not None:
|
98
98
|
return self._all_inputs
|
99
99
|
self._allow_add_upstream = False
|
100
|
-
self._all_inputs: List[
|
100
|
+
self._all_inputs: List[AnyInput] = []
|
101
101
|
existing_input_names: Mapping[str, bool] = {}
|
102
102
|
# Add task inputs
|
103
103
|
for task_input in self._inputs:
|
104
|
-
if task_input.
|
104
|
+
if task_input.get_name() in existing_input_names:
|
105
105
|
continue
|
106
106
|
self._all_inputs.append(task_input)
|
107
|
-
existing_input_names[task_input.
|
107
|
+
existing_input_names[task_input.get_name()] = True
|
108
108
|
# Add upstream inputs
|
109
109
|
for upstream in self._upstreams:
|
110
110
|
upstream_inputs = upstream.get_all_inputs()
|
111
111
|
for upstream_input in upstream_inputs:
|
112
|
-
if upstream_input.
|
112
|
+
if upstream_input.get_name() in existing_input_names:
|
113
113
|
continue
|
114
114
|
self._all_inputs.append(upstream_input)
|
115
|
-
existing_input_names[upstream_input.
|
115
|
+
existing_input_names[upstream_input.get_name()] = True
|
116
116
|
return self._all_inputs
|
117
117
|
|
118
118
|
def to_function(
|
@@ -193,9 +193,9 @@ class BaseTask(
|
|
193
193
|
self._is_keyval_set = True
|
194
194
|
self.log_info('Set input map')
|
195
195
|
for task_input in self.get_all_inputs():
|
196
|
-
input_name = self._get_normalized_input_key(task_input.
|
196
|
+
input_name = self._get_normalized_input_key(task_input.get_name())
|
197
197
|
input_value = self.render_any(
|
198
|
-
kwargs.get(input_name, task_input.
|
198
|
+
kwargs.get(input_name, task_input.get_default())
|
199
199
|
)
|
200
200
|
self._set_input_map(input_name, input_value)
|
201
201
|
self.log_debug(
|
@@ -298,7 +298,7 @@ class BaseTask(
|
|
298
298
|
def _show_run_command(self):
|
299
299
|
params: List[str] = [double_quote(arg) for arg in self._args]
|
300
300
|
for task_input in self.get_all_inputs():
|
301
|
-
key = task_input.
|
301
|
+
key = task_input.get_name()
|
302
302
|
kwarg_key = self._get_normalized_input_key(key)
|
303
303
|
quoted_value = double_quote(str(self._kwargs[kwarg_key]))
|
304
304
|
params.append(f'--{key} {quoted_value}')
|
@@ -420,10 +420,10 @@ class BaseTask(
|
|
420
420
|
async def _set_keyval(self, kwargs: Mapping[str, Any], env_prefix: str):
|
421
421
|
# if input is not in input_map, add default values
|
422
422
|
for task_input in self.get_all_inputs():
|
423
|
-
key = self._get_normalized_input_key(task_input.
|
423
|
+
key = self._get_normalized_input_key(task_input.get_name())
|
424
424
|
if key in kwargs:
|
425
425
|
continue
|
426
|
-
kwargs[key] = task_input.
|
426
|
+
kwargs[key] = task_input.get_default()
|
427
427
|
# set current task local keyval
|
428
428
|
await self._set_local_keyval(kwargs=kwargs, env_prefix=env_prefix)
|
429
429
|
# get new_kwargs for upstream and checkers
|
zrb/task/base_task_composite.py
CHANGED
@@ -8,7 +8,7 @@ from ..helper.log import logger
|
|
8
8
|
from ..helper.accessories.color import colored, get_random_color
|
9
9
|
from ..helper.accessories.icon import get_random_icon
|
10
10
|
from ..helper.util import coalesce_str
|
11
|
-
from ..task_input.
|
11
|
+
from ..task_input.any_input import AnyInput
|
12
12
|
from ..task_group.group import Group
|
13
13
|
from ..task_env.env import Env
|
14
14
|
from ..task_env.env_file import EnvFile
|
@@ -30,7 +30,7 @@ class CommonTaskModel():
|
|
30
30
|
name: str,
|
31
31
|
group: Optional[Group] = None,
|
32
32
|
description: str = '',
|
33
|
-
inputs: List[
|
33
|
+
inputs: List[AnyInput] = [],
|
34
34
|
envs: Iterable[Env] = [],
|
35
35
|
env_files: Iterable[EnvFile] = [],
|
36
36
|
icon: Optional[str] = None,
|
@@ -288,7 +288,7 @@ class TaskModelWithPrinterAndTracker(
|
|
288
288
|
name: str,
|
289
289
|
group: Optional[Group] = None,
|
290
290
|
description: str = '',
|
291
|
-
inputs: List[
|
291
|
+
inputs: List[AnyInput] = [],
|
292
292
|
envs: Iterable[Env] = [],
|
293
293
|
env_files: Iterable[EnvFile] = [],
|
294
294
|
icon: Optional[str] = None,
|
zrb/task/cmd_task.py
CHANGED
@@ -5,7 +5,7 @@ from .base_task import BaseTask
|
|
5
5
|
from ..task_env.env import Env
|
6
6
|
from ..task_env.env_file import EnvFile
|
7
7
|
from ..task_group.group import Group
|
8
|
-
from ..task_input.
|
8
|
+
from ..task_input.any_input import AnyInput
|
9
9
|
from ..config.config import default_shell
|
10
10
|
|
11
11
|
import asyncio
|
@@ -59,7 +59,7 @@ class CmdTask(BaseTask):
|
|
59
59
|
self,
|
60
60
|
name: str,
|
61
61
|
group: Optional[Group] = None,
|
62
|
-
inputs: Iterable[
|
62
|
+
inputs: Iterable[AnyInput] = [],
|
63
63
|
envs: Iterable[Env] = [],
|
64
64
|
env_files: Iterable[EnvFile] = [],
|
65
65
|
icon: Optional[str] = None,
|
zrb/task/decorator.py
CHANGED
@@ -3,7 +3,7 @@ from typing import (
|
|
3
3
|
)
|
4
4
|
from typeguard import typechecked
|
5
5
|
from ..task.any_task import AnyTask
|
6
|
-
from ..task_input.
|
6
|
+
from ..task_input.any_input import AnyInput
|
7
7
|
from ..task_env.env import Env
|
8
8
|
from ..task_env.env_file import EnvFile
|
9
9
|
from ..task_group.group import Group
|
@@ -15,7 +15,7 @@ from .task import Task
|
|
15
15
|
def python_task(
|
16
16
|
name: str,
|
17
17
|
group: Optional[Group] = None,
|
18
|
-
inputs: Iterable[
|
18
|
+
inputs: Iterable[AnyInput] = [],
|
19
19
|
envs: Iterable[Env] = [],
|
20
20
|
env_files: Iterable[EnvFile] = [],
|
21
21
|
icon: Optional[str] = None,
|
zrb/task/docker_compose_task.py
CHANGED
@@ -5,7 +5,7 @@ from .any_task import AnyTask
|
|
5
5
|
from ..task_env.env import Env
|
6
6
|
from ..task_env.env_file import EnvFile
|
7
7
|
from ..task_group.group import Group
|
8
|
-
from ..task_input.
|
8
|
+
from ..task_input.any_input import AnyInput
|
9
9
|
from ..helper.accessories.name import get_random_name
|
10
10
|
from ..helper.string.conversion import to_cmd_name
|
11
11
|
from ..helper.string.double_quote import double_quote
|
@@ -37,7 +37,7 @@ class DockerComposeTask(CmdTask):
|
|
37
37
|
self,
|
38
38
|
name: str,
|
39
39
|
group: Optional[Group] = None,
|
40
|
-
inputs: Iterable[
|
40
|
+
inputs: Iterable[AnyInput] = [],
|
41
41
|
envs: Iterable[Env] = [],
|
42
42
|
env_files: Iterable[EnvFile] = [],
|
43
43
|
icon: Optional[str] = None,
|