zrb 0.24.0__py3-none-any.whl → 0.25.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.
Files changed (174) hide show
  1. zrb/action/runner.py +6 -5
  2. zrb/advertisement.py +1 -2
  3. zrb/builtin/base64/decode.py +1 -1
  4. zrb/builtin/base64/encode.py +1 -1
  5. zrb/builtin/devtool/install/_helper.py +2 -1
  6. zrb/builtin/env/get.py +3 -2
  7. zrb/builtin/eval.py +2 -1
  8. zrb/builtin/git/get_file_changes.py +2 -1
  9. zrb/builtin/md5/hash.py +1 -1
  10. zrb/builtin/md5/sum.py +1 -1
  11. zrb/builtin/project/_helper.py +3 -3
  12. zrb/builtin/project/add/app/generator/generator.py +1 -1
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. zrb/builtin/project/add/app/python/python.py +1 -1
  19. zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/remove.py +1 -1
  20. zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +1 -1
  21. zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/stop.py +1 -1
  22. zrb/builtin/project/add/app/python/template/src/kebab-zrb-app-name/docker-compose.yml +0 -2
  23. zrb/builtin/project/add/fastapp/app/app.py +3 -1
  24. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -1
  25. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_service_config.py +1 -1
  26. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/_helper.py +2 -2
  27. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/_helper.py +2 -2
  28. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/stop.py +2 -0
  29. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/_helper.py +5 -3
  30. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build-once.sh +1 -1
  31. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/frontend/build.sh +1 -1
  32. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/_helper.py +3 -5
  33. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/start.py +3 -3
  34. zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/microservices/{start_microservices.py → start_services.py} +2 -3
  35. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/.generator-version +1 -0
  36. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/_common.py +5 -5
  37. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/deployment/app_helper.py +5 -5
  38. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/docker-compose.yml +2 -2
  39. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/error.py +2 -1
  40. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/admin.py +4 -3
  41. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/kafka/consumer.py +2 -1
  42. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/messagebus.py +4 -3
  43. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/mock.py +4 -3
  44. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/admin.py +4 -3
  45. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/messagebus/rabbitmq/consumer.py +3 -2
  46. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/model/repo_model.py +3 -3
  47. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/db_repo.py +7 -6
  48. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/repo.py +2 -2
  49. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/repo/search_filter.py +2 -1
  50. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/caller.py +2 -1
  51. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/messagebus/server.py +2 -1
  52. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/rpc/rpc.py +3 -2
  53. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/component/serializer/serializer.py +2 -1
  54. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +3 -4
  55. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/helper/async_task.py +1 -1
  56. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/scheme.py +2 -1
  57. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/component/access_token/util.py +2 -1
  58. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +2 -1
  59. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +2 -1
  60. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +2 -1
  61. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +2 -1
  62. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +3 -2
  63. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +3 -2
  64. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +3 -2
  65. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +2 -2
  66. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +3 -5
  67. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +1 -3
  68. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -3
  69. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +5 -7
  70. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +2 -1
  71. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +2 -1
  72. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +1 -3
  73. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +1 -1
  74. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +1 -1
  75. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +1 -1
  76. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +1 -1
  77. zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +1 -1
  78. zrb/builtin/project/add/fastapp/crud/_task_factory.py +1 -2
  79. zrb/builtin/project/add/fastapp/crud/crud.py +1 -1
  80. 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
  81. 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
  82. 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
  83. zrb/builtin/project/add/fastapp/field/field.py +1 -1
  84. zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +7 -8
  85. zrb/builtin/project/add/fastapp/module/module.py +1 -1
  86. zrb/builtin/project/add/plugin/plugin.py +1 -1
  87. zrb/builtin/project/add/project_task/add.py +1 -1
  88. zrb/builtin/project/add/project_task/template/_automate/_project/build.py +2 -1
  89. zrb/builtin/project/add/project_task/template/_automate/_project/container/remove.py +2 -1
  90. zrb/builtin/project/add/project_task/template/_automate/_project/container/start.py +2 -1
  91. zrb/builtin/project/add/project_task/template/_automate/_project/container/stop.py +2 -1
  92. zrb/builtin/project/add/project_task/template/_automate/_project/deploy.py +2 -1
  93. zrb/builtin/project/add/project_task/template/_automate/_project/destroy.py +2 -1
  94. zrb/builtin/project/add/project_task/template/_automate/_project/get_env.py +2 -1
  95. zrb/builtin/project/add/project_task/template/_automate/_project/image/build.py +2 -1
  96. zrb/builtin/project/add/project_task/template/_automate/_project/image/push.py +2 -1
  97. zrb/builtin/project/add/project_task/template/_automate/_project/publish.py +2 -1
  98. zrb/builtin/project/add/project_task/template/_automate/_project/start.py +2 -1
  99. zrb/builtin/project/add/task/cmd/add.py +1 -1
  100. zrb/builtin/project/add/task/docker_compose/add.py +1 -1
  101. zrb/builtin/project/add/task/docker_compose/template/src/kebab-zrb-task-name/docker-compose.yml +0 -2
  102. zrb/builtin/project/add/task/python/add.py +1 -1
  103. zrb/builtin/project/add/task/python/template/_automate/snake_zrb_task_name.py +1 -1
  104. zrb/builtin/project/create/_helper.py +1 -1
  105. zrb/builtin/project/create/create.py +1 -1
  106. zrb/builtin/say.py +3 -3
  107. zrb/builtin/version.py +2 -1
  108. zrb/config/config.py +12 -2
  109. zrb/helper/accessories/color.py +2 -1
  110. zrb/helper/advertisement.py +2 -1
  111. zrb/helper/callable.py +2 -1
  112. zrb/helper/cli.py +17 -3
  113. zrb/helper/codemod/add_import_module.py +3 -2
  114. zrb/helper/codemod/add_property_to_class.py +2 -1
  115. zrb/helper/default_env.py +2 -1
  116. zrb/helper/docker_compose/fetch_external_env.py +4 -2
  117. zrb/helper/docker_compose/file.py +3 -1
  118. zrb/helper/env_map/fetch.py +3 -2
  119. zrb/helper/file/copy_tree.py +2 -1
  120. zrb/helper/file/match.py +2 -2
  121. zrb/helper/git/detect_changes.py +1 -1
  122. zrb/helper/loader/load_module.py +7 -46
  123. zrb/helper/loader/load_script.py +57 -0
  124. zrb/helper/map/conversion.py +3 -1
  125. zrb/helper/string/jinja.py +2 -1
  126. zrb/helper/string/parse_replacement.py +1 -1
  127. zrb/helper/typing.py +5 -27
  128. zrb/helper/util.py +1 -1
  129. zrb/task/any_task.py +9 -17
  130. zrb/task/any_task_event_handler.py +3 -1
  131. zrb/task/base_remote_cmd_task.py +3 -10
  132. zrb/task/base_task/base_task.py +12 -8
  133. zrb/task/base_task/component/base_task_model.py +6 -13
  134. zrb/task/base_task/component/common_task_model.py +15 -22
  135. zrb/task/base_task/component/renderer.py +3 -1
  136. zrb/task/base_task/component/trackers.py +1 -1
  137. zrb/task/checker.py +2 -1
  138. zrb/task/cmd_task.py +4 -11
  139. zrb/task/decorator.py +3 -1
  140. zrb/task/docker_compose_start_task.py +27 -32
  141. zrb/task/docker_compose_task.py +27 -35
  142. zrb/task/flow_task.py +19 -17
  143. zrb/task/http_checker.py +3 -9
  144. zrb/task/looper.py +4 -2
  145. zrb/task/notifier.py +3 -1
  146. zrb/task/parallel.py +4 -4
  147. zrb/task/path_checker.py +6 -12
  148. zrb/task/path_watcher.py +5 -13
  149. zrb/task/port_checker.py +3 -9
  150. zrb/task/recurring_task.py +5 -4
  151. zrb/task/remote_cmd_task.py +2 -1
  152. zrb/task/resource_maker.py +6 -13
  153. zrb/task/rsync_task.py +3 -1
  154. zrb/task/server.py +13 -12
  155. zrb/task/time_watcher.py +3 -10
  156. zrb/task/watcher.py +2 -1
  157. zrb/task/wiki_task.py +4 -3
  158. zrb/task_env/env.py +2 -1
  159. zrb/task_env/env_file.py +7 -6
  160. zrb/task_group/group.py +8 -7
  161. zrb/task_input/any_input.py +4 -3
  162. zrb/task_input/base_input.py +5 -3
  163. zrb/task_input/bool_input.py +2 -1
  164. zrb/task_input/choice_input.py +3 -1
  165. zrb/task_input/float_input.py +2 -1
  166. zrb/task_input/int_input.py +2 -1
  167. zrb/task_input/multiline_input.py +3 -1
  168. zrb/task_input/password_input.py +2 -1
  169. zrb/task_input/str_input.py +2 -1
  170. {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/METADATA +1 -1
  171. {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/RECORD +174 -172
  172. {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/LICENSE +0 -0
  173. {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/WHEEL +0 -0
  174. {zrb-0.24.0.dist-info → zrb-0.25.1.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,6 @@
1
1
  import asyncio
2
2
  import os
3
+ from typing import Any
3
4
 
4
5
  from zrb.builtin.project._helper import validate_existing_project_dir
5
6
  from zrb.builtin.project._input import project_dir_input
@@ -18,7 +19,6 @@ from zrb.builtin.project.add.fastapp.module._helper import (
18
19
  from zrb.builtin.project.add.fastapp.module._input import module_name_input
19
20
  from zrb.helper import util
20
21
  from zrb.helper.accessories.color import colored
21
- from zrb.helper.typing import Any
22
22
  from zrb.runner import runner
23
23
  from zrb.task.decorator import python_task
24
24
  from zrb.task.resource_maker import ResourceMaker
@@ -1,4 +1,5 @@
1
1
  import os
2
+ from typing import Any
2
3
 
3
4
  from zrb.builtin.project._helper import (
4
5
  create_register_module,
@@ -19,7 +20,6 @@ from zrb.builtin.project.add.plugin._input import (
19
20
  from zrb.builtin.project.add.project_task import add_project_tasks
20
21
  from zrb.config.config import VERSION
21
22
  from zrb.helper.accessories.color import colored
22
- from zrb.helper.typing import Any
23
23
  from zrb.runner import runner
24
24
  from zrb.task.decorator import python_task
25
25
  from zrb.task.resource_maker import ResourceMaker
@@ -1,11 +1,11 @@
1
1
  import os
2
+ from typing import Any
2
3
 
3
4
  from zrb.builtin.project._input import project_dir_input
4
5
  from zrb.helper.codemod.add_assert_resource import add_assert_resource
5
6
  from zrb.helper.codemod.add_import_module import add_import_module
6
7
  from zrb.helper.file.copy_tree import copy_tree
7
8
  from zrb.helper.file.text import read_text_file_async, write_text_file_async
8
- from zrb.helper.typing import Any
9
9
  from zrb.task.decorator import python_task
10
10
  from zrb.task.task import Task
11
11
 
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.accessories.color import colored
4
- from zrb.helper.typing import Any
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,6 +1,7 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.helper.accessories.color import colored
3
- from zrb.helper.typing import Any
4
5
 
5
6
  from ._group import project_container_group
6
7
 
@@ -1,6 +1,7 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.helper.accessories.color import colored
3
- from zrb.helper.typing import Any
4
5
 
5
6
  from ._group import project_container_group
6
7
 
@@ -1,6 +1,7 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.helper.accessories.color import colored
3
- from zrb.helper.typing import Any
4
5
 
5
6
  from ._group import project_container_group
6
7
 
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.accessories.color import colored
4
- from zrb.helper.typing import Any
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.accessories.color import colored
4
- from zrb.helper.typing import Any
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import BoolInput, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.env_map.fetch import fetch_env_map_from_group
4
- from zrb.helper.typing import Any, Mapping
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,6 +1,7 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.helper.accessories.color import colored
3
- from zrb.helper.typing import Any
4
5
 
5
6
  from ._group import project_image_group
6
7
 
@@ -1,6 +1,7 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.helper.accessories.color import colored
3
- from zrb.helper.typing import Any
4
5
 
5
6
  from ._group import project_image_group
6
7
 
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.accessories.color import colored
4
- from zrb.helper.typing import Any
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,7 +1,8 @@
1
+ from typing import Any
2
+
1
3
  from zrb import Task, python_task, runner
2
4
  from zrb.builtin import project_group
3
5
  from zrb.helper.accessories.color import colored
4
- from zrb.helper.typing import Any
5
6
 
6
7
 
7
8
  @python_task(
@@ -1,4 +1,5 @@
1
1
  import os
2
+ from typing import Any
2
3
 
3
4
  from zrb.builtin.project._helper import (
4
5
  create_register_module,
@@ -8,7 +9,6 @@ from zrb.builtin.project._helper import (
8
9
  from zrb.builtin.project._input import project_dir_input
9
10
  from zrb.builtin.project.add.task._group import project_add_task_group
10
11
  from zrb.builtin.project.add.task._input import task_name_input
11
- from zrb.helper.typing import Any
12
12
  from zrb.runner import runner
13
13
  from zrb.task.decorator import python_task
14
14
  from zrb.task.resource_maker import ResourceMaker
@@ -1,4 +1,5 @@
1
1
  import os
2
+ from typing import Any
2
3
 
3
4
  from zrb.builtin.project._helper import (
4
5
  create_register_module,
@@ -12,7 +13,6 @@ from zrb.builtin.project.add.task.docker_compose._input import (
12
13
  compose_command_input,
13
14
  http_port_input,
14
15
  )
15
- from zrb.helper.typing import Any
16
16
  from zrb.runner import runner
17
17
  from zrb.task.decorator import python_task
18
18
  from zrb.task.resource_maker import ResourceMaker
@@ -1,5 +1,3 @@
1
- version: '3'
2
-
3
1
  x-logging: &default-logging
4
2
  options:
5
3
  max-size: "100m"
@@ -1,4 +1,5 @@
1
1
  import os
2
+ from typing import Any
2
3
 
3
4
  from zrb.builtin.project._helper import (
4
5
  create_register_module,
@@ -8,7 +9,6 @@ from zrb.builtin.project._helper import (
8
9
  from zrb.builtin.project._input import project_dir_input
9
10
  from zrb.builtin.project.add.task._group import project_add_task_group
10
11
  from zrb.builtin.project.add.task._input import task_name_input
11
- from zrb.helper.typing import Any
12
12
  from zrb.runner import runner
13
13
  from zrb.task.decorator import python_task
14
14
  from zrb.task.resource_maker import ResourceMaker
@@ -1,4 +1,4 @@
1
- from typing import Any, Mapping
1
+ from typing import Any
2
2
 
3
3
  from zrb import Task, python_task, runner
4
4
  from zrb.builtin import project_group
@@ -1,6 +1,6 @@
1
1
  import os
2
+ from collections.abc import Mapping
2
3
 
3
- from zrb.helper.typing import Mapping
4
4
  from zrb.task.resource_maker import ResourceMaker
5
5
 
6
6
 
@@ -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) -> List[str]:
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) -> List[str]:
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
@@ -1,5 +1,6 @@
1
+ from typing import Any
2
+
1
3
  from zrb.config.config import VERSION
2
- from zrb.helper.typing import Any
3
4
  from zrb.runner import runner
4
5
  from zrb.task.decorator import python_task
5
6
  from zrb.task.task import Task
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
- INIT_SCRIPT_STR = os.getenv("ZRB_INIT_SCRIPTS", "")
37
- INIT_SCRIPTS = INIT_SCRIPT_STR.split(":") if INIT_SCRIPT_STR != "" else []
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", "")
@@ -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
 
@@ -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
 
zrb/helper/callable.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import asyncio
2
2
  import inspect
3
- from typing import Any, Callable, Coroutine
3
+ from collections.abc import Callable
4
+ from typing import Any
4
5
 
5
6
  from zrb.helper.accessories.color import colored
6
7
  from zrb.helper.log import logger
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,28 @@ 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
+ )
61
+ traceback.print_exc()
48
62
  # Load zrb_init.py
49
63
  project_dir = os.getenv("ZRB_PROJECT_DIR", os.getcwd())
50
64
  project_script = os.path.join(project_dir, "zrb_init.py")
51
- load_module(script_path=project_script, sys_path_index=0)
65
+ load_script(script_path=project_script, sys_path_index=0)
52
66
  # load from ZRB_INIT_SCRIPTS environment
53
67
  for index, init_script in enumerate(INIT_SCRIPTS):
54
68
  logger.info(colored(f"Load module from {init_script}", attrs=["dark"]))
55
69
  try:
56
- load_module(script_path=init_script, sys_path_index=index + 1)
70
+ load_script(script_path=init_script, sys_path_index=index + 1)
57
71
  except Exception:
58
72
  logger.error(
59
73
  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) -> Tuple[str, str]:
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: List[str] = environment.split("=")
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
 
@@ -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: List[Env]
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() == "":
@@ -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]) -> List[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(
@@ -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
 
@@ -1,8 +1,6 @@
1
- import importlib.util
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(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])
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])