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/helper/docstring.py
CHANGED
@@ -14,14 +14,14 @@ def get_markdown_from_docstring(cls) -> str:
|
|
14
14
|
"""
|
15
15
|
markdown = f"## `{cls.__name__}`\n\n"
|
16
16
|
cls_doc = get_doc(cls)
|
17
|
-
markdown += parse_docstring(cls_doc) +
|
17
|
+
markdown += parse_docstring(cls_doc) + "\n"
|
18
18
|
for method_name, _ in inspect.getmembers(cls, predicate=inspect.isfunction): # noqa
|
19
|
-
if method_name.startswith(
|
19
|
+
if method_name.startswith("__"):
|
20
20
|
# Don't parse private or protected function
|
21
21
|
continue
|
22
22
|
markdown += f"\n### `{cls.__name__}.{method_name}`\n\n"
|
23
23
|
method_doc = get_method_doc(cls, method_name)
|
24
|
-
markdown += parse_docstring(method_doc) +
|
24
|
+
markdown += parse_docstring(method_doc) + "\n"
|
25
25
|
return markdown
|
26
26
|
|
27
27
|
|
@@ -29,7 +29,7 @@ def get_method_doc(cls, method_name: str) -> str:
|
|
29
29
|
if not hasattr(cls, method_name):
|
30
30
|
return None
|
31
31
|
method = getattr(cls, method_name)
|
32
|
-
if not method.__doc__ and hasattr(cls,
|
32
|
+
if not method.__doc__ and hasattr(cls, "__bases__"):
|
33
33
|
for parent in cls.__bases__:
|
34
34
|
parent_method_doc = get_method_doc(parent, method_name)
|
35
35
|
if parent_method_doc:
|
@@ -38,7 +38,7 @@ def get_method_doc(cls, method_name: str) -> str:
|
|
38
38
|
|
39
39
|
|
40
40
|
def get_doc(cls) -> str:
|
41
|
-
if not cls.__doc__ and hasattr(cls,
|
41
|
+
if not cls.__doc__ and hasattr(cls, "__bases__"):
|
42
42
|
for parent in cls.__bases__:
|
43
43
|
parent_doc = get_doc(parent)
|
44
44
|
if parent_doc:
|
@@ -48,88 +48,85 @@ def get_doc(cls) -> str:
|
|
48
48
|
|
49
49
|
def parse_docstring(docstring: str) -> str:
|
50
50
|
if not docstring:
|
51
|
-
return
|
51
|
+
return "No documentation available.\n"
|
52
52
|
# Split the docstring into lines
|
53
|
-
lines = docstring.strip().split(
|
53
|
+
lines = docstring.strip().split("\n")
|
54
54
|
line_length = len(lines)
|
55
55
|
# Process each line
|
56
56
|
markdown_lines = []
|
57
|
-
section =
|
57
|
+
section = ""
|
58
58
|
is_previous_code = False
|
59
59
|
has_unclosed_backtick = False
|
60
60
|
for line_index, line in enumerate(lines):
|
61
61
|
line = line.strip()
|
62
|
-
is_code = line.startswith(
|
62
|
+
is_code = line.startswith(">>> ")
|
63
63
|
is_last_line = line_index == line_length - 1
|
64
64
|
is_new_section = False
|
65
65
|
# Add code backticks
|
66
66
|
if is_code and not is_previous_code:
|
67
|
-
markdown_lines.append(
|
67
|
+
markdown_lines.append("```python")
|
68
68
|
has_unclosed_backtick = True
|
69
|
-
elif section ==
|
70
|
-
markdown_lines.append(
|
71
|
-
markdown_lines.append(
|
72
|
-
markdown_lines.append(
|
69
|
+
elif section == "examples" and is_previous_code and not is_code:
|
70
|
+
markdown_lines.append("```")
|
71
|
+
markdown_lines.append("")
|
72
|
+
markdown_lines.append("```")
|
73
73
|
has_unclosed_backtick = True
|
74
74
|
elif is_previous_code and not is_code:
|
75
|
-
markdown_lines.append(
|
76
|
-
markdown_lines.append(
|
75
|
+
markdown_lines.append("````")
|
76
|
+
markdown_lines.append("")
|
77
77
|
has_unclosed_backtick = False
|
78
78
|
# Handle lines
|
79
79
|
if is_code:
|
80
80
|
markdown_lines.append(line[4:])
|
81
81
|
elif (
|
82
|
-
line.startswith(
|
83
|
-
line.startswith(
|
84
|
-
line.startswith(
|
85
|
-
line.startswith(
|
82
|
+
line.startswith("Attributes:")
|
83
|
+
or line.startswith("Attribute:")
|
84
|
+
or line.startswith("Attrs:")
|
85
|
+
or line.startswith("Attr:")
|
86
86
|
):
|
87
|
-
markdown_lines.append(
|
88
|
-
section =
|
87
|
+
markdown_lines.append("__Attributes:__\n")
|
88
|
+
section = "attributes"
|
89
89
|
is_new_section = True
|
90
90
|
elif (
|
91
|
-
line.startswith(
|
92
|
-
line.startswith(
|
93
|
-
line.startswith(
|
94
|
-
line.startswith(
|
91
|
+
line.startswith("Args:")
|
92
|
+
or line.startswith("Arg:")
|
93
|
+
or line.startswith("Arguments:")
|
94
|
+
or line.startswith("Argument:")
|
95
95
|
):
|
96
|
-
markdown_lines.append(
|
97
|
-
section =
|
96
|
+
markdown_lines.append("__Arguments:__\n")
|
97
|
+
section = "args"
|
98
98
|
is_new_section = True
|
99
|
-
elif line.startswith(
|
100
|
-
markdown_lines.append(
|
101
|
-
section =
|
99
|
+
elif line.startswith("Returns:"):
|
100
|
+
markdown_lines.append("__Returns:__\n")
|
101
|
+
section = "returns"
|
102
102
|
is_new_section = True
|
103
|
-
elif (
|
104
|
-
|
105
|
-
|
106
|
-
):
|
107
|
-
markdown_lines.append('__Examples:__\n')
|
108
|
-
section = 'examples'
|
103
|
+
elif line.startswith("Examples:") or line.startswith("Examples:"):
|
104
|
+
markdown_lines.append("__Examples:__\n")
|
105
|
+
section = "examples"
|
109
106
|
is_new_section = True
|
110
|
-
elif line ==
|
107
|
+
elif line == "```":
|
111
108
|
markdown_lines.append(line)
|
112
|
-
elif section ==
|
113
|
-
named_param_match = re.match(r
|
109
|
+
elif section == "args" or section == "attributes":
|
110
|
+
named_param_match = re.match(r"^(\w+)\s+\((.+)\):(.+)$", line)
|
114
111
|
if named_param_match:
|
115
112
|
param_name, param_type, param_desc = named_param_match.groups()
|
116
113
|
markdown_lines.append(
|
117
|
-
f
|
114
|
+
f"- `{param_name}` (`{param_type}`): {param_desc.strip()}"
|
118
115
|
)
|
119
116
|
else:
|
120
117
|
markdown_lines.append(line)
|
121
|
-
elif section ==
|
122
|
-
return_match = re.match(r
|
118
|
+
elif section == "returns":
|
119
|
+
return_match = re.match(r"^(.+):(.+)$", line)
|
123
120
|
if return_match:
|
124
121
|
param_type, param_desc = return_match.groups()
|
125
|
-
markdown_lines.append(f
|
122
|
+
markdown_lines.append(f"`{param_type}`: {param_desc.strip()}")
|
126
123
|
else:
|
127
124
|
markdown_lines.append(line)
|
128
125
|
else:
|
129
126
|
markdown_lines.append(line)
|
130
127
|
is_previous_code = is_code
|
131
128
|
if (is_new_section or is_last_line) and has_unclosed_backtick:
|
132
|
-
markdown_lines.append(
|
133
|
-
markdown_lines.append(
|
129
|
+
markdown_lines.append("```")
|
130
|
+
markdown_lines.append("")
|
134
131
|
has_unclosed_backtick = False
|
135
|
-
return
|
132
|
+
return "\n".join(markdown_lines)
|
zrb/helper/env_map/fetch.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
from zrb.helper.string.jinja import is_probably_jinja
|
1
2
|
from zrb.helper.typecheck import typechecked
|
2
3
|
from zrb.helper.typing import List, Mapping
|
3
|
-
from zrb.task_group.group import Group
|
4
4
|
from zrb.task.any_task import AnyTask
|
5
5
|
from zrb.task_env.env import Env
|
6
|
-
from zrb.
|
6
|
+
from zrb.task_group.group import Group
|
7
7
|
|
8
8
|
|
9
9
|
@typechecked
|
@@ -13,17 +13,13 @@ def fetch_env_map_from_group(
|
|
13
13
|
for task in group.get_tasks():
|
14
14
|
env_map = fetch_env_map_from_task(env_map, task)
|
15
15
|
for sub_group in group.get_children():
|
16
|
-
sub_env_map: Mapping[str, str] = fetch_env_map_from_group(
|
17
|
-
env_map, sub_group
|
18
|
-
)
|
16
|
+
sub_env_map: Mapping[str, str] = fetch_env_map_from_group(env_map, sub_group)
|
19
17
|
env_map = _cascade_env_map(env_map, sub_env_map)
|
20
18
|
return env_map
|
21
19
|
|
22
20
|
|
23
21
|
@typechecked
|
24
|
-
def fetch_env_map_from_task(
|
25
|
-
env_map: Mapping[str, str], task: AnyTask
|
26
|
-
):
|
22
|
+
def fetch_env_map_from_task(env_map: Mapping[str, str], task: AnyTask):
|
27
23
|
task_env_map: Mapping[str, str] = {}
|
28
24
|
for env_file in task._get_env_files():
|
29
25
|
envs = env_file.get_envs()
|
@@ -42,7 +38,7 @@ def _add_envs_to_env_map(
|
|
42
38
|
env_map: Mapping[str, str], envs: List[Env]
|
43
39
|
) -> Mapping[str, str]:
|
44
40
|
for env in envs:
|
45
|
-
if env.get_os_name() ==
|
41
|
+
if env.get_os_name() == "":
|
46
42
|
continue
|
47
43
|
env_name = _get_env_name(env)
|
48
44
|
env_default = _get_env_default(env)
|
@@ -52,8 +48,7 @@ def _add_envs_to_env_map(
|
|
52
48
|
|
53
49
|
@typechecked
|
54
50
|
def _cascade_env_map(
|
55
|
-
env_map: Mapping[str, str],
|
56
|
-
other_env_map: Mapping[str, str]
|
51
|
+
env_map: Mapping[str, str], other_env_map: Mapping[str, str]
|
57
52
|
) -> Mapping[str, str]:
|
58
53
|
for key, value in other_env_map.items():
|
59
54
|
if key in env_map:
|
@@ -72,5 +67,5 @@ def _get_env_name(env: Env) -> str:
|
|
72
67
|
@typechecked
|
73
68
|
def _get_env_default(env: Env) -> str:
|
74
69
|
if is_probably_jinja(env.get_default()):
|
75
|
-
return
|
70
|
+
return ""
|
76
71
|
return env.get_default()
|
zrb/helper/file/copy_tree.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
from zrb.helper.typing import Iterable, Mapping, Optional
|
3
|
-
from zrb.helper.typecheck import typechecked
|
4
|
-
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
5
|
-
from zrb.helper.string.parse_replacement import parse_replacement
|
6
|
-
from zrb.helper.log import logger
|
7
|
-
|
1
|
+
import fnmatch
|
8
2
|
import logging
|
9
3
|
import os
|
10
4
|
import shutil
|
11
|
-
|
5
|
+
|
6
|
+
from zrb.config.config import logging_level
|
7
|
+
from zrb.helper.file.text import read_text_file_async, write_text_file_async
|
8
|
+
from zrb.helper.log import logger
|
9
|
+
from zrb.helper.string.parse_replacement import parse_replacement
|
10
|
+
from zrb.helper.typecheck import typechecked
|
11
|
+
from zrb.helper.typing import Iterable, Mapping, Optional
|
12
12
|
|
13
13
|
|
14
14
|
@typechecked
|
@@ -17,7 +17,7 @@ async def copy_tree(
|
|
17
17
|
dst: str,
|
18
18
|
replacements: Optional[Mapping[str, str]] = None,
|
19
19
|
excludes: Optional[Iterable[str]] = None,
|
20
|
-
skip_parsing: Optional[Iterable[str]] = None
|
20
|
+
skip_parsing: Optional[Iterable[str]] = None,
|
21
21
|
):
|
22
22
|
if replacements is None:
|
23
23
|
replacements = {}
|
@@ -35,21 +35,16 @@ async def copy_tree(
|
|
35
35
|
continue
|
36
36
|
dst_name = os.path.join(dst, name)
|
37
37
|
if os.path.isdir(src_name):
|
38
|
-
await copy_tree(
|
39
|
-
src_name, dst_name, replacements, excludes, skip_parsing
|
40
|
-
)
|
38
|
+
await copy_tree(src_name, dst_name, replacements, excludes, skip_parsing)
|
41
39
|
continue
|
42
40
|
new_dst_name = parse_replacement(dst_name, replacements)
|
43
41
|
shutil.copy2(src_name, new_dst_name)
|
44
42
|
try:
|
45
|
-
if any(
|
46
|
-
fnmatch.fnmatch(new_dst_name, pattern)
|
47
|
-
for pattern in skip_parsing
|
48
|
-
):
|
43
|
+
if any(fnmatch.fnmatch(new_dst_name, pattern) for pattern in skip_parsing):
|
49
44
|
continue
|
50
45
|
file_content = await read_text_file_async(new_dst_name)
|
51
46
|
new_file_content = parse_replacement(file_content, replacements)
|
52
47
|
await write_text_file_async(new_dst_name, new_file_content)
|
53
48
|
except Exception:
|
54
49
|
if logging_level <= logging.ERROR:
|
55
|
-
logger.error(f
|
50
|
+
logger.error(f"Cannot parse file: {new_dst_name}")
|
zrb/helper/file/match.py
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
from zrb.helper.typing import List, Iterable
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
1
|
import fnmatch
|
4
2
|
import glob
|
5
3
|
|
4
|
+
from zrb.helper.typecheck import typechecked
|
5
|
+
from zrb.helper.typing import Iterable, List
|
6
|
+
|
6
7
|
|
7
8
|
@typechecked
|
8
|
-
def get_file_names(
|
9
|
-
glob_path: str, glob_ignored_paths: Iterable[str]
|
10
|
-
) -> List[str]:
|
9
|
+
def get_file_names(glob_path: str, glob_ignored_paths: Iterable[str]) -> List[str]:
|
11
10
|
matches = []
|
12
11
|
for file in glob.glob(glob_path, recursive=True):
|
13
12
|
should_ignore = any(
|
14
|
-
fnmatch.fnmatch(file, ignored_path)
|
15
|
-
fnmatch.fnmatch(file, ignored_path +
|
13
|
+
fnmatch.fnmatch(file, ignored_path)
|
14
|
+
or fnmatch.fnmatch(file, ignored_path + "**")
|
16
15
|
for ignored_path in glob_ignored_paths
|
17
16
|
)
|
18
17
|
if not should_ignore:
|
zrb/helper/file/text.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
|
-
import aiofiles
|
3
1
|
import os
|
4
2
|
|
3
|
+
import aiofiles
|
4
|
+
|
5
|
+
from zrb.helper.typecheck import typechecked
|
6
|
+
|
5
7
|
|
6
8
|
@typechecked
|
7
9
|
async def read_text_file_async(file_name: str) -> str:
|
8
|
-
async with aiofiles.open(file_name, mode=
|
10
|
+
async with aiofiles.open(file_name, mode="r") as file:
|
9
11
|
content = await file.read()
|
10
12
|
return content
|
11
13
|
|
@@ -13,14 +15,14 @@ async def read_text_file_async(file_name: str) -> str:
|
|
13
15
|
@typechecked
|
14
16
|
async def write_text_file_async(file_name: str, content: str):
|
15
17
|
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
16
|
-
async with aiofiles.open(file_name, mode=
|
18
|
+
async with aiofiles.open(file_name, mode="w") as file:
|
17
19
|
await file.write(content)
|
18
20
|
|
19
21
|
|
20
22
|
@typechecked
|
21
23
|
async def append_text_file_async(file_name: str, additional_content: str):
|
22
24
|
content = await read_text_file_async(file_name)
|
23
|
-
if content !=
|
24
|
-
additional_content =
|
25
|
+
if content != "":
|
26
|
+
additional_content = "\n" + additional_content
|
25
27
|
new_content = content + additional_content
|
26
28
|
await write_text_file_async(file_name, new_content)
|
zrb/helper/git/detect_changes.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
import subprocess
|
2
|
+
|
1
3
|
from zrb.helper.typecheck import typechecked
|
2
4
|
from zrb.helper.typing import Mapping
|
3
|
-
import subprocess
|
4
5
|
|
5
6
|
|
6
7
|
@typechecked
|
7
|
-
class ModificationState
|
8
|
+
class ModificationState:
|
8
9
|
def __init__(self):
|
9
10
|
self.plus: bool = False
|
10
11
|
self.minus: bool = False
|
@@ -12,23 +13,23 @@ class ModificationState():
|
|
12
13
|
|
13
14
|
@typechecked
|
14
15
|
def get_modified_file_states(commit: str) -> Mapping[str, ModificationState]:
|
15
|
-
exit_status, output = subprocess.getstatusoutput(f
|
16
|
+
exit_status, output = subprocess.getstatusoutput(f"git show {commit}")
|
16
17
|
if exit_status != 0:
|
17
18
|
raise Exception(output)
|
18
|
-
lines = output.split(
|
19
|
+
lines = output.split("\n")
|
19
20
|
modified_files: Mapping[str, ModificationState] = {}
|
20
21
|
for line in lines:
|
21
|
-
if not line.startswith(
|
22
|
+
if not line.startswith("---") and not line.startswith("+++"):
|
22
23
|
continue
|
23
|
-
if line[4:6] !=
|
24
|
+
if line[4:6] != "a/" and line[4:6] != "b/":
|
24
25
|
continue
|
25
26
|
# line should contains something like `--- a/some-file.txt`
|
26
27
|
file = line[6:]
|
27
28
|
if file not in modified_files:
|
28
29
|
modified_files[file] = ModificationState()
|
29
30
|
modification_state = modified_files[file]
|
30
|
-
if line.startswith(
|
31
|
+
if line.startswith("---"):
|
31
32
|
modification_state.minus = True
|
32
|
-
if line.startswith(
|
33
|
+
if line.startswith("+++"):
|
33
34
|
modification_state.plus = True
|
34
35
|
return modified_files
|
zrb/helper/loader/load_module.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
from zrb.config.config import logging_level
|
2
|
-
from zrb.helper.typecheck import typechecked
|
3
|
-
from zrb.helper.log import logger
|
4
|
-
from zrb.helper.accessories.color import colored
|
5
|
-
from functools import lru_cache
|
6
|
-
|
7
|
-
import os
|
8
1
|
import logging
|
2
|
+
import os
|
9
3
|
import re
|
4
|
+
from functools import lru_cache
|
10
5
|
|
11
|
-
|
6
|
+
from zrb.config.config import logging_level
|
7
|
+
from zrb.helper.accessories.color import colored
|
8
|
+
from zrb.helper.log import logger
|
9
|
+
from zrb.helper.typecheck import typechecked
|
10
|
+
|
11
|
+
pattern = re.compile("[^a-zA-Z0-9]")
|
12
12
|
|
13
13
|
|
14
14
|
@lru_cache
|
@@ -17,15 +17,16 @@ def load_module(script_path: str):
|
|
17
17
|
if not os.path.isfile(script_path):
|
18
18
|
return
|
19
19
|
import importlib.util
|
20
|
-
|
20
|
+
|
21
|
+
module_name = pattern.sub("", script_path)
|
21
22
|
if logging_level <= logging.INFO:
|
22
|
-
logger.info(colored(f
|
23
|
+
logger.info(colored(f"Get module spec: {script_path}", attrs=["dark"]))
|
23
24
|
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
24
25
|
if logging_level <= logging.INFO:
|
25
|
-
logger.info(colored(f
|
26
|
+
logger.info(colored(f"Create module: {script_path}", attrs=["dark"]))
|
26
27
|
module = importlib.util.module_from_spec(spec)
|
27
28
|
if logging_level <= logging.INFO:
|
28
|
-
logger.info(colored(f
|
29
|
+
logger.info(colored(f"Exec module: {script_path}", attrs=["dark"]))
|
29
30
|
spec.loader.exec_module(module)
|
30
31
|
if logging_level <= logging.INFO:
|
31
|
-
logger.info(colored(f
|
32
|
+
logger.info(colored(f"Module executed: {script_path}", attrs=["dark"]))
|
zrb/helper/log.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
import logging
|
2
|
+
|
1
3
|
from zrb.config.config import logging_level
|
2
4
|
from zrb.helper.accessories.color import colored
|
3
|
-
import logging
|
4
5
|
|
5
6
|
# create logger
|
6
|
-
logger = logging.getLogger(
|
7
|
+
logger = logging.getLogger("zrb")
|
7
8
|
logger.setLevel(logging_level)
|
8
9
|
|
9
10
|
# create console handler and set level to debug
|
@@ -12,7 +13,7 @@ ch.setLevel(logging_level)
|
|
12
13
|
|
13
14
|
# create formatter
|
14
15
|
formatter = logging.Formatter(
|
15
|
-
colored(
|
16
|
+
colored("%(levelname)-6s %(asctime)s", attrs=["dark"]) + " %(message)s"
|
16
17
|
)
|
17
18
|
|
18
19
|
# add formatter to ch
|
zrb/helper/map/conversion.py
CHANGED
@@ -5,14 +5,13 @@ from zrb.helper.typing import Any, Mapping
|
|
5
5
|
@typechecked
|
6
6
|
def to_str(
|
7
7
|
str_map: Mapping[str, Any],
|
8
|
-
item_separator: str =
|
9
|
-
item_prefix: str =
|
10
|
-
keyval_separator: str =
|
8
|
+
item_separator: str = "\n",
|
9
|
+
item_prefix: str = "",
|
10
|
+
keyval_separator: str = " : ",
|
11
11
|
) -> str:
|
12
12
|
keys = list(str_map.keys())
|
13
13
|
keys.sort()
|
14
14
|
str_list = [
|
15
|
-
item_prefix + key + keyval_separator + str(str_map[key])
|
16
|
-
for key in keys
|
15
|
+
item_prefix + key + keyval_separator + str(str_map[key]) for key in keys
|
17
16
|
]
|
18
17
|
return item_separator.join(str_list)
|
zrb/helper/python_task.py
CHANGED
@@ -4,7 +4,5 @@ from zrb.task.task import Task
|
|
4
4
|
|
5
5
|
@typechecked
|
6
6
|
def show_lines(task: Task, *lines: str):
|
7
|
-
separator =
|
8
|
-
task.print_out(
|
9
|
-
'\n' + separator + separator.join(lines) + '\n', trim_message=False
|
10
|
-
)
|
7
|
+
separator = "\n "
|
8
|
+
task.print_out("\n" + separator + separator.join(lines) + "\n", trim_message=False)
|
zrb/helper/render_data.py
CHANGED
@@ -1,25 +1,32 @@
|
|
1
|
-
from zrb.helper.util import (
|
2
|
-
coalesce, coalesce_str, to_camel_case, to_pascal_case, to_kebab_case,
|
3
|
-
to_snake_case, to_human_readable, to_boolean
|
4
|
-
)
|
5
1
|
import datetime
|
6
2
|
import os
|
7
3
|
import platform
|
8
4
|
import time
|
9
5
|
|
6
|
+
from zrb.helper.util import (
|
7
|
+
coalesce,
|
8
|
+
coalesce_str,
|
9
|
+
to_boolean,
|
10
|
+
to_camel_case,
|
11
|
+
to_human_readable,
|
12
|
+
to_kebab_case,
|
13
|
+
to_pascal_case,
|
14
|
+
to_snake_case,
|
15
|
+
)
|
16
|
+
|
10
17
|
DEFAULT_RENDER_DATA = {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
18
|
+
"datetime": datetime,
|
19
|
+
"os": os,
|
20
|
+
"platform": platform,
|
21
|
+
"time": time,
|
22
|
+
"util": {
|
23
|
+
"coalesce": coalesce,
|
24
|
+
"coalesce_str": coalesce_str,
|
25
|
+
"to_camel_case": to_camel_case,
|
26
|
+
"to_pascal_case": to_pascal_case,
|
27
|
+
"to_kebab_case": to_kebab_case,
|
28
|
+
"to_snake_case": to_snake_case,
|
29
|
+
"to_human_readable": to_human_readable,
|
30
|
+
"to_boolean": to_boolean,
|
31
|
+
},
|
25
32
|
}
|
zrb/helper/string/constant.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
TRUE_STRS = [
|
2
|
-
FALSE_STRS = [
|
1
|
+
TRUE_STRS = ["true", "1", "yes", "y", "active", "on"]
|
2
|
+
FALSE_STRS = ["false", "0", "no", "n", "inactive", "off"]
|
zrb/helper/string/conversion.py
CHANGED
@@ -1,38 +1,39 @@
|
|
1
|
-
from zrb.helper.typecheck import typechecked
|
2
|
-
from zrb.helper.string.constant import TRUE_STRS, FALSE_STRS
|
3
1
|
import keyword
|
4
2
|
import logging
|
5
3
|
import re
|
6
4
|
|
7
|
-
|
8
|
-
|
5
|
+
from zrb.helper.string.constant import FALSE_STRS, TRUE_STRS
|
6
|
+
from zrb.helper.typecheck import typechecked
|
7
|
+
|
8
|
+
NON_WORD = re.compile(r"[\W]+")
|
9
|
+
LEADING_NUM = re.compile(r"^\d+")
|
9
10
|
LOGGING_LEVEL_MAP = {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
"critical": logging.CRITICAL,
|
12
|
+
"fatal": logging.FATAL,
|
13
|
+
"error": logging.ERROR,
|
14
|
+
"warning": logging.WARNING,
|
15
|
+
"warn": logging.WARN,
|
16
|
+
"info": logging.INFO,
|
17
|
+
"debug": logging.DEBUG,
|
18
|
+
"notset": logging.NOTSET,
|
18
19
|
}
|
19
20
|
|
20
21
|
|
21
22
|
@typechecked
|
22
23
|
def to_cli_name(name: str) -> str:
|
23
|
-
return NON_WORD.sub(
|
24
|
+
return NON_WORD.sub("-", name).strip("-").lower()
|
24
25
|
|
25
26
|
|
26
27
|
@typechecked
|
27
28
|
def to_variable_name(string: str) -> str:
|
28
29
|
# Replace any non-word characters with underscore
|
29
|
-
string = NON_WORD.sub(
|
30
|
+
string = NON_WORD.sub("_", string).strip()
|
30
31
|
# Remove leading digits
|
31
|
-
string = LEADING_NUM.sub(
|
32
|
+
string = LEADING_NUM.sub("", string)
|
32
33
|
# Convert to lowercase
|
33
34
|
string = string.lower()
|
34
35
|
if keyword.iskeyword(string):
|
35
|
-
return string +
|
36
|
+
return string + "_"
|
36
37
|
return string
|
37
38
|
|
38
39
|
|
zrb/helper/string/jinja.py
CHANGED
@@ -6,8 +6,8 @@ from zrb.helper.typing import Any
|
|
6
6
|
def is_probably_jinja(value: Any) -> bool:
|
7
7
|
if not isinstance(value, str):
|
8
8
|
return False
|
9
|
-
if
|
9
|
+
if "{{" in value and "}}" in value:
|
10
10
|
return True
|
11
|
-
if
|
11
|
+
if "{%" in value and "%}" in value:
|
12
12
|
return True
|
13
13
|
return False
|
zrb/helper/typecheck.py
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
import os
|
1
2
|
from typing import TypeVar
|
2
|
-
|
3
|
+
|
3
4
|
from beartype import beartype
|
4
|
-
import os
|
5
5
|
|
6
|
-
|
6
|
+
from zrb.helper.string.constant import FALSE_STRS
|
7
|
+
|
8
|
+
enable_type_checking_str = os.getenv("ZRB_ENABLE_TYPE_CHECKING", "1").lower()
|
7
9
|
enable_type_checking = enable_type_checking_str not in FALSE_STRS
|
8
10
|
|
9
|
-
T = TypeVar(
|
11
|
+
T = TypeVar("T")
|
10
12
|
|
11
13
|
|
12
14
|
def typechecked(anything: T) -> T:
|
zrb/helper/typing.py
CHANGED