zrb 0.24.0__py3-none-any.whl → 0.26.2__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/action/runner.py +8 -5
- zrb/advertisement.py +1 -2
- zrb/builtin/__init__.py +4 -0
- zrb/builtin/base64/decode.py +1 -1
- zrb/builtin/base64/encode.py +1 -1
- zrb/builtin/devtool/install/_helper.py +2 -1
- zrb/builtin/docker/prune.py +11 -3
- zrb/builtin/env/get.py +3 -2
- zrb/builtin/eval.py +2 -1
- zrb/builtin/git/get_file_changes.py +2 -1
- zrb/builtin/md5/hash.py +1 -1
- zrb/builtin/md5/sum.py +1 -1
- zrb/builtin/monorepo/__init__.py +7 -0
- zrb/builtin/monorepo/_common.sh +15 -0
- zrb/builtin/monorepo/_config.py +11 -0
- zrb/builtin/monorepo/_group.py +3 -0
- zrb/builtin/monorepo/_helper.py +140 -0
- zrb/builtin/monorepo/_task.py +126 -0
- zrb/builtin/monorepo/add-subrepo.sh +22 -0
- zrb/builtin/monorepo/add.py +48 -0
- zrb/builtin/monorepo/pull-monorepo.sh +18 -0
- zrb/builtin/monorepo/pull-subrepo.sh +18 -0
- zrb/builtin/monorepo/pull.py +24 -0
- zrb/builtin/monorepo/push-monorepo.sh +18 -0
- zrb/builtin/monorepo/push-subrepo.sh +18 -0
- zrb/builtin/monorepo/push.py +24 -0
- zrb/builtin/project/_helper.py +3 -3
- zrb/builtin/project/_input.py +2 -2
- zrb/builtin/project/add/app/generator/generator.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/snake_zrb_generator_name.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/app/python/python.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +1 -1
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
- zrb/builtin/project/add/app/python/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/fastapp/app/app.py +3 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_service_config.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/_helper.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/stop.py +2 -0
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/_helper.py +5 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build-once.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build.sh +1 -1
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/_helper.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/start.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/{start_microservices.py → start_services.py} +2 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/.generator-version +1 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/_common.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/app_helper.py +5 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/docker-compose.yml +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/error.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/consumer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/messagebus.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/mock.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/admin.py +4 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/consumer.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/model/repo_model.py +3 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/db_repo.py +7 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/repo.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/search_filter.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/caller.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/server.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/serializer/serializer.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +3 -4
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/package-lock.json +4443 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/helper/async_task.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/scheme.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/util.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +3 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +3 -5
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +5 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +1 -1
- zrb/builtin/project/add/fastapp/crud/_task_factory.py +1 -2
- zrb/builtin/project/add/fastapp/crud/crud.py +1 -1
- zrb/builtin/project/add/fastapp/crud/nodejs/codemod/package-lock.json +3 -3
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +2 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +2 -2
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +1 -1
- zrb/builtin/project/add/fastapp/field/field.py +1 -1
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +7 -8
- zrb/builtin/project/add/fastapp/module/module.py +1 -1
- zrb/builtin/project/add/plugin/plugin.py +1 -1
- zrb/builtin/project/add/project_task/add.py +1 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/remove.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/start.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/container/stop.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/deploy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/destroy.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/get_env.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/build.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/image/push.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/publish.py +2 -1
- zrb/builtin/project/add/project_task/template/_automate/_project/start.py +2 -1
- zrb/builtin/project/add/task/cmd/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/add.py +1 -1
- zrb/builtin/project/add/task/docker_compose/template/src/kebab-zrb-task-name/docker-compose.yml +0 -2
- zrb/builtin/project/add/task/python/add.py +1 -1
- zrb/builtin/project/add/task/python/template/_automate/snake_zrb_task_name.py +1 -1
- zrb/builtin/project/create/_helper.py +1 -1
- zrb/builtin/project/create/create.py +1 -1
- zrb/builtin/say.py +3 -3
- zrb/builtin/version.py +2 -1
- zrb/config/config.py +12 -2
- zrb/helper/accessories/color.py +2 -1
- zrb/helper/advertisement.py +2 -1
- zrb/helper/asyncio_task.py +26 -0
- zrb/helper/callable.py +2 -1
- zrb/helper/cli.py +16 -3
- zrb/helper/codemod/add_import_module.py +3 -2
- zrb/helper/codemod/add_property_to_class.py +2 -1
- zrb/helper/default_env.py +2 -1
- zrb/helper/docker_compose/fetch_external_env.py +4 -2
- zrb/helper/docker_compose/file.py +3 -1
- zrb/helper/env_map/fetch.py +3 -2
- zrb/helper/file/copy_tree.py +2 -1
- zrb/helper/file/match.py +2 -2
- zrb/helper/git/detect_changes.py +1 -1
- zrb/helper/loader/load_module.py +7 -46
- zrb/helper/loader/load_script.py +57 -0
- zrb/helper/map/conversion.py +3 -1
- zrb/helper/string/jinja.py +2 -1
- zrb/helper/string/parse_replacement.py +1 -1
- zrb/helper/typing.py +5 -27
- zrb/helper/util.py +1 -1
- zrb/task/any_task.py +9 -17
- zrb/task/any_task_event_handler.py +3 -1
- zrb/task/base_remote_cmd_task.py +3 -10
- zrb/task/base_task/base_task.py +12 -8
- zrb/task/base_task/component/base_task_model.py +6 -13
- zrb/task/base_task/component/common_task_model.py +15 -22
- zrb/task/base_task/component/renderer.py +3 -1
- zrb/task/base_task/component/trackers.py +1 -1
- zrb/task/checker.py +2 -1
- zrb/task/cmd_task.py +6 -18
- zrb/task/decorator.py +3 -1
- zrb/task/docker_compose_start_task.py +27 -32
- zrb/task/docker_compose_task.py +27 -35
- zrb/task/flow_task.py +19 -18
- zrb/task/http_checker.py +3 -9
- zrb/task/looper.py +4 -2
- zrb/task/notifier.py +3 -1
- zrb/task/parallel.py +4 -4
- zrb/task/path_checker.py +6 -12
- zrb/task/path_watcher.py +5 -13
- zrb/task/port_checker.py +3 -9
- zrb/task/recurring_task.py +5 -4
- zrb/task/remote_cmd_task.py +2 -1
- zrb/task/resource_maker.py +6 -13
- zrb/task/rsync_task.py +3 -1
- zrb/task/server.py +13 -12
- zrb/task/time_watcher.py +3 -10
- zrb/task/watcher.py +2 -1
- zrb/task/wiki_task.py +4 -3
- zrb/task_env/env.py +2 -1
- zrb/task_env/env_file.py +7 -6
- zrb/task_group/group.py +8 -7
- zrb/task_input/any_input.py +4 -3
- zrb/task_input/base_input.py +5 -3
- zrb/task_input/bool_input.py +2 -1
- zrb/task_input/choice_input.py +3 -1
- zrb/task_input/float_input.py +2 -1
- zrb/task_input/int_input.py +2 -1
- zrb/task_input/multiline_input.py +3 -1
- zrb/task_input/password_input.py +2 -1
- zrb/task_input/str_input.py +2 -1
- {zrb-0.24.0.dist-info → zrb-0.26.2.dist-info}/METADATA +1 -1
- {zrb-0.24.0.dist-info → zrb-0.26.2.dist-info}/RECORD +194 -176
- {zrb-0.24.0.dist-info → zrb-0.26.2.dist-info}/LICENSE +0 -0
- {zrb-0.24.0.dist-info → zrb-0.26.2.dist-info}/WHEEL +0 -0
- {zrb-0.24.0.dist-info → zrb-0.26.2.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import os
|
2
|
+
from typing import Any
|
2
3
|
|
3
4
|
from zrb.builtin.project._group import project_group
|
4
5
|
from zrb.builtin.project._input import project_dir_input
|
@@ -12,7 +13,6 @@ from zrb.builtin.project.create._input import (
|
|
12
13
|
)
|
13
14
|
from zrb.config.config import VERSION
|
14
15
|
from zrb.helper.accessories.color import colored
|
15
|
-
from zrb.helper.typing import Any
|
16
16
|
from zrb.runner import runner
|
17
17
|
from zrb.task.cmd_task import CmdTask
|
18
18
|
from zrb.task.decorator import python_task
|
zrb/builtin/say.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import datetime
|
2
2
|
import random
|
3
|
+
from typing import Any
|
3
4
|
|
4
5
|
from zrb.helper.task import show_lines
|
5
|
-
from zrb.helper.typing import Any, List
|
6
6
|
from zrb.runner import runner
|
7
7
|
from zrb.task.decorator import python_task
|
8
8
|
from zrb.task_input.int_input import IntInput
|
@@ -94,7 +94,7 @@ def say(*args: Any, **kwargs: Any):
|
|
94
94
|
show_lines(kwargs["_task"], *lines)
|
95
95
|
|
96
96
|
|
97
|
-
def _get_content(text: str, width: int) ->
|
97
|
+
def _get_content(text: str, width: int) -> list[str]:
|
98
98
|
if text == "":
|
99
99
|
now = datetime.datetime.now()
|
100
100
|
today = "Today is " + now.strftime("%A, %B %d, %Y")
|
@@ -108,7 +108,7 @@ def _get_content(text: str, width: int) -> List[str]:
|
|
108
108
|
return _split_text_by_width(text, width)
|
109
109
|
|
110
110
|
|
111
|
-
def _split_text_by_width(text: str, width: int) ->
|
111
|
+
def _split_text_by_width(text: str, width: int) -> list[str]:
|
112
112
|
original_lines = text.split("\n")
|
113
113
|
new_lines = []
|
114
114
|
for original_line in original_lines:
|
zrb/builtin/version.py
CHANGED
zrb/config/config.py
CHANGED
@@ -33,8 +33,18 @@ def _get_default_tmp_dir() -> str:
|
|
33
33
|
TMP_DIR = os.getenv("ZRB_TMP_DIR", _get_default_tmp_dir())
|
34
34
|
DEFAULT_SHELL = os.getenv("ZRB_SHELL", _get_current_shell())
|
35
35
|
DEFAULT_EDITOR = os.getenv("ZRB_EDITOR", "nano")
|
36
|
-
|
37
|
-
|
36
|
+
INIT_MODULES_STR = os.getenv("ZRB_INIT_MODULES", "")
|
37
|
+
INIT_MODULES = (
|
38
|
+
[module.strip() for module in INIT_MODULES_STR.split(":") if module.strip() != ""]
|
39
|
+
if INIT_MODULES_STR != ""
|
40
|
+
else []
|
41
|
+
)
|
42
|
+
INIT_SCRIPTS_STR = os.getenv("ZRB_INIT_SCRIPTS", "")
|
43
|
+
INIT_SCRIPTS = (
|
44
|
+
[script.strip() for script in INIT_SCRIPTS_STR.split(":") if script.strip() != ""]
|
45
|
+
if INIT_SCRIPTS_STR != ""
|
46
|
+
else []
|
47
|
+
)
|
38
48
|
LOGGING_LEVEL = untyped_to_logging_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
|
39
49
|
SHOULD_LOAD_BUILTIN = untyped_to_boolean(os.getenv("ZRB_SHOULD_LOAD_BUILTIN", "1"))
|
40
50
|
ENV_PREFIX = os.getenv("ZRB_ENV", "")
|
zrb/helper/accessories/color.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import random
|
2
|
+
from collections.abc import Iterable
|
3
|
+
from typing import Optional
|
2
4
|
|
3
5
|
from termcolor import COLORS
|
4
6
|
|
5
7
|
from zrb.helper.accessories.untyped_color import untyped_colored
|
6
8
|
from zrb.helper.log import logger
|
7
9
|
from zrb.helper.typecheck import typechecked
|
8
|
-
from zrb.helper.typing import Iterable, Optional
|
9
10
|
|
10
11
|
logger.debug(untyped_colored("Loading zrb.helper.accessories.color", attrs=["dark"]))
|
11
12
|
|
zrb/helper/advertisement.py
CHANGED
@@ -2,11 +2,12 @@ import datetime
|
|
2
2
|
import random
|
3
3
|
import re
|
4
4
|
import sys
|
5
|
+
from collections.abc import Iterable
|
6
|
+
from typing import Optional
|
5
7
|
|
6
8
|
from zrb.helper.accessories.color import colored
|
7
9
|
from zrb.helper.log import logger
|
8
10
|
from zrb.helper.typecheck import typechecked
|
9
|
-
from zrb.helper.typing import Iterable, Optional
|
10
11
|
|
11
12
|
logger.debug(colored("Loading zrb.helper.advertisement", attrs=["dark"]))
|
12
13
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
3
|
+
from zrb.helper.accessories.color import colored
|
4
|
+
from zrb.helper.log import logger
|
5
|
+
|
6
|
+
logger.debug(colored("Loading zrb.helper.asyncio_task", attrs=["dark"]))
|
7
|
+
|
8
|
+
|
9
|
+
async def stop_asyncio():
|
10
|
+
tasks = [task for task in asyncio.all_tasks() if task is not asyncio.current_task()]
|
11
|
+
for task in tasks:
|
12
|
+
task.cancel()
|
13
|
+
|
14
|
+
# Wait until all tasks are cancelled
|
15
|
+
await asyncio.gather(*tasks, return_exceptions=True)
|
16
|
+
|
17
|
+
|
18
|
+
def stop_asyncio_sync():
|
19
|
+
try:
|
20
|
+
loop = asyncio.get_event_loop()
|
21
|
+
if loop.is_running():
|
22
|
+
loop.create_task(stop_asyncio())
|
23
|
+
else:
|
24
|
+
loop.run_until_complete(stop_asyncio())
|
25
|
+
except Exception:
|
26
|
+
pass
|
zrb/helper/callable.py
CHANGED
zrb/helper/cli.py
CHANGED
@@ -4,9 +4,10 @@ from functools import lru_cache
|
|
4
4
|
|
5
5
|
import click
|
6
6
|
|
7
|
-
from zrb.config.config import INIT_SCRIPTS, SHOULD_LOAD_BUILTIN, VERSION
|
7
|
+
from zrb.config.config import INIT_MODULES, INIT_SCRIPTS, SHOULD_LOAD_BUILTIN, VERSION
|
8
8
|
from zrb.helper.accessories.color import colored
|
9
9
|
from zrb.helper.loader.load_module import load_module
|
10
|
+
from zrb.helper.loader.load_script import load_script
|
10
11
|
from zrb.helper.log import logger
|
11
12
|
from zrb.helper.typecheck import typechecked
|
12
13
|
from zrb.runner import runner
|
@@ -45,15 +46,27 @@ def create_cli() -> click.Group:
|
|
45
46
|
from zrb import builtin
|
46
47
|
|
47
48
|
assert builtin
|
49
|
+
# load from ZRB_INIT_MODULES
|
50
|
+
for init_module in INIT_MODULES:
|
51
|
+
try:
|
52
|
+
load_module(init_module)
|
53
|
+
except Exception:
|
54
|
+
logger.error(
|
55
|
+
colored(
|
56
|
+
f"Failed to load module {init_module}",
|
57
|
+
color="red",
|
58
|
+
attrs=["bold"],
|
59
|
+
)
|
60
|
+
)
|
48
61
|
# Load zrb_init.py
|
49
62
|
project_dir = os.getenv("ZRB_PROJECT_DIR", os.getcwd())
|
50
63
|
project_script = os.path.join(project_dir, "zrb_init.py")
|
51
|
-
|
64
|
+
load_script(script_path=project_script, sys_path_index=0)
|
52
65
|
# load from ZRB_INIT_SCRIPTS environment
|
53
66
|
for index, init_script in enumerate(INIT_SCRIPTS):
|
54
67
|
logger.info(colored(f"Load module from {init_script}", attrs=["dark"]))
|
55
68
|
try:
|
56
|
-
|
69
|
+
load_script(script_path=init_script, sys_path_index=index + 1)
|
57
70
|
except Exception:
|
58
71
|
logger.error(
|
59
72
|
colored(
|
@@ -1,9 +1,10 @@
|
|
1
|
+
from typing import Optional, Union
|
2
|
+
|
1
3
|
import libcst as cst
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
7
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Optional, Tuple, Union
|
7
8
|
|
8
9
|
logger.debug(colored("Loading zrb.helper.codemod.add_import_module", attrs=["dark"]))
|
9
10
|
|
@@ -83,7 +84,7 @@ def _get_new_import(
|
|
83
84
|
|
84
85
|
|
85
86
|
@typechecked
|
86
|
-
def _split_module_path(module_path) ->
|
87
|
+
def _split_module_path(module_path) -> tuple[str, str]:
|
87
88
|
prefix = ""
|
88
89
|
suffix = ""
|
89
90
|
is_prefix = True
|
@@ -1,9 +1,10 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
1
3
|
import libcst as cst
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
7
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Optional
|
7
8
|
|
8
9
|
logger.debug(
|
9
10
|
colored("Loading zrb.helper.codemod.add_property_to_class", attrs=["dark"])
|
zrb/helper/default_env.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
import os
|
2
|
+
from collections.abc import Mapping
|
2
3
|
from functools import lru_cache
|
4
|
+
from typing import Optional
|
3
5
|
|
4
6
|
from zrb.helper.accessories.color import colored
|
5
7
|
from zrb.helper.log import logger
|
6
8
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import Mapping, Optional
|
8
9
|
|
9
10
|
logger.debug(colored("Loading zrb.helper.default_env", attrs=["dark"]))
|
10
11
|
_PROJECT_DIR_MAP: Mapping[str, str] = {}
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
6
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Any, List, Mapping
|
5
7
|
|
6
8
|
logger.debug(
|
7
9
|
colored("Loading zrb.helper.docker_compose.fetch_external_env", attrs=["dark"])
|
@@ -19,7 +21,7 @@ def fetch_compose_file_env_map(data: Any) -> Mapping[str, str]:
|
|
19
21
|
environments = data["services"][service]["environment"]
|
20
22
|
if isinstance(environments, list):
|
21
23
|
for environment in environments:
|
22
|
-
parts:
|
24
|
+
parts: list[str] = environment.split("=")
|
23
25
|
if len(parts) > 0:
|
24
26
|
env_str = str(parts[1])
|
25
27
|
env_dict = parse_compose_file_env_string(env_str)
|
@@ -1,9 +1,11 @@
|
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from ruamel.yaml import YAML, CommentedMap
|
2
5
|
|
3
6
|
from zrb.helper.accessories.color import colored
|
4
7
|
from zrb.helper.log import logger
|
5
8
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Any, Mapping
|
7
9
|
|
8
10
|
logger.debug(colored("Loading zrb.helper.docker_compose.file", attrs=["dark"]))
|
9
11
|
|
zrb/helper/env_map/fetch.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
from collections.abc import Mapping
|
2
|
+
|
1
3
|
from zrb.helper.accessories.color import colored
|
2
4
|
from zrb.helper.log import logger
|
3
5
|
from zrb.helper.string.jinja import is_probably_jinja
|
4
6
|
from zrb.helper.typecheck import typechecked
|
5
|
-
from zrb.helper.typing import List, Mapping
|
6
7
|
from zrb.task.any_task import AnyTask
|
7
8
|
from zrb.task_env.env import Env
|
8
9
|
from zrb.task_group.group import Group
|
@@ -39,7 +40,7 @@ def fetch_env_map_from_task(env_map: Mapping[str, str], task: AnyTask):
|
|
39
40
|
|
40
41
|
@typechecked
|
41
42
|
def _add_envs_to_env_map(
|
42
|
-
env_map: Mapping[str, str], envs:
|
43
|
+
env_map: Mapping[str, str], envs: list[Env]
|
43
44
|
) -> Mapping[str, str]:
|
44
45
|
for env in envs:
|
45
46
|
if env.get_os_name() == "":
|
zrb/helper/file/copy_tree.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
import fnmatch
|
2
2
|
import os
|
3
3
|
import shutil
|
4
|
+
from collections.abc import Iterable, Mapping
|
5
|
+
from typing import Optional
|
4
6
|
|
5
7
|
from zrb.helper.accessories.color import colored
|
6
8
|
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
7
9
|
from zrb.helper.log import logger
|
8
10
|
from zrb.helper.string.parse_replacement import parse_replacement
|
9
11
|
from zrb.helper.typecheck import typechecked
|
10
|
-
from zrb.helper.typing import Iterable, Mapping, Optional
|
11
12
|
|
12
13
|
logger.debug(colored("Loading zrb.helper.file.copy_tree", attrs=["dark"]))
|
13
14
|
|
zrb/helper/file/match.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
import fnmatch
|
2
2
|
import glob
|
3
|
+
from collections.abc import Iterable
|
3
4
|
|
4
5
|
from zrb.helper.accessories.color import colored
|
5
6
|
from zrb.helper.log import logger
|
6
7
|
from zrb.helper.typecheck import typechecked
|
7
|
-
from zrb.helper.typing import Iterable, List
|
8
8
|
|
9
9
|
logger.debug(colored("Loading zrb.helper.file.match", attrs=["dark"]))
|
10
10
|
|
11
11
|
|
12
12
|
@typechecked
|
13
|
-
def get_file_names(glob_path: str, glob_ignored_paths: Iterable[str]) ->
|
13
|
+
def get_file_names(glob_path: str, glob_ignored_paths: Iterable[str]) -> list[str]:
|
14
14
|
matches = []
|
15
15
|
for file in glob.glob(glob_path, recursive=True):
|
16
16
|
should_ignore = any(
|
zrb/helper/git/detect_changes.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import subprocess
|
2
|
+
from collections.abc import Mapping
|
2
3
|
|
3
4
|
from zrb.helper.accessories.color import colored
|
4
5
|
from zrb.helper.log import logger
|
5
6
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Mapping
|
7
7
|
|
8
8
|
logger.debug(colored("Loading zrb.helper.git.detect_changes", attrs=["dark"]))
|
9
9
|
|
zrb/helper/loader/load_module.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
import importlib
|
2
|
-
import os
|
3
|
-
import re
|
4
|
-
import sys
|
1
|
+
import importlib
|
5
2
|
from functools import lru_cache
|
3
|
+
from typing import Any
|
6
4
|
|
7
5
|
from zrb.helper.accessories.color import colored
|
8
6
|
from zrb.helper.log import logger
|
@@ -10,48 +8,11 @@ from zrb.helper.typecheck import typechecked
|
|
10
8
|
|
11
9
|
logger.debug(colored("Loading zrb.helper.loader.load_module", attrs=["dark"]))
|
12
10
|
|
13
|
-
pattern = re.compile("[^a-zA-Z0-9]")
|
14
|
-
|
15
11
|
|
16
12
|
@lru_cache
|
17
13
|
@typechecked
|
18
|
-
def load_module(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
_append_dir_to_python_path(script_dir_path)
|
24
|
-
_exec_script_as_module(script_path)
|
25
|
-
|
26
|
-
|
27
|
-
def _exec_script_as_module(script_path: str):
|
28
|
-
module_name = pattern.sub("", script_path)
|
29
|
-
logger.info(colored(f"Get module spec: {script_path}", attrs=["dark"]))
|
30
|
-
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
31
|
-
logger.info(colored(f"Create module: {script_path}", attrs=["dark"]))
|
32
|
-
module = importlib.util.module_from_spec(spec)
|
33
|
-
logger.info(colored(f"Exec module: {script_path}", attrs=["dark"]))
|
34
|
-
spec.loader.exec_module(module)
|
35
|
-
logger.info(colored(f"Module executed: {script_path}", attrs=["dark"]))
|
36
|
-
|
37
|
-
|
38
|
-
def _append_dir_to_sys_path(dir_path: str, index: int):
|
39
|
-
if dir_path in sys.path:
|
40
|
-
return
|
41
|
-
sys.path.insert(index, dir_path)
|
42
|
-
logger.info(colored(f"Set sys.path to {sys.path}", attrs=["dark"]))
|
43
|
-
|
44
|
-
|
45
|
-
def _append_dir_to_python_path(dir_path: str):
|
46
|
-
new_python_path = _get_new_python_path(dir_path)
|
47
|
-
logger.info(colored(f"Set PYTHONPATH to {new_python_path}", attrs=["dark"]))
|
48
|
-
os.environ["PYTHONPATH"] = new_python_path
|
49
|
-
|
50
|
-
|
51
|
-
def _get_new_python_path(dir_path: str) -> str:
|
52
|
-
current_python_path = os.getenv("PYTHONPATH")
|
53
|
-
if current_python_path is None or current_python_path == "":
|
54
|
-
return dir_path
|
55
|
-
if dir_path in current_python_path.split(":"):
|
56
|
-
return current_python_path
|
57
|
-
return ":".join([current_python_path, dir_path])
|
14
|
+
def load_module(module_name: str) -> Any:
|
15
|
+
logger.info(colored(f"Importing module: {module_name}", attrs=["dark"]))
|
16
|
+
module = importlib.import_module(module_name)
|
17
|
+
logger.info(colored(f"Module imported: {module_name}", attrs=["dark"]))
|
18
|
+
return module
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import importlib.util
|
2
|
+
import os
|
3
|
+
import re
|
4
|
+
import sys
|
5
|
+
from functools import lru_cache
|
6
|
+
|
7
|
+
from zrb.helper.accessories.color import colored
|
8
|
+
from zrb.helper.log import logger
|
9
|
+
from zrb.helper.typecheck import typechecked
|
10
|
+
|
11
|
+
logger.debug(colored("Loading zrb.helper.loader.load_script", attrs=["dark"]))
|
12
|
+
|
13
|
+
pattern = re.compile("[^a-zA-Z0-9]")
|
14
|
+
|
15
|
+
|
16
|
+
@lru_cache
|
17
|
+
@typechecked
|
18
|
+
def load_script(script_path: str, sys_path_index: int = 0):
|
19
|
+
if not os.path.isfile(script_path):
|
20
|
+
return
|
21
|
+
script_dir_path = os.path.dirname(script_path)
|
22
|
+
_append_dir_to_sys_path(script_dir_path, sys_path_index)
|
23
|
+
_append_dir_to_python_path(script_dir_path)
|
24
|
+
_exec_script_as_module(script_path)
|
25
|
+
|
26
|
+
|
27
|
+
def _exec_script_as_module(script_path: str):
|
28
|
+
module_name = pattern.sub("", script_path)
|
29
|
+
logger.info(colored(f"Get module spec: {script_path}", attrs=["dark"]))
|
30
|
+
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
31
|
+
logger.info(colored(f"Create module: {script_path}", attrs=["dark"]))
|
32
|
+
module = importlib.util.module_from_spec(spec)
|
33
|
+
logger.info(colored(f"Exec module: {script_path}", attrs=["dark"]))
|
34
|
+
spec.loader.exec_module(module)
|
35
|
+
logger.info(colored(f"Module executed: {script_path}", attrs=["dark"]))
|
36
|
+
|
37
|
+
|
38
|
+
def _append_dir_to_sys_path(dir_path: str, index: int):
|
39
|
+
if dir_path in sys.path:
|
40
|
+
return
|
41
|
+
sys.path.insert(index, dir_path)
|
42
|
+
logger.info(colored(f"Set sys.path to {sys.path}", attrs=["dark"]))
|
43
|
+
|
44
|
+
|
45
|
+
def _append_dir_to_python_path(dir_path: str):
|
46
|
+
new_python_path = _get_new_python_path(dir_path)
|
47
|
+
logger.info(colored(f"Set PYTHONPATH to {new_python_path}", attrs=["dark"]))
|
48
|
+
os.environ["PYTHONPATH"] = new_python_path
|
49
|
+
|
50
|
+
|
51
|
+
def _get_new_python_path(dir_path: str) -> str:
|
52
|
+
current_python_path = os.getenv("PYTHONPATH")
|
53
|
+
if current_python_path is None or current_python_path == "":
|
54
|
+
return dir_path
|
55
|
+
if dir_path in current_python_path.split(":"):
|
56
|
+
return current_python_path
|
57
|
+
return ":".join([current_python_path, dir_path])
|
zrb/helper/map/conversion.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
6
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Any, Mapping
|
5
7
|
|
6
8
|
logger.debug(colored("Loading zrb.helper.map.conversion", attrs=["dark"]))
|
7
9
|
|
zrb/helper/string/jinja.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
1
3
|
from zrb.helper.accessories.color import colored
|
2
4
|
from zrb.helper.log import logger
|
3
5
|
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.typing import Any
|
5
6
|
|
6
7
|
logger.debug(colored("Loading zrb.helper.string.jinja", attrs=["dark"]))
|
7
8
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import re
|
2
|
+
from collections.abc import Mapping
|
2
3
|
|
3
4
|
from zrb.helper.accessories.color import colored
|
4
5
|
from zrb.helper.log import logger
|
5
6
|
from zrb.helper.typecheck import typechecked
|
6
|
-
from zrb.helper.typing import Mapping
|
7
7
|
|
8
8
|
logger.debug(colored("Loading zrb.helper.string.parse_replacment", attrs=["dark"]))
|
9
9
|
|
zrb/helper/typing.py
CHANGED
@@ -1,35 +1,13 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Callable, Iterable, Mapping
|
2
|
+
from typing import Any, Optional, Type, TypeVar, Union
|
3
|
+
|
2
4
|
from zrb.helper.accessories.untyped_color import untyped_colored as colored
|
3
5
|
from zrb.helper.log import logger
|
4
6
|
|
5
7
|
logger.debug(colored("Loading zrb.helper.typing", attrs=["dark"]))
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
Any,
|
10
|
-
Callable,
|
11
|
-
Iterable,
|
12
|
-
List,
|
13
|
-
Mapping,
|
14
|
-
Optional,
|
15
|
-
Tuple,
|
16
|
-
Type,
|
17
|
-
TypeVar,
|
18
|
-
Union,
|
19
|
-
)
|
20
|
-
else:
|
21
|
-
from typing import (
|
22
|
-
Any,
|
23
|
-
Callable,
|
24
|
-
Iterable,
|
25
|
-
List,
|
26
|
-
Mapping,
|
27
|
-
Optional,
|
28
|
-
Tuple,
|
29
|
-
Type,
|
30
|
-
TypeVar,
|
31
|
-
Union,
|
32
|
-
)
|
9
|
+
Tuple = tuple
|
10
|
+
List = list
|
33
11
|
|
34
12
|
JinjaTemplate = str
|
35
13
|
|
zrb/helper/util.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import re
|
2
2
|
from functools import lru_cache
|
3
|
+
from typing import Any, Optional
|
3
4
|
|
4
5
|
import jinja2
|
5
6
|
|
@@ -7,7 +8,6 @@ from zrb.helper.accessories.color import colored
|
|
7
8
|
from zrb.helper.log import logger
|
8
9
|
from zrb.helper.string.conversion import to_boolean as conversion_to_boolean
|
9
10
|
from zrb.helper.typecheck import typechecked
|
10
|
-
from zrb.helper.typing import Any, Optional
|
11
11
|
|
12
12
|
logger.debug(colored("Loading zrb.helper.util", attrs=["dark"]))
|
13
13
|
|
zrb/task/any_task.py
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
|
+
from collections.abc import Callable, Iterable, Mapping
|
3
|
+
from typing import Any, Optional, TypeVar, Union
|
2
4
|
|
3
5
|
from zrb.helper.accessories.color import colored
|
4
6
|
from zrb.helper.log import logger
|
5
|
-
from zrb.helper.typing import
|
6
|
-
Any,
|
7
|
-
Callable,
|
8
|
-
Iterable,
|
9
|
-
JinjaTemplate,
|
10
|
-
List,
|
11
|
-
Mapping,
|
12
|
-
Optional,
|
13
|
-
TypeVar,
|
14
|
-
Union,
|
15
|
-
)
|
7
|
+
from zrb.helper.typing import JinjaTemplate
|
16
8
|
from zrb.task_env.env import Env
|
17
9
|
from zrb.task_env.env_file import EnvFile
|
18
10
|
from zrb.task_input.any_input import AnyInput
|
@@ -824,7 +816,7 @@ class AnyTask(ABC):
|
|
824
816
|
pass
|
825
817
|
|
826
818
|
@abstractmethod
|
827
|
-
def _get_env_files(self) ->
|
819
|
+
def _get_env_files(self) -> list[EnvFile]:
|
828
820
|
"""
|
829
821
|
Retrieves the list of environment variable files associated with the task.
|
830
822
|
|
@@ -832,7 +824,7 @@ class AnyTask(ABC):
|
|
832
824
|
uses to load environment variables, primarily for setup and configuration purposes.
|
833
825
|
|
834
826
|
Returns:
|
835
|
-
|
827
|
+
list[EnvFile]: A list of `EnvFile` instances associated with the task.
|
836
828
|
"""
|
837
829
|
pass
|
838
830
|
|
@@ -850,7 +842,7 @@ class AnyTask(ABC):
|
|
850
842
|
pass
|
851
843
|
|
852
844
|
@abstractmethod
|
853
|
-
def _get_envs(self) ->
|
845
|
+
def _get_envs(self) -> list[Env]:
|
854
846
|
"""
|
855
847
|
Retrieves the list of environment variables set for the task.
|
856
848
|
|
@@ -858,7 +850,7 @@ class AnyTask(ABC):
|
|
858
850
|
configured for the task, essential for understanding and debugging the task's environment setup.
|
859
851
|
|
860
852
|
Returns:
|
861
|
-
|
853
|
+
list[Env]: A list of `Env` instances representing the environment variables of the task.
|
862
854
|
"""
|
863
855
|
pass
|
864
856
|
|
@@ -880,7 +872,7 @@ class AnyTask(ABC):
|
|
880
872
|
pass
|
881
873
|
|
882
874
|
@abstractmethod
|
883
|
-
def _get_inputs(self) ->
|
875
|
+
def _get_inputs(self) -> list[AnyInput]:
|
884
876
|
"""
|
885
877
|
Retrieves the list of inputs associated with the task.
|
886
878
|
|
@@ -889,7 +881,7 @@ class AnyTask(ABC):
|
|
889
881
|
for introspection and debugging purposes.
|
890
882
|
|
891
883
|
Returns:
|
892
|
-
|
884
|
+
list[AnyInput]: A list of `AnyInput` instances representing the inputs for the task.
|
893
885
|
"""
|
894
886
|
pass
|
895
887
|
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from collections.abc import Callable
|
2
|
+
from typing import Any
|
3
|
+
|
1
4
|
from zrb.helper.accessories.color import colored
|
2
5
|
from zrb.helper.log import logger
|
3
|
-
from zrb.helper.typing import Any, Callable
|
4
6
|
from zrb.task.any_task import AnyTask
|
5
7
|
|
6
8
|
logger.debug(colored("Loading zrb.task.any_task_event_handler", attrs=["dark"]))
|