zrb 0.6.0__py3-none-any.whl → 0.6.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.
- zrb/__init__.py +24 -20
- zrb/__main__.py +5 -5
- zrb/action/runner.py +22 -30
- zrb/advertisement.py +10 -9
- zrb/builtin/__init__.py +18 -16
- zrb/builtin/base64.py +13 -18
- zrb/builtin/devtool/__init__.py +14 -3
- zrb/builtin/devtool/devtool_install.py +207 -221
- zrb/builtin/env.py +9 -12
- zrb/builtin/eval.py +9 -9
- zrb/builtin/explain.py +73 -74
- zrb/builtin/generator/__init__.py +7 -11
- zrb/builtin/generator/app_generator/add.py +86 -87
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/add.py +78 -77
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +6 -6
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +32 -32
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +29 -30
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +1 -3
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +5 -4
- zrb/builtin/generator/app_generator/template/base/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/add.py +89 -87
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/container.py +42 -54
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/app_generator/template/build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +18 -18
- zrb/builtin/generator/app_generator/template/http-port/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/_checker.py +10 -10
- zrb/builtin/generator/app_generator/template/http-port-build-custom-image/_automate/generate_snake_zrb_meta_template_name/template/_automate/snake_zrb_app_name/local.py +19 -19
- zrb/builtin/generator/app_generator/template/use-helm/_automate/generate_snake_zrb_meta_template_name/template/src/kebab-zrb-app-name/deployment/__main__.py +12 -14
- zrb/builtin/generator/cmd_task/add.py +23 -25
- zrb/builtin/generator/cmd_task/template/_automate/snake_zrb_task_name.py +3 -5
- zrb/builtin/generator/common/helper.py +15 -20
- zrb/builtin/generator/common/task_factory.py +29 -26
- zrb/builtin/generator/common/task_input.py +97 -91
- zrb/builtin/generator/docker_compose_task/add.py +38 -39
- zrb/builtin/generator/docker_compose_task/template/_automate/snake_zrb_task_name.py +13 -19
- zrb/builtin/generator/docker_compose_task/template/src/kebab-zrb-task-name/image/main.py +18 -14
- zrb/builtin/generator/fastapp/add.py +94 -90
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_checker.py +28 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_config.py +68 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env.py +24 -22
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_env_file.py +12 -12
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_get_start_microservices.py +43 -41
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_helper.py +23 -24
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/_input.py +21 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-load-test.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-start.sh +1 -1
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/cmd/app-test.sh +2 -2
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/container.py +46 -39
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/deployment.py +28 -20
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/frontend.py +21 -27
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/image.py +23 -18
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/load_test.py +35 -36
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/local.py +68 -58
- zrb/builtin/generator/fastapp/template/_automate/snake_zrb_app_name/test.py +24 -38
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/__main__.py +23 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/_common.py +72 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/app_helper.py +70 -75
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_postgresql_helper.py +18 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_rabbitmq_helper.py +11 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_redpanda_helper.py +18 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/deployment/helm_signoz_helper.py +17 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/docker-compose.yml +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/loadtest/locustfile.py +10 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/Dockerfile +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app.py +35 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_lifespan.py +21 -17
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/app_state.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/db_connection.py +18 -20
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/frontend_index.py +5 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/log.py +7 -15
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/messagebus.py +38 -34
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/component/rpc.py +19 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/config.py +68 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/error.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/__init__.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/admin.py +38 -35
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/consumer.py +38 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/kafka/publisher.py +26 -29
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/messagebus.py +8 -14
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/mock.py +12 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/admin.py +37 -44
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/consumer.py +42 -67
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/messagebus/rabbitmq/publisher.py +32 -55
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/model/repo_model.py +11 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/__init__.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_entity_mixin.py +3 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/db_repo.py +76 -83
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/repo.py +5 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/repo/search_filter.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/caller.py +17 -19
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/messagebus/server.py +14 -18
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/rpc/rpc.py +15 -28
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/__init__.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/schema/base_schema.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/__init__.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/core/serializer/serializer.py +3 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/async_task.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/conversion.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/helper/migration.py +6 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/migrate.py +3 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/api.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/__init__.py +4 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_scheme.py +9 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/access_token_util.py +6 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/authorizer.py +4 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/bearer_token_scheme.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/model/user_model.py +8 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/password_hasher.py +1 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/refresh_token_util.py +7 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/group_repo.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/permission_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/repo/user_repo.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/component/user.py +12 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/__init__.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/scheme.py +7 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/access_token/util.py +20 -30
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/authorizer.py +1 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/authorizer/rpc_authorizer.py +5 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/bcrypt_password_hasher.py +3 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/password_hasher/password_hasher.py +0 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/core/refresh_token/util.py +15 -21
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/api.py +42 -49
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/model.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/repo.py +18 -16
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/group/rpc.py +26 -41
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/api.py +46 -51
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/model.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/repo.py +11 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/permission/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/table.py +10 -10
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/api.py +60 -72
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/model.py +32 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/repo.py +33 -36
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/entity/user/rpc.py +42 -61
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/event.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +11 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/register_permission.py +19 -26
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/rpc.py +5 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/group.py +6 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/permission.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/request.py +1 -0
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/token.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/auth/schema/user.py +4 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/api.py +4 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/model/activity_model.py +3 -9
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/component/repo/activity_repo.py +3 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/core/historical_repo_model.py +13 -13
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/api.py +22 -23
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/event.py +5 -7
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/model.py +2 -6
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/repo.py +8 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/activity/rpc.py +28 -45
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/entity/table.py +3 -3
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/event.py +4 -8
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -4
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/register_module.py +10 -11
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/rpc.py +3 -5
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/module/log/schema/activity.py +3 -1
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/src/requirements.txt +12 -12
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +76 -106
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +73 -103
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +92 -122
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +107 -134
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/conftest.py +2 -2
- zrb/builtin/generator/fastapp/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +8 -15
- zrb/builtin/generator/fastapp_crud/add.py +74 -79
- zrb/builtin/generator/fastapp_crud/helper.py +51 -48
- zrb/builtin/generator/fastapp_crud/task_factory.py +17 -14
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/model/snake_zrb_entity_name_model.py +2 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/component/repo/snake_zrb_entity_name_repo.py +3 -2
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/api.py +58 -40
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/model.py +7 -3
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +9 -4
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/rpc.py +32 -39
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +3 -1
- zrb/builtin/generator/fastapp_crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +68 -98
- zrb/builtin/generator/fastapp_field/add.py +143 -85
- zrb/builtin/generator/fastapp_field/helper.py +184 -125
- zrb/builtin/generator/fastapp_module/add.py +90 -67
- zrb/builtin/generator/fastapp_module/helper.py +141 -155
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/api.py +3 -2
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/table.py +3 -3
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/event.py +3 -5
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -4
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +10 -11
- zrb/builtin/generator/fastapp_module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/rpc.py +3 -5
- zrb/builtin/generator/pip_package/add.py +39 -40
- zrb/builtin/generator/pip_package/template/_automate/snake_zrb_package_name/local.py +30 -30
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__init__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/pip_package/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/util.py +2 -2
- zrb/builtin/generator/plugin/create.py +39 -36
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__init__.py +1 -1
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/__main__.py +1 -0
- zrb/builtin/generator/plugin/template/src/snake_zrb_package_name/task/example_task.py +6 -4
- zrb/builtin/generator/plugin/template/zrb_init.py +27 -27
- zrb/builtin/generator/project/create.py +38 -46
- zrb/builtin/generator/project/template/.flake8 +3 -0
- zrb/builtin/generator/project/template/project.sh +19 -10
- zrb/builtin/generator/project_task/task_factory.py +60 -61
- zrb/builtin/generator/project_task/template/_automate/_project/__init__.py +2 -2
- zrb/builtin/generator/project_task/template/_automate/_project/build_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/deploy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/destroy_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/push_project_images.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/remove_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/start_project_containers.py +4 -4
- zrb/builtin/generator/project_task/template/_automate/_project/stop_project_containers.py +4 -4
- zrb/builtin/generator/python_task/add.py +25 -33
- zrb/builtin/generator/python_task/template/_automate/snake_zrb_task_name.py +8 -7
- zrb/builtin/generator/simple_python_app/add.py +81 -75
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/_common.py +14 -15
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/container.py +46 -61
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/deployment.py +34 -32
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/image.py +19 -22
- zrb/builtin/generator/simple_python_app/template/_automate/snake_zrb_app_name/local.py +23 -25
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/deployment/__main__.py +24 -32
- zrb/builtin/generator/simple_python_app/template/src/kebab-zrb-app-name/src/main.py +18 -14
- zrb/builtin/git.py +46 -46
- zrb/builtin/group.py +13 -34
- zrb/builtin/helper/reccuring_action.py +26 -29
- zrb/builtin/md5.py +17 -30
- zrb/builtin/process.py +19 -19
- zrb/builtin/project.py +13 -15
- zrb/builtin/say.py +69 -88
- zrb/builtin/schedule.py +15 -19
- zrb/builtin/ubuntu.py +44 -35
- zrb/builtin/update.py +5 -5
- zrb/builtin/version.py +3 -7
- zrb/builtin/watch_changes.py +24 -25
- zrb/config/config.py +19 -18
- zrb/helper/accessories/color.py +18 -6
- zrb/helper/accessories/icon.py +24 -3
- zrb/helper/accessories/name.py +120 -28
- zrb/helper/advertisement.py +9 -13
- zrb/helper/callable.py +2 -4
- zrb/helper/cli.py +27 -31
- zrb/helper/codemod/add_argument_to_function.py +3 -4
- zrb/helper/codemod/add_argument_to_function_call.py +4 -7
- zrb/helper/codemod/add_assert_resource.py +7 -7
- zrb/helper/codemod/add_function_call.py +3 -5
- zrb/helper/codemod/add_import_module.py +15 -26
- zrb/helper/codemod/add_key_value_to_dict.py +7 -10
- zrb/helper/codemod/add_property_to_class.py +10 -8
- zrb/helper/codemod/add_upstream_to_task.py +21 -33
- zrb/helper/codemod/append_code_to_function.py +6 -13
- zrb/helper/codemod/format_code.py +2 -1
- zrb/helper/default_env.py +25 -25
- zrb/helper/docker_compose/fetch_external_env.py +18 -18
- zrb/helper/docker_compose/file.py +5 -4
- zrb/helper/docstring.py +44 -47
- zrb/helper/env_map/fetch.py +7 -12
- zrb/helper/file/copy_tree.py +12 -17
- zrb/helper/file/match.py +6 -7
- zrb/helper/file/text.py +8 -6
- zrb/helper/git/detect_changes.py +9 -8
- zrb/helper/loader/load_module.py +14 -13
- zrb/helper/log.py +4 -3
- zrb/helper/map/conversion.py +4 -5
- zrb/helper/python_task.py +2 -4
- zrb/helper/render_data.py +25 -18
- zrb/helper/string/constant.py +2 -2
- zrb/helper/string/conversion.py +17 -16
- zrb/helper/string/jinja.py +2 -2
- zrb/helper/typecheck.py +6 -4
- zrb/helper/typing.py +10 -2
- zrb/helper/util.py +44 -40
- zrb/task/any_task.py +251 -251
- zrb/task/base_remote_cmd_task.py +76 -59
- zrb/task/base_task/base_task.py +95 -108
- zrb/task/base_task/component/base_task_model.py +73 -71
- zrb/task/base_task/component/common_task_model.py +42 -29
- zrb/task/base_task/component/pid_model.py +3 -5
- zrb/task/base_task/component/renderer.py +26 -36
- zrb/task/base_task/component/trackers.py +6 -9
- zrb/task/checker.py +14 -9
- zrb/task/cmd_task.py +102 -100
- zrb/task/decorator.py +19 -13
- zrb/task/docker_compose_task.py +127 -98
- zrb/task/flow_task.py +16 -19
- zrb/task/http_checker.py +40 -36
- zrb/task/notifier.py +50 -38
- zrb/task/parallel.py +3 -3
- zrb/task/path_checker.py +34 -27
- zrb/task/path_watcher.py +49 -40
- zrb/task/port_checker.py +33 -26
- zrb/task/recurring_task.py +36 -42
- zrb/task/remote_cmd_task.py +31 -28
- zrb/task/resource_maker.py +66 -52
- zrb/task/rsync_task.py +24 -21
- zrb/task/task.py +4 -3
- zrb/task/time_watcher.py +36 -31
- zrb/task_env/constant.py +1 -1
- zrb/task_env/env.py +33 -31
- zrb/task_env/env_file.py +24 -23
- zrb/task_group/group.py +27 -30
- zrb/task_input/any_input.py +18 -16
- zrb/task_input/base_input.py +26 -26
- zrb/task_input/bool_input.py +6 -6
- zrb/task_input/choice_input.py +11 -9
- zrb/task_input/constant.py +1 -1
- zrb/task_input/float_input.py +6 -5
- zrb/task_input/int_input.py +8 -8
- zrb/task_input/password_input.py +9 -9
- zrb/task_input/str_input.py +8 -8
- zrb/task_input/task_input.py +4 -2
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/METADATA +3 -1
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/RECORD +316 -315
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/LICENSE +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/WHEEL +0 -0
- {zrb-0.6.0.dist-info → zrb-0.6.1.dist-info}/entry_points.txt +0 -0
zrb/builtin/watch_changes.py
CHANGED
@@ -1,42 +1,41 @@
|
|
1
|
-
from zrb.
|
1
|
+
from zrb.builtin.helper.reccuring_action import create_recurring_action
|
2
|
+
from zrb.runner import runner
|
2
3
|
from zrb.task.path_watcher import PathWatcher
|
4
|
+
from zrb.task.recurring_task import RecurringTask
|
3
5
|
from zrb.task_input.str_input import StrInput
|
4
|
-
from zrb.runner import runner
|
5
|
-
from zrb.builtin.helper.reccuring_action import create_recurring_action
|
6
|
-
|
7
6
|
|
8
7
|
watch_changes = RecurringTask(
|
9
|
-
name=
|
10
|
-
icon=
|
11
|
-
color=
|
12
|
-
description=
|
8
|
+
name="watch-changes",
|
9
|
+
icon="🕵️",
|
10
|
+
color="yellow",
|
11
|
+
description="Watch changes and show message/run command",
|
13
12
|
inputs=[
|
14
13
|
StrInput(
|
15
|
-
name=
|
16
|
-
default=
|
17
|
-
prompt=
|
18
|
-
description=
|
14
|
+
name="pattern",
|
15
|
+
default="*.*",
|
16
|
+
prompt="File pattern",
|
17
|
+
description="File pattern to be watched",
|
19
18
|
),
|
20
19
|
StrInput(
|
21
|
-
name=
|
22
|
-
default=
|
23
|
-
prompt=
|
24
|
-
description=
|
20
|
+
name="ignored-pattern",
|
21
|
+
default="",
|
22
|
+
prompt="Ignored file pattern",
|
23
|
+
description="Ignored file pattern",
|
25
24
|
),
|
26
25
|
],
|
27
26
|
triggers=[
|
28
27
|
PathWatcher(
|
29
|
-
name=
|
30
|
-
color=
|
31
|
-
icon=
|
32
|
-
path=
|
33
|
-
ignored_path=
|
28
|
+
name="watch-path",
|
29
|
+
color="cyan",
|
30
|
+
icon="👀",
|
31
|
+
path="{{input.pattern}}",
|
32
|
+
ignored_path="{{input.ignored_pattern}}",
|
34
33
|
)
|
35
34
|
],
|
36
35
|
task=create_recurring_action(
|
37
|
-
notif_title=
|
38
|
-
trigger_caption=
|
39
|
-
trigger_xcom_key=
|
40
|
-
)
|
36
|
+
notif_title="Watch",
|
37
|
+
trigger_caption="File changes",
|
38
|
+
trigger_xcom_key="watch-path.file",
|
39
|
+
),
|
41
40
|
)
|
42
41
|
runner.register(watch_changes)
|
zrb/config/config.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
import importlib.metadata as metadata
|
2
|
+
import os
|
3
|
+
|
1
4
|
from zrb.helper.string.conversion import to_boolean, to_logging_level
|
2
5
|
from zrb.helper.typecheck import typechecked
|
3
6
|
|
4
|
-
import os
|
5
|
-
import importlib.metadata as metadata
|
6
|
-
|
7
7
|
|
8
8
|
@typechecked
|
9
9
|
def get_version() -> str:
|
@@ -11,25 +11,26 @@ def get_version() -> str:
|
|
11
11
|
return metadata.version("zrb")
|
12
12
|
except metadata.PackageNotFoundError:
|
13
13
|
import flit
|
14
|
+
|
14
15
|
meta = flit.read_module_metadata("zrb")
|
15
16
|
return str(meta["module"]["version"])
|
16
17
|
|
17
18
|
|
18
19
|
@typechecked
|
19
20
|
def get_current_shell() -> str:
|
20
|
-
current_shell = os.getenv(
|
21
|
-
if current_shell.endswith(
|
22
|
-
return
|
23
|
-
return
|
24
|
-
|
25
|
-
|
26
|
-
default_shell = os.getenv(
|
27
|
-
init_script_str = os.getenv(
|
28
|
-
init_scripts = init_script_str.split(
|
29
|
-
logging_level = to_logging_level(os.getenv(
|
30
|
-
should_load_builtin = to_boolean(os.getenv(
|
31
|
-
env_prefix = os.getenv(
|
32
|
-
show_advertisement = to_boolean(os.getenv(
|
33
|
-
show_prompt = to_boolean(os.getenv(
|
34
|
-
show_time = to_boolean(os.getenv(
|
21
|
+
current_shell = os.getenv("SHELL", "")
|
22
|
+
if current_shell.endswith("zsh"):
|
23
|
+
return "zsh"
|
24
|
+
return "bash"
|
25
|
+
|
26
|
+
|
27
|
+
default_shell = os.getenv("ZRB_SHELL", get_current_shell())
|
28
|
+
init_script_str = os.getenv("ZRB_INIT_SCRIPTS", "")
|
29
|
+
init_scripts = init_script_str.split(":") if init_script_str != "" else []
|
30
|
+
logging_level = to_logging_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
|
31
|
+
should_load_builtin = to_boolean(os.getenv("ZRB_SHOULD_LOAD_BUILTIN", "1"))
|
32
|
+
env_prefix = os.getenv("ZRB_ENV", "")
|
33
|
+
show_advertisement = to_boolean(os.getenv("ZRB_SHOW_ADVERTISEMENT", "1"))
|
34
|
+
show_prompt = to_boolean(os.getenv("ZRB_SHOW_PROMPT", "1"))
|
35
|
+
show_time = to_boolean(os.getenv("ZRB_SHOW_TIME", "1"))
|
35
36
|
version = get_version()
|
zrb/helper/accessories/color.py
CHANGED
@@ -1,14 +1,26 @@
|
|
1
|
-
from zrb.helper.typing import Iterable, Optional
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
|
-
from termcolor import colored as term_colored, COLORS
|
4
1
|
import random
|
5
2
|
|
3
|
+
from termcolor import COLORS
|
4
|
+
from termcolor import colored as term_colored
|
5
|
+
|
6
|
+
from zrb.helper.typecheck import typechecked
|
7
|
+
from zrb.helper.typing import Iterable, Optional
|
8
|
+
|
6
9
|
|
7
10
|
@typechecked
|
8
11
|
def get_random_color() -> str:
|
9
12
|
colors = [
|
10
|
-
|
11
|
-
|
13
|
+
"green",
|
14
|
+
"yellow",
|
15
|
+
"blue",
|
16
|
+
"magenta",
|
17
|
+
"cyan",
|
18
|
+
"white",
|
19
|
+
"light_green",
|
20
|
+
"light_yellow",
|
21
|
+
"light_blue",
|
22
|
+
"light_magenta",
|
23
|
+
"light_cyan",
|
12
24
|
]
|
13
25
|
return random.choice(colors)
|
14
26
|
|
@@ -23,6 +35,6 @@ def colored(
|
|
23
35
|
text: str,
|
24
36
|
color: Optional[str] = None,
|
25
37
|
on_color: Optional[str] = None,
|
26
|
-
attrs: Optional[Iterable[str]] = None
|
38
|
+
attrs: Optional[Iterable[str]] = None,
|
27
39
|
) -> str:
|
28
40
|
return term_colored(text, color, on_color, attrs)
|
zrb/helper/accessories/icon.py
CHANGED
@@ -1,11 +1,32 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import random
|
3
2
|
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
4
5
|
|
5
6
|
@typechecked
|
6
7
|
def get_random_icon() -> str:
|
7
8
|
icons = [
|
8
|
-
|
9
|
-
|
9
|
+
"🐶",
|
10
|
+
"🐱",
|
11
|
+
"🐭",
|
12
|
+
"🐹",
|
13
|
+
"🦊",
|
14
|
+
"🐻",
|
15
|
+
"🐨",
|
16
|
+
"🐯",
|
17
|
+
"🦁",
|
18
|
+
"🐮",
|
19
|
+
"🐷",
|
20
|
+
"🍎",
|
21
|
+
"🍐",
|
22
|
+
"🍊",
|
23
|
+
"🍋",
|
24
|
+
"🍌",
|
25
|
+
"🍉",
|
26
|
+
"🍇",
|
27
|
+
"🍓",
|
28
|
+
"🍈",
|
29
|
+
"🍒",
|
30
|
+
"🍑",
|
10
31
|
]
|
11
32
|
return random.choice(icons)
|
zrb/helper/accessories/name.py
CHANGED
@@ -1,45 +1,137 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import random
|
3
2
|
import string
|
4
3
|
|
4
|
+
from zrb.helper.typecheck import typechecked
|
5
|
+
|
5
6
|
|
6
7
|
@typechecked
|
7
8
|
def get_random_name(
|
8
|
-
separator: str =
|
9
|
-
add_random_digit: bool = True,
|
10
|
-
digit_count: int = 4
|
9
|
+
separator: str = "-", add_random_digit: bool = True, digit_count: int = 4
|
11
10
|
) -> str:
|
12
11
|
prefixes = [
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
"albedo",
|
13
|
+
"argent",
|
14
|
+
"argentum",
|
15
|
+
"aurora",
|
16
|
+
"aurum",
|
17
|
+
"azure",
|
18
|
+
"basilisk",
|
19
|
+
"cerulean",
|
20
|
+
"chimeric",
|
21
|
+
"citrin",
|
22
|
+
"coral",
|
23
|
+
"crimson",
|
24
|
+
"diamond",
|
25
|
+
"draco",
|
26
|
+
"dragon",
|
27
|
+
"emerald",
|
28
|
+
"ethereal",
|
29
|
+
"ferrum",
|
30
|
+
"flammeus",
|
31
|
+
"garnet",
|
32
|
+
"glacial",
|
33
|
+
"glimmering",
|
34
|
+
"glistening",
|
35
|
+
"golden",
|
36
|
+
"helios",
|
37
|
+
"igneous",
|
38
|
+
"imperial",
|
39
|
+
"jade",
|
40
|
+
"luminous",
|
41
|
+
"luna",
|
42
|
+
"lunar",
|
43
|
+
"mystic",
|
44
|
+
"nephrite",
|
45
|
+
"nocturnal",
|
46
|
+
"obsidian",
|
47
|
+
"opal",
|
48
|
+
"pearl",
|
49
|
+
"platinum",
|
50
|
+
"prismatic",
|
51
|
+
"ruby",
|
52
|
+
"sapphire",
|
53
|
+
"serpentine",
|
54
|
+
"silver",
|
55
|
+
"sol",
|
56
|
+
"solar",
|
57
|
+
"spiritual",
|
58
|
+
"stellar",
|
59
|
+
"tempest",
|
60
|
+
"topaz",
|
61
|
+
"turquoise",
|
62
|
+
"verde",
|
63
|
+
"vermillion",
|
64
|
+
"vitreous",
|
65
|
+
"zephyr",
|
66
|
+
"zircon",
|
22
67
|
]
|
23
68
|
suffixes = [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
69
|
+
"aether",
|
70
|
+
"albedo",
|
71
|
+
"alchemy",
|
72
|
+
"arcana",
|
73
|
+
"aureum",
|
74
|
+
"aetheris",
|
75
|
+
"anima",
|
76
|
+
"astralis",
|
77
|
+
"caelestis",
|
78
|
+
"chrysopoeia",
|
79
|
+
"cosmicum",
|
80
|
+
"crystallum",
|
81
|
+
"deum",
|
82
|
+
"divinitas",
|
83
|
+
"draconis",
|
84
|
+
"elementorum",
|
85
|
+
"elixir",
|
86
|
+
"essentia",
|
87
|
+
"eternis",
|
88
|
+
"ethereus",
|
89
|
+
"fatum",
|
90
|
+
"flamma",
|
91
|
+
"fulgur",
|
92
|
+
"hermetica",
|
93
|
+
"ignis",
|
94
|
+
"illuminationis",
|
95
|
+
"imperium",
|
96
|
+
"incantatum",
|
97
|
+
"infinitum",
|
98
|
+
"lapis",
|
99
|
+
"lux",
|
100
|
+
"magicae",
|
101
|
+
"magnum",
|
102
|
+
"materia",
|
103
|
+
"metallum",
|
104
|
+
"mysticum",
|
105
|
+
"natura",
|
106
|
+
"occultum",
|
107
|
+
"omnipotentis",
|
108
|
+
"opulentia",
|
109
|
+
"philosophia",
|
110
|
+
"philosophorum",
|
111
|
+
"praeparatum",
|
112
|
+
"praestantissimum",
|
113
|
+
"prima",
|
114
|
+
"primordium",
|
115
|
+
"quintessentia",
|
116
|
+
"regeneratio",
|
117
|
+
"ritualis",
|
118
|
+
"sanctum",
|
119
|
+
"spiritus",
|
120
|
+
"tenebris",
|
121
|
+
"terra",
|
122
|
+
"tinctura",
|
123
|
+
"transmutationis",
|
124
|
+
"universalis",
|
125
|
+
"vapores",
|
126
|
+
"venenum",
|
127
|
+
"veritas",
|
128
|
+
"vitae",
|
129
|
+
"volatus",
|
36
130
|
]
|
37
131
|
prefix = random.choice(prefixes)
|
38
132
|
suffix = random.choice(suffixes)
|
39
133
|
parts = [prefix, suffix]
|
40
134
|
if add_random_digit:
|
41
|
-
random_digit =
|
42
|
-
random.choices(string.digits, k=digit_count)
|
43
|
-
)
|
135
|
+
random_digit = "".join(random.choices(string.digits, k=digit_count))
|
44
136
|
parts.append(random_digit)
|
45
137
|
return separator.join(parts)
|
zrb/helper/advertisement.py
CHANGED
@@ -1,33 +1,29 @@
|
|
1
|
-
from zrb.helper.typing import Iterable, Optional
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
|
-
from zrb.helper.accessories.color import colored
|
4
|
-
|
5
1
|
import datetime
|
6
2
|
import random
|
7
3
|
import re
|
8
4
|
import sys
|
9
5
|
|
6
|
+
from zrb.helper.accessories.color import colored
|
7
|
+
from zrb.helper.typecheck import typechecked
|
8
|
+
from zrb.helper.typing import Iterable, Optional
|
9
|
+
|
10
10
|
|
11
11
|
@typechecked
|
12
|
-
class Advertisement
|
13
|
-
def __init__(self, content: str, time_pattern: str =
|
12
|
+
class Advertisement:
|
13
|
+
def __init__(self, content: str, time_pattern: str = ".*"):
|
14
14
|
self.time_pattern = time_pattern
|
15
15
|
self.content = content
|
16
16
|
|
17
17
|
def show(self):
|
18
|
-
print(colored(self.content, attrs=[
|
18
|
+
print(colored(self.content, attrs=["dark"]), file=sys.stderr)
|
19
19
|
|
20
20
|
|
21
21
|
@typechecked
|
22
22
|
def get_advertisement(
|
23
|
-
advertisements: Iterable[Advertisement]
|
23
|
+
advertisements: Iterable[Advertisement],
|
24
24
|
) -> Optional[Advertisement]:
|
25
25
|
now = datetime.datetime.now().isoformat()
|
26
|
-
candidates = [
|
27
|
-
adv
|
28
|
-
for adv in advertisements
|
29
|
-
if re.match(adv.time_pattern, now)
|
30
|
-
]
|
26
|
+
candidates = [adv for adv in advertisements if re.match(adv.time_pattern, now)]
|
31
27
|
if len(candidates) == 0:
|
32
28
|
return None
|
33
29
|
return random.choice(candidates)
|
zrb/helper/callable.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
from typing import Any, Callable
|
2
1
|
import inspect
|
2
|
+
from typing import Any, Callable
|
3
3
|
|
4
4
|
|
5
|
-
async def run_async(
|
6
|
-
fn: Callable, *args: Any, **kwargs: Any
|
7
|
-
) -> Any:
|
5
|
+
async def run_async(fn: Callable, *args: Any, **kwargs: Any) -> Any:
|
8
6
|
if inspect.iscoroutinefunction(fn):
|
9
7
|
return await fn(*args, **kwargs)
|
10
8
|
return fn(*args, **kwargs)
|
zrb/helper/cli.py
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
|
-
from zrb.runner import runner
|
3
|
-
from zrb.config.config import (
|
4
|
-
init_scripts, should_load_builtin, version, logging_level
|
5
|
-
)
|
6
|
-
from zrb.helper.loader.load_module import load_module
|
7
|
-
from zrb.helper.log import logger
|
8
|
-
from zrb.helper.accessories.color import colored
|
9
|
-
from functools import lru_cache
|
10
|
-
|
11
|
-
import click
|
12
1
|
import logging
|
13
2
|
import os
|
14
3
|
import sys
|
4
|
+
from functools import lru_cache
|
15
5
|
|
16
|
-
|
6
|
+
import click
|
7
|
+
|
8
|
+
from zrb.config.config import init_scripts, logging_level, should_load_builtin, version
|
9
|
+
from zrb.helper.accessories.color import colored
|
10
|
+
from zrb.helper.loader.load_module import load_module
|
11
|
+
from zrb.helper.log import logger
|
12
|
+
from zrb.helper.typecheck import typechecked
|
13
|
+
from zrb.runner import runner
|
14
|
+
|
15
|
+
HELP = f"""
|
17
16
|
bb
|
18
17
|
zzzzz rr rr bb
|
19
18
|
zz rrr r bbbbbb
|
@@ -26,7 +25,7 @@ Super framework for your super app.
|
|
26
25
|
☕ Donate at: https://stalchmst.com/donation
|
27
26
|
🐙 Submit issues/PR at: https://github.com/state-alchemists/zrb
|
28
27
|
🐤 Follow us at: https://twitter.com/zarubastalchmst
|
29
|
-
|
28
|
+
"""
|
30
29
|
|
31
30
|
|
32
31
|
class MultilineHelpClickGroup(click.Group):
|
@@ -38,27 +37,26 @@ class MultilineHelpClickGroup(click.Group):
|
|
38
37
|
@typechecked
|
39
38
|
def create_cli() -> click.Group:
|
40
39
|
if logging_level <= logging.INFO:
|
41
|
-
logger.info(colored(
|
42
|
-
zrb_cli_group = MultilineHelpClickGroup(name=
|
40
|
+
logger.info(colored("Prepare CLI", attrs=["dark"]))
|
41
|
+
zrb_cli_group = MultilineHelpClickGroup(name="zrb", help=HELP)
|
43
42
|
# load from ZRB_INIT_SCRIPTS environment
|
44
43
|
for init_script in init_scripts:
|
45
44
|
if logging_level <= logging.INFO:
|
46
|
-
logger.info(colored(
|
47
|
-
f'Load modules from {init_script}', attrs=['dark']
|
48
|
-
))
|
45
|
+
logger.info(colored(f"Load modules from {init_script}", attrs=["dark"]))
|
49
46
|
load_module(script_path=init_script)
|
50
47
|
# Load default tasks
|
51
48
|
if should_load_builtin:
|
52
49
|
if logging_level <= logging.INFO:
|
53
|
-
logger.info(colored(
|
50
|
+
logger.info(colored("Load builtins", attrs=["dark"]))
|
54
51
|
from zrb import builtin
|
52
|
+
|
55
53
|
assert builtin
|
56
54
|
# Load zrb_init.py
|
57
|
-
project_dir = os.getenv(
|
55
|
+
project_dir = os.getenv("ZRB_PROJECT_DIR", os.getcwd())
|
58
56
|
_load_zrb_init(project_dir)
|
59
57
|
# Serve all tasks registered to runner
|
60
58
|
if logging_level <= logging.INFO:
|
61
|
-
logger.info(colored(
|
59
|
+
logger.info(colored("Serve CLI", attrs=["dark"]))
|
62
60
|
cli = runner.serve(zrb_cli_group)
|
63
61
|
return cli
|
64
62
|
|
@@ -66,26 +64,24 @@ def create_cli() -> click.Group:
|
|
66
64
|
@lru_cache
|
67
65
|
@typechecked
|
68
66
|
def _load_zrb_init(project_dir: str):
|
69
|
-
project_script = os.path.join(project_dir,
|
67
|
+
project_script = os.path.join(project_dir, "zrb_init.py")
|
70
68
|
if not os.path.isfile(project_script):
|
71
69
|
return
|
72
70
|
sys.path.append(project_dir)
|
73
71
|
if logging_level <= logging.INFO:
|
74
|
-
logger.info(colored(f
|
72
|
+
logger.info(colored(f"Set sys.path to {sys.path}", attrs=["dark"]))
|
75
73
|
python_path = _get_new_python_path(project_dir)
|
76
74
|
if logging_level <= logging.INFO:
|
77
|
-
logger.info(
|
78
|
-
|
79
|
-
)
|
80
|
-
os.environ['PYTHONPATH'] = python_path
|
75
|
+
logger.info(colored(f"Set PYTHONPATH to {python_path}", attrs=["dark"]))
|
76
|
+
os.environ["PYTHONPATH"] = python_path
|
81
77
|
if logging_level <= logging.INFO:
|
82
|
-
logger.info(colored(f
|
78
|
+
logger.info(colored(f"Load modules from {project_script}", attrs=["dark"]))
|
83
79
|
load_module(script_path=project_script)
|
84
80
|
|
85
81
|
|
86
82
|
@typechecked
|
87
83
|
def _get_new_python_path(project_dir: str) -> str:
|
88
|
-
current_python_path = os.getenv(
|
89
|
-
if current_python_path is None or current_python_path ==
|
84
|
+
current_python_path = os.getenv("PYTHONPATH")
|
85
|
+
if current_python_path is None or current_python_path == "":
|
90
86
|
return project_dir
|
91
|
-
return
|
87
|
+
return ":".join([current_python_path, project_dir])
|
@@ -1,12 +1,11 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import libcst as cst
|
3
2
|
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
4
5
|
|
5
6
|
@typechecked
|
6
7
|
class AddArgumentTransformer(cst.CSTTransformer):
|
7
|
-
def __init__(
|
8
|
-
self, function_name: str, argument_name: str, argument_type: str
|
9
|
-
):
|
8
|
+
def __init__(self, function_name: str, argument_name: str, argument_type: str):
|
10
9
|
self.function_name = function_name
|
11
10
|
self.argument_name = argument_name
|
12
11
|
self.argument_type = argument_type
|
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import libcst as cst
|
3
2
|
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
4
5
|
|
5
6
|
@typechecked
|
6
7
|
class AddArgumentTransformer(cst.CSTTransformer):
|
@@ -9,16 +10,12 @@ class AddArgumentTransformer(cst.CSTTransformer):
|
|
9
10
|
self.argument_name = argument_name
|
10
11
|
super().__init__()
|
11
12
|
|
12
|
-
def leave_Call(
|
13
|
-
self, original_node: cst.Call, updated_node: cst.Call
|
14
|
-
) -> cst.Call:
|
13
|
+
def leave_Call(self, original_node: cst.Call, updated_node: cst.Call) -> cst.Call:
|
15
14
|
if (
|
16
15
|
isinstance(updated_node.func, cst.Name)
|
17
16
|
and updated_node.func.value == self.function_name
|
18
17
|
):
|
19
|
-
new_args = updated_node.args + (
|
20
|
-
cst.Arg(cst.Name(self.argument_name)),
|
21
|
-
)
|
18
|
+
new_args = updated_node.args + (cst.Arg(cst.Name(self.argument_name)),)
|
22
19
|
return updated_node.with_changes(args=new_args)
|
23
20
|
return updated_node
|
24
21
|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import libcst as cst
|
3
2
|
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
4
5
|
|
5
6
|
@typechecked
|
6
7
|
def add_assert_resource(code: str, resource: str) -> str:
|
@@ -19,12 +20,11 @@ def add_assert_resource(code: str, resource: str) -> str:
|
|
19
20
|
module = cst.parse_module(code)
|
20
21
|
|
21
22
|
# Create the new assertion statement
|
22
|
-
new_assert = cst.SimpleStatementLine(
|
23
|
-
|
24
|
-
test=cst.Name(value=resource),
|
25
|
-
|
26
|
-
|
27
|
-
])
|
23
|
+
new_assert = cst.SimpleStatementLine(
|
24
|
+
[
|
25
|
+
cst.Assert(test=cst.Name(value=resource), msg=None),
|
26
|
+
]
|
27
|
+
)
|
28
28
|
|
29
29
|
module.body.append(new_assert)
|
30
30
|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
1
|
import libcst as cst
|
3
2
|
|
3
|
+
from zrb.helper.typecheck import typechecked
|
4
|
+
|
4
5
|
|
5
6
|
@typechecked
|
6
7
|
def add_function_call(code: str, function_name: str, parameters: list) -> str:
|
@@ -23,10 +24,7 @@ def add_function_call(code: str, function_name: str, parameters: list) -> str:
|
|
23
24
|
new_function_call = cst.Expr(
|
24
25
|
value=cst.Call(
|
25
26
|
func=cst.Name(value=function_name),
|
26
|
-
args=[
|
27
|
-
cst.Arg(value=cst.parse_expression(param))
|
28
|
-
for param in parameters
|
29
|
-
]
|
27
|
+
args=[cst.Arg(value=cst.parse_expression(param)) for param in parameters],
|
30
28
|
)
|
31
29
|
)
|
32
30
|
|