arpakitlib 1.7.256__py3-none-any.whl → 1.8.0__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.
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/README.md +1 -1
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/admin1/add_admin_in_app.py +6 -12
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/admin1/admin_auth.py +2 -6
- arpakitlib/_arpakit_project_template_v1/admin1/model_view.py +95 -0
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/alembic/env.py +3 -3
- arpakitlib/_arpakit_project_template_v1/api/asgi.py +3 -0
- arpakitlib/_arpakit_project_template_v1/api/auth.py +244 -0
- arpakitlib/_arpakit_project_template_v1/api/const.py +18 -0
- arpakitlib/_arpakit_project_template_v1/api/create_api_app.py +72 -0
- arpakitlib/_arpakit_project_template_v1/api/event.py +69 -0
- arpakitlib/_arpakit_project_template_v1/api/exception.py +39 -0
- arpakitlib/_arpakit_project_template_v1/api/exception_handler.py +297 -0
- arpakitlib/_arpakit_project_template_v1/api/openapi_ui.py +28 -0
- arpakitlib/_arpakit_project_template_v1/api/response.py +27 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/api/router/main_router.py +3 -2
- arpakitlib/_arpakit_project_template_v1/api/router/v1/arpakitlib_.py +27 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/check_auth.py +30 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/get_errors_info.py +24 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/healthcheck.py +21 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/main_router.py +54 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/now_utc_datetime.py +21 -0
- arpakitlib/_arpakit_project_template_v1/api/router/v1/raise_fake_error.py +21 -0
- arpakitlib/_arpakit_project_template_v1/api/schema/base_schema.py +26 -0
- arpakitlib/_arpakit_project_template_v1/api/schema/common/in_.py +5 -0
- arpakitlib/_arpakit_project_template_v1/api/schema/common/out.py +60 -0
- arpakitlib/_arpakit_project_template_v1/api/schema/v1/in_.py +5 -0
- arpakitlib/_arpakit_project_template_v1/api/schema/v1/out.py +53 -0
- arpakitlib/_arpakit_project_template_v1/api/transmitted_api_data.py +66 -0
- arpakitlib/_arpakit_project_template_v1/arpakitlib_project_template.json +3 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/business_service/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v1/business_service/remove_operations.py +51 -0
- arpakitlib/_arpakit_project_template_v1/command/alembic_history.sh +2 -0
- arpakitlib/_arpakit_project_template_v1/command/alembic_revision_autogenerate.sh +2 -0
- arpakitlib/{_arpakit_project_template/manage/json_beautify.py → _arpakit_project_template_v1/command/beautify_json.py} +2 -2
- arpakitlib/{_arpakit_project_template/src/core/_check_logging.py → _arpakit_project_template_v1/command/check_logging.py} +3 -3
- arpakitlib/_arpakit_project_template_v1/command/check_sqlalchemy_db.py +11 -0
- arpakitlib/_arpakit_project_template_v1/command/drop_json_db.py +13 -0
- arpakitlib/_arpakit_project_template_v1/command/drop_sqlalchemy_db.py +14 -0
- arpakitlib/{_arpakit_project_template/src/core/_generate_settings_env_example.py → _arpakit_project_template_v1/command/generate_settings_env_example.py} +4 -4
- arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/hello_world.py +2 -2
- arpakitlib/_arpakit_project_template_v1/command/init_json_db.py +11 -0
- arpakitlib/_arpakit_project_template_v1/command/init_sqlalchemy_db.py +11 -0
- arpakitlib/_arpakit_project_template_v1/command/reinit_json_db.py +13 -0
- arpakitlib/_arpakit_project_template_v1/command/reinit_sqlalchemy_db.py +13 -0
- arpakitlib/_arpakit_project_template_v1/command/remove_operations.py +13 -0
- arpakitlib/_arpakit_project_template_v1/command/remove_story_logs.py +16 -0
- arpakitlib/_arpakit_project_template_v1/command/rm_all_records_in_json_db.py +13 -0
- arpakitlib/{_arpakit_project_template/src/core/_show_settings.py → _arpakit_project_template_v1/command/show_settings.py} +3 -3
- arpakitlib/{_arpakit_project_template/src/api/_start_api_with_reload.py → _arpakit_project_template_v1/command/start_api_with_reload.py} +5 -5
- arpakitlib/{_arpakit_project_template/src/api/_start_api_without_reload.py → _arpakit_project_template_v1/command/start_api_without_reload.py} +5 -5
- arpakitlib/_arpakit_project_template_v1/command/start_async_operation_executor_worker.py +14 -0
- arpakitlib/_arpakit_project_template_v1/command/start_async_scheduled_operation_creator_worker.py +14 -0
- arpakitlib/_arpakit_project_template_v1/command/start_sync_operation_executor_worker.py +15 -0
- arpakitlib/_arpakit_project_template_v1/command/start_sync_operation_executor_workers.py +22 -0
- arpakitlib/_arpakit_project_template_v1/command/start_sync_scheduled_operation_creator_worker.py +12 -0
- arpakitlib/_arpakit_project_template_v1/core/cache_file_storage_in_dir.py +21 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/core/const.py +2 -9
- arpakitlib/_arpakit_project_template_v1/core/dump_file_storage_in_dir.py +21 -0
- arpakitlib/_arpakit_project_template_v1/core/media_file_storage_in_dir.py +21 -0
- arpakitlib/_arpakit_project_template_v1/core/settings.py +193 -0
- arpakitlib/_arpakit_project_template_v1/core/util.py +29 -0
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/example.env +10 -5
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/json_db/util.py +2 -2
- arpakitlib/_arpakit_project_template_v1/operation_execution/operation_executor_worker.py +256 -0
- arpakitlib/_arpakit_project_template_v1/operation_execution/scheduled_operation_creator_worker.py +106 -0
- arpakitlib/_arpakit_project_template_v1/operation_execution/scheduled_operations.py +49 -0
- arpakitlib/_arpakit_project_template_v1/operation_execution/util.py +29 -0
- arpakitlib/_arpakit_project_template_v1/resource/static/openapi-favicon.png +0 -0
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/index.html +19 -0
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/swagger-ui-bundle.js +2 -0
- arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui-es-bundle-core.js +1 -1
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/swagger-ui-es-bundle-core.js.map +1 -0
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/swagger-ui-es-bundle.js +2 -0
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/swagger-ui-standalone-preset.js +2 -0
- arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui.js +1 -1
- arpakitlib/_arpakit_project_template_v1/resource/static/swagger-ui/swagger-ui.js.map +1 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_1.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_2.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_3.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_4.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_5.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_6.py +14 -0
- arpakitlib/_arpakit_project_template_v1/sandbox/sandbox_7.py +14 -0
- arpakitlib/{_arpakit_project_template/src/sqlalchemy_db/util.py → _arpakit_project_template_v1/sqlalchemy_db/sqlalchemy_db.py} +3 -11
- arpakitlib/_arpakit_project_template_v1/sqlalchemy_db/sqlalchemy_model.py +129 -0
- arpakitlib/_arpakit_project_template_v1/sqlalchemy_db/util.py +28 -0
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_3.py → _arpakit_project_template_v1/test_data/make_test_data_1.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_4.py → _arpakit_project_template_v1/test_data/make_test_data_2.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_1.py → _arpakit_project_template_v1/test_data/make_test_data_3.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_2.py → _arpakit_project_template_v1/test_data/make_test_data_4.py} +8 -3
- arpakitlib/_arpakit_project_template_v1/test_data/make_test_data_5.py +22 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/blank/blank.py +5 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/blank/util.py +1 -1
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/const.py +6 -3
- arpakitlib/_arpakit_project_template_v1/tg_bot/event.py +51 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/filter/not_prod_mode.py +1 -1
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/filter/prod_mode.py +1 -1
- arpakitlib/_arpakit_project_template_v1/tg_bot/middleware/init_user.py +24 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/middleware/middleware.py +12 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/router/arpakitlib_.py +10 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/router/error.py +15 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/router/healthcheck.py +10 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/router/main_router.py +14 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/start_tg_bot.py +34 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/tg_bot.py +24 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/tg_bot_dispatcher.py +19 -0
- arpakitlib/_arpakit_project_template_v1/tg_bot/transmitted_tg_data.py +58 -0
- arpakitlib/_arpakit_project_template_v1/util/read_arpakitlib_project_template_file.py +17 -0
- arpakitlib/ar_aiogram_util.py +41 -52
- arpakitlib/ar_arpakit_project_template_util.py +8 -11
- arpakitlib/ar_arpakitlib_cli_util.py +14 -5
- arpakitlib/ar_base_worker_util.py +35 -17
- arpakitlib/ar_class_util.py +11 -0
- arpakitlib/ar_func_util.py +19 -29
- arpakitlib/ar_http_request_util.py +10 -2
- arpakitlib/ar_need_type_util.py +3 -0
- arpakitlib/ar_rat_func_util.py +1 -1
- arpakitlib/ar_retry_func_util.py +4 -4
- arpakitlib/ar_schedule_uust_api_client_util.py +1 -1
- arpakitlib/ar_settings_util.py +3 -204
- arpakitlib/ar_sqladmin_util.py +7 -102
- arpakitlib/ar_sqlalchemy_util.py +65 -13
- arpakitlib/ar_type_util.py +0 -2
- {arpakitlib-1.7.256.dist-info → arpakitlib-1.8.0.dist-info}/METADATA +7 -6
- arpakitlib-1.8.0.dist-info/RECORD +251 -0
- {arpakitlib-1.7.256.dist-info → arpakitlib-1.8.0.dist-info}/WHEEL +1 -1
- arpakitlib/_arpakit_project_template/ARPAKITLIB +0 -1
- arpakitlib/_arpakit_project_template/manage/docker_ps.sh +0 -2
- arpakitlib/_arpakit_project_template/manage/git_branch.sh +0 -2
- arpakitlib/_arpakit_project_template/manage/poetry_add_plugin_export.sh +0 -2
- arpakitlib/_arpakit_project_template/manage/poetry_config_virtualenvs_in_project_true.sh +0 -2
- arpakitlib/_arpakit_project_template/manage/poetry_self_add_plugin_export.sh +0 -2
- arpakitlib/_arpakit_project_template/src/admin1/model_view.py +0 -1
- arpakitlib/_arpakit_project_template/src/api/asgi.py +0 -3
- arpakitlib/_arpakit_project_template/src/api/auth.py +0 -53
- arpakitlib/_arpakit_project_template/src/api/const.py +0 -13
- arpakitlib/_arpakit_project_template/src/api/create_api_app.py +0 -43
- arpakitlib/_arpakit_project_template/src/api/create_handle_exception_.py +0 -59
- arpakitlib/_arpakit_project_template/src/api/event.py +0 -83
- arpakitlib/_arpakit_project_template/src/api/router/v1/get_api_error_info.py +0 -27
- arpakitlib/_arpakit_project_template/src/api/router/v1/main_router.py +0 -15
- arpakitlib/_arpakit_project_template/src/api/schema/v1/in_.py +0 -1
- arpakitlib/_arpakit_project_template/src/api/schema/v1/out.py +0 -1
- arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +0 -7
- arpakitlib/_arpakit_project_template/src/api/util.py +0 -44
- arpakitlib/_arpakit_project_template/src/core/settings.py +0 -21
- arpakitlib/_arpakit_project_template/src/core/util.py +0 -61
- arpakitlib/_arpakit_project_template/src/json_db/_drop_json_db.py +0 -13
- arpakitlib/_arpakit_project_template/src/json_db/_init_json_db.py +0 -11
- arpakitlib/_arpakit_project_template/src/json_db/_reinit_json_db.py +0 -13
- arpakitlib/_arpakit_project_template/src/json_db/_rm_all_records_in_json_db.py +0 -13
- arpakitlib/_arpakit_project_template/src/just_script/example.py +0 -16
- arpakitlib/_arpakit_project_template/src/operation_execution/_start_operation_executor_worker.py +0 -17
- arpakitlib/_arpakit_project_template/src/operation_execution/_start_scheduled_operation_creator_worker.py +0 -17
- arpakitlib/_arpakit_project_template/src/operation_execution/const.py +0 -9
- arpakitlib/_arpakit_project_template/src/operation_execution/operation_executor.py +0 -16
- arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +0 -29
- arpakitlib/_arpakit_project_template/src/operation_execution/util.py +0 -1
- arpakitlib/_arpakit_project_template/src/sandbox/sandbox_5.py +0 -17
- arpakitlib/_arpakit_project_template/src/sandbox/sandbox_6.py +0 -17
- arpakitlib/_arpakit_project_template/src/sandbox/sandbox_7.py +0 -17
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_check_conn_sqlalchemy_db.py +0 -11
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_drop_sqlalchemy_db.py +0 -13
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_init_sqlalchemy_db.py +0 -11
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_reinit_sqlalchemy_db.py +0 -13
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_remove_operations.py +0 -15
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_remove_story_logs.py +0 -16
- arpakitlib/_arpakit_project_template/src/sqlalchemy_db/sqlalchemy_model.py +0 -13
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_1.py +0 -8
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_2.py +0 -8
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_3.py +0 -8
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_4.py +0 -8
- arpakitlib/_arpakit_project_template/src/test_data/make_test_data_5.py +0 -8
- arpakitlib/_arpakit_project_template/src/tg_bot/blank/blank.py +0 -10
- arpakitlib/_arpakit_project_template/src/tg_bot/event.py +0 -39
- arpakitlib/_arpakit_project_template/src/tg_bot/handler/cmd_healthcheck.py +0 -0
- arpakitlib/_arpakit_project_template/src/tg_bot/router/error.py +0 -3
- arpakitlib/_arpakit_project_template/src/tg_bot/router/router.py +0 -7
- arpakitlib/_arpakit_project_template/src/tg_bot/start_tg_bot.py +0 -11
- arpakitlib/_arpakit_project_template/src/tg_bot/transmitted_tg_data.py +0 -6
- arpakitlib/_arpakit_project_template/src/tg_bot/util.py +0 -44
- arpakitlib/ar_api_key_util.py +0 -21
- arpakitlib/ar_fastapi_static/healthcheck +0 -1
- arpakitlib/ar_fastapi_static/swagger-ui/index.html +0 -19
- arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-bundle.js +0 -2
- arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-es-bundle-core.js.map +0 -1
- arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-es-bundle.js +0 -2
- arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-standalone-preset.js +0 -2
- arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map +0 -1
- arpakitlib/ar_fastapi_util.py +0 -862
- arpakitlib/ar_operation_execution_util.py +0 -504
- arpakitlib/ar_sqlalchemy_model_util.py +0 -183
- arpakitlib-1.7.256.dist-info/RECORD +0 -236
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/.gitignore +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/.python-version +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/LICENSE +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/additional_model}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/additional_model/additional_model.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note → _arpakit_project_template_v1/admin1}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/alembic/README +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/alembic/script.py.mako +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/alembic.ini +0 -0
- /arpakitlib/{_arpakit_project_template/resource → _arpakit_project_template_v1/api}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/resource/static → _arpakit_project_template_v1/api/router}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1/api/router/v1}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/additional_model → _arpakit_project_template_v1/api/schema}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/admin1 → _arpakit_project_template_v1/api/schema/common}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api → _arpakit_project_template_v1/api/schema/v1}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_1.txt → _arpakit_project_template_v1/api/util.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/router → _arpakit_project_template_v1/business_service}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/router/v1 → _arpakit_project_template_v1/command}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/alembic_upgrade_head .sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/docker_ps_a.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/docker_rm_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/docker_run_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/docker_start_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/docker_stop_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_commit.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_push_arpakit_company_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_push_arpakit_company_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_push_arpakit_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_push_arpakit_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage/git_remote_v.sh → _arpakit_project_template_v1/command/git_remote.sh} +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_set_arpakit_company_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_set_arpakit_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/git_status.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_check.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_clear_cache.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_config.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_install.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_lock.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_remove_and_add_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_show.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_show_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_update.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v1/command}/poetry_update_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/schema → _arpakit_project_template_v1/core}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/schema/v1 → _arpakit_project_template_v1/json_db}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/json_db/json_db.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/business_service → _arpakit_project_template_v1/note}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_2.txt → _arpakit_project_template_v1/note/note_1.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_3.txt → _arpakit_project_template_v1/note/note_2.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_4.txt → _arpakit_project_template_v1/note/note_3.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_5.txt → _arpakit_project_template_v1/note/note_4.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/src/core/__init__.py → _arpakit_project_template_v1/note/note_5.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/src/json_db → _arpakit_project_template_v1/operation_execution}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/just_script/__init__.py → _arpakit_project_template_v1/operation_execution/const.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/operation_execution → _arpakit_project_template_v1/resource}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/sandbox → _arpakit_project_template_v1/resource/static}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/resource/static/healthcheck +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v1}/resource/static/helloworld +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/redoc/redoc.standalone.js +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/favicon-16x16.png +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/favicon-32x32.png +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/index.css +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/oauth2-redirect.html +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-initializer.js +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui-bundle.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui-es-bundle.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui-standalone-preset.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui.css +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v1/resource/static}/swagger-ui/swagger-ui.css.map +0 -0
- /arpakitlib/{_arpakit_project_template/src/sqlalchemy_db → _arpakit_project_template_v1/sandbox}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/test_data → _arpakit_project_template_v1/sqlalchemy_db}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/sqlalchemy_db/const.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot → _arpakit_project_template_v1/test_data}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/blank → _arpakit_project_template_v1/tg_bot}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/filter → _arpakit_project_template_v1/tg_bot/blank}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/handler → _arpakit_project_template_v1/tg_bot/filter}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/inline_/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/inline_/callback.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/inline_/common.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/static_/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/kb/static_/common.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/middleware/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/tg_bot/router/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/cmd_arpakitlib.py → _arpakit_project_template_v1/tg_bot/util.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v1}/util/__init__.py +0 -0
- {arpakitlib-1.7.256.dist-info → arpakitlib-1.8.0.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.256.dist-info → arpakitlib-1.8.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
import aiogram
|
2
|
+
from aiogram.fsm.storage.memory import MemoryStorage
|
3
|
+
|
4
|
+
from tg_bot.event import add_events_to_tg_bot_dispatcher
|
5
|
+
from tg_bot.router.main_router import main_tg_bot_router
|
6
|
+
from tg_bot.transmitted_tg_data import get_cached_transmitted_tg_bot_data
|
7
|
+
|
8
|
+
|
9
|
+
def create_tg_bot_dispatcher() -> aiogram.Dispatcher:
|
10
|
+
tg_bot_dispatcher = aiogram.Dispatcher(
|
11
|
+
storage=MemoryStorage(),
|
12
|
+
transmitted_tg_bot_data=get_cached_transmitted_tg_bot_data()
|
13
|
+
)
|
14
|
+
|
15
|
+
add_events_to_tg_bot_dispatcher(tg_bot_dispatcher=tg_bot_dispatcher)
|
16
|
+
|
17
|
+
tg_bot_dispatcher.include_router(router=main_tg_bot_router)
|
18
|
+
|
19
|
+
return tg_bot_dispatcher
|
@@ -0,0 +1,58 @@
|
|
1
|
+
from functools import lru_cache
|
2
|
+
|
3
|
+
from pydantic import BaseModel
|
4
|
+
|
5
|
+
from arpakitlib.ar_file_storage_in_dir_util import FileStorageInDir
|
6
|
+
from arpakitlib.ar_json_db_util import BaseJSONDb
|
7
|
+
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDb
|
8
|
+
from core.cache_file_storage_in_dir import get_cached_cache_file_storage_in_dir
|
9
|
+
from core.dump_file_storage_in_dir import get_cached_dump_file_storage_in_dir
|
10
|
+
from core.media_file_storage_in_dir import get_cached_media_file_storage_in_dir
|
11
|
+
from core.settings import Settings, get_cached_settings
|
12
|
+
from json_db.util import get_json_db
|
13
|
+
from sqlalchemy_db.sqlalchemy_db import get_cached_sqlalchemy_db
|
14
|
+
|
15
|
+
|
16
|
+
class TransmittedTgBotData(BaseModel):
|
17
|
+
settings: Settings | None = None
|
18
|
+
sqlalchemy_db: SQLAlchemyDb | None = None
|
19
|
+
json_db: BaseJSONDb | None = None
|
20
|
+
media_file_storage_in_dir: FileStorageInDir | None = None
|
21
|
+
cache_file_storage_in_dir: FileStorageInDir | None = None
|
22
|
+
dump_file_storage_in_dir: FileStorageInDir | None = None
|
23
|
+
|
24
|
+
|
25
|
+
def create_transmitted_tg_bot_data() -> TransmittedTgBotData:
|
26
|
+
settings = get_cached_settings()
|
27
|
+
|
28
|
+
sqlalchemy_db = get_cached_sqlalchemy_db() if settings.sqlalchemy_sync_db_url is not None else None
|
29
|
+
|
30
|
+
json_db = get_json_db() if settings.json_db_dirpath is not None else None
|
31
|
+
|
32
|
+
media_file_storage_in_dir = (
|
33
|
+
get_cached_media_file_storage_in_dir() if settings.media_dirpath is not None else None
|
34
|
+
)
|
35
|
+
|
36
|
+
cache_file_storage_in_dir = (
|
37
|
+
get_cached_cache_file_storage_in_dir() if settings.cache_dirpath is not None else None
|
38
|
+
)
|
39
|
+
|
40
|
+
dump_file_storage_in_dir = (
|
41
|
+
get_cached_dump_file_storage_in_dir() if settings.dump_dirpath is not None else None
|
42
|
+
)
|
43
|
+
|
44
|
+
transmitted_api_data = TransmittedTgBotData(
|
45
|
+
settings=settings,
|
46
|
+
sqlalchemy_db=sqlalchemy_db,
|
47
|
+
json_db=json_db,
|
48
|
+
media_file_storage_in_dir=media_file_storage_in_dir,
|
49
|
+
cache_file_storage_in_dir=cache_file_storage_in_dir,
|
50
|
+
dump_file_storage_in_dir=dump_file_storage_in_dir,
|
51
|
+
)
|
52
|
+
|
53
|
+
return transmitted_api_data
|
54
|
+
|
55
|
+
|
56
|
+
@lru_cache()
|
57
|
+
def get_cached_transmitted_tg_bot_data() -> TransmittedTgBotData:
|
58
|
+
return create_transmitted_tg_bot_data()
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import json
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
from core.const import ProjectPaths
|
5
|
+
|
6
|
+
|
7
|
+
def read_arpakitlib_project_template_file() -> dict[str, Any]:
|
8
|
+
with open(ProjectPaths.arpakit_lib_project_template_filepath, mode="r", encoding="utf-8") as fr:
|
9
|
+
return json.load(fp=fr)
|
10
|
+
|
11
|
+
|
12
|
+
def __example():
|
13
|
+
print(read_arpakitlib_project_template_file())
|
14
|
+
|
15
|
+
|
16
|
+
if __name__ == '__main__':
|
17
|
+
__example()
|
arpakitlib/ar_aiogram_util.py
CHANGED
@@ -4,21 +4,20 @@ import asyncio
|
|
4
4
|
import logging
|
5
5
|
from typing import Optional, Any, Union, Callable, Iterable
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
from aiogram
|
7
|
+
import aiogram
|
8
|
+
import aiohttp
|
9
|
+
import aiohttp.web
|
10
|
+
from aiogram import types
|
11
|
+
from aiogram.enums import ChatType
|
11
12
|
from aiogram.exceptions import AiogramError
|
12
13
|
from aiogram.filters import CommandObject, Filter
|
13
14
|
from aiogram.filters.callback_data import CallbackData
|
14
|
-
from
|
15
|
+
from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application
|
16
|
+
from aiohttp import web
|
17
|
+
from pydantic import BaseModel
|
15
18
|
|
16
|
-
from arpakitlib.ar_file_storage_in_dir_util import FileStorageInDir
|
17
|
-
from arpakitlib.ar_json_db_util import BaseJSONDb
|
18
19
|
from arpakitlib.ar_need_type_util import parse_need_type, NeedTypes
|
19
20
|
from arpakitlib.ar_parse_command import BadCommandFormat, parse_command
|
20
|
-
from arpakitlib.ar_settings_util import BaseSettings2
|
21
|
-
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDb
|
22
21
|
from arpakitlib.ar_type_util import raise_for_types, raise_for_type
|
23
22
|
|
24
23
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -141,7 +140,7 @@ class TgCommandKeyValueParam(BaseTgCommandParam):
|
|
141
140
|
def as_tg_command(
|
142
141
|
*params: TgCommandFlagParam | TgCommandKeyValueParam,
|
143
142
|
desc: str | None = None,
|
144
|
-
|
143
|
+
passwd_validator: Callable | str | None = None,
|
145
144
|
passwd: str | None = None,
|
146
145
|
remove_message_after_correct_passwd: bool = True
|
147
146
|
):
|
@@ -150,10 +149,10 @@ def as_tg_command(
|
|
150
149
|
|
151
150
|
params = list(params)
|
152
151
|
|
153
|
-
if
|
154
|
-
|
155
|
-
if
|
156
|
-
raise_for_types(
|
152
|
+
if passwd_validator is None and passwd is not None:
|
153
|
+
passwd_validator = passwd
|
154
|
+
if passwd_validator is not None:
|
155
|
+
raise_for_types(passwd_validator, [Callable, str])
|
157
156
|
params.append(TgCommandKeyValueParam(key=_PASSWD_KEY, required=True, index=None, need_type=NeedTypes.str_))
|
158
157
|
|
159
158
|
params.append(TgCommandFlagParam(key=_HELP_FLAG))
|
@@ -196,7 +195,7 @@ def as_tg_command(
|
|
196
195
|
text += "\n\n" + desc
|
197
196
|
text += "\n\n"
|
198
197
|
|
199
|
-
if
|
198
|
+
if passwd_validator is not None:
|
200
199
|
text += "Passwd is required\n\n"
|
201
200
|
|
202
201
|
text += "<b>Keys:</b>\n"
|
@@ -236,16 +235,16 @@ def as_tg_command(
|
|
236
235
|
await message.answer(text=text.strip())
|
237
236
|
return
|
238
237
|
|
239
|
-
if
|
238
|
+
if passwd_validator is not None:
|
240
239
|
passwd_ = parsed_command.get_value_by_key(_PASSWD_KEY)
|
241
240
|
if not passwd_:
|
242
241
|
is_passwd_correct = False
|
243
|
-
elif isinstance(
|
244
|
-
is_passwd_correct =
|
242
|
+
elif isinstance(passwd_validator, Callable):
|
243
|
+
is_passwd_correct = passwd_validator(
|
245
244
|
passwd=passwd_, message=message, parsed_command=parsed_command
|
246
245
|
)
|
247
|
-
elif isinstance(
|
248
|
-
is_passwd_correct = (
|
246
|
+
elif isinstance(passwd_validator, str):
|
247
|
+
is_passwd_correct = (passwd_validator == passwd_)
|
249
248
|
else:
|
250
249
|
raise TypeError("check_passwd is not not Callable and not str")
|
251
250
|
if not is_passwd_correct:
|
@@ -315,38 +314,28 @@ def as_tg_command(
|
|
315
314
|
return decorator
|
316
315
|
|
317
316
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
if kwargs.get("default") is None:
|
341
|
-
kwargs["default"] = DefaultBotProperties(
|
342
|
-
parse_mode=ParseMode.HTML,
|
343
|
-
disable_notification=False,
|
344
|
-
link_preview_is_disabled=True
|
345
|
-
)
|
346
|
-
|
347
|
-
tg_bot = Bot(**kwargs)
|
348
|
-
|
349
|
-
return tg_bot
|
317
|
+
def start_aiogram_tg_bot_with_webhook(
|
318
|
+
*,
|
319
|
+
dispatcher: aiogram.Dispatcher,
|
320
|
+
bot: aiogram.Bot,
|
321
|
+
webhook_secret: str = "123",
|
322
|
+
webhook_path: str = "/tg_bot_webhook",
|
323
|
+
webhook_server_hostname: str = "127.0.0.1",
|
324
|
+
webhook_server_port: int = 8080
|
325
|
+
):
|
326
|
+
app = aiohttp.web.Application()
|
327
|
+
simple_requests_handler = SimpleRequestHandler(
|
328
|
+
dispatcher=dispatcher,
|
329
|
+
bot=bot,
|
330
|
+
secret_token=webhook_secret
|
331
|
+
)
|
332
|
+
simple_requests_handler.register(app, path=webhook_path)
|
333
|
+
setup_application(app, dispatcher, bot=bot)
|
334
|
+
web.run_app(
|
335
|
+
app=app,
|
336
|
+
host=webhook_server_hostname,
|
337
|
+
port=webhook_server_port
|
338
|
+
)
|
350
339
|
|
351
340
|
|
352
341
|
def __example():
|
@@ -13,33 +13,32 @@ _logger = logging.getLogger(__name__)
|
|
13
13
|
|
14
14
|
def init_arpakit_project_template(
|
15
15
|
*,
|
16
|
+
version: str = "1",
|
16
17
|
project_dirpath: str = "./",
|
17
18
|
overwrite_if_exists: bool = False,
|
18
19
|
ignore_paths_startswith: list[str] | str | None = None,
|
19
20
|
only_paths_startswith: list[str] | str | None = None,
|
20
|
-
params: dict[str, str] | None = None,
|
21
21
|
):
|
22
|
+
raise_for_type(project_dirpath, str)
|
22
23
|
raise_if_string_blank(project_dirpath)
|
23
24
|
|
24
25
|
raise_for_type(overwrite_if_exists, bool)
|
25
26
|
|
26
|
-
if params is None:
|
27
|
-
params = {}
|
28
|
-
raise_for_type(params, dict)
|
29
|
-
|
30
27
|
if isinstance(ignore_paths_startswith, str):
|
31
28
|
ignore_paths_startswith = [ignore_paths_startswith]
|
32
29
|
if ignore_paths_startswith is None:
|
33
30
|
ignore_paths_startswith = []
|
31
|
+
raise_for_type(ignore_paths_startswith, list)
|
34
32
|
|
35
33
|
if isinstance(only_paths_startswith, str):
|
36
34
|
only_paths_startswith = [only_paths_startswith]
|
37
35
|
if only_paths_startswith is None:
|
38
36
|
only_paths_startswith = []
|
37
|
+
raise_for_type(only_paths_startswith, list)
|
39
38
|
|
40
|
-
def _generate_filepath_to_content() -> dict[str,
|
39
|
+
def _generate_filepath_to_content() -> dict[str, bytes]:
|
41
40
|
arpakit_project_template_dirpath = os.path.join(
|
42
|
-
os.path.dirname(os.path.abspath(__file__)), "
|
41
|
+
os.path.dirname(os.path.abspath(__file__)), f"_arpakit_project_template_v{version}"
|
43
42
|
)
|
44
43
|
res = {}
|
45
44
|
for root, dirs, files in os.walk(arpakit_project_template_dirpath):
|
@@ -60,10 +59,8 @@ def init_arpakit_project_template(
|
|
60
59
|
):
|
61
60
|
_logger.info(f"ignoring file: {rel_path}")
|
62
61
|
continue
|
63
|
-
with open(os.path.join(root, file), "
|
62
|
+
with open(os.path.join(root, file), "rb") as _file:
|
64
63
|
_content = _file.read()
|
65
|
-
for key, value in params.items():
|
66
|
-
_content = _content.replace("{{" + key.upper().strip() + "}}", value)
|
67
64
|
res[rel_path] = _content
|
68
65
|
return res
|
69
66
|
|
@@ -81,6 +78,6 @@ def init_arpakit_project_template(
|
|
81
78
|
|
82
79
|
_logger.info(f"creating file: {full_filepath}")
|
83
80
|
os.makedirs(os.path.dirname(full_filepath), exist_ok=True)
|
84
|
-
with open(full_filepath, "
|
81
|
+
with open(full_filepath, "wb") as file_:
|
85
82
|
file_.write(content)
|
86
83
|
_logger.info(f"file created: {full_filepath}")
|
@@ -5,7 +5,6 @@ import sys
|
|
5
5
|
from arpakitlib.ar_arpakit_project_template_util import init_arpakit_project_template
|
6
6
|
from arpakitlib.ar_need_type_util import parse_need_type, NeedTypes
|
7
7
|
from arpakitlib.ar_parse_command import parse_command
|
8
|
-
from arpakitlib.ar_str_util import raise_if_string_blank
|
9
8
|
|
10
9
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
11
10
|
|
@@ -27,6 +26,8 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
27
26
|
print("Commands:")
|
28
27
|
print()
|
29
28
|
print("-c init_arpakit_project_template")
|
29
|
+
print("-version (1,) ...")
|
30
|
+
print("-project_dirpath ./")
|
30
31
|
print("-overwrite_if_exists ...")
|
31
32
|
print("-ignore_paths_startswith ...")
|
32
33
|
print("-only_paths_startswith ...")
|
@@ -36,13 +37,21 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
36
37
|
print("\n")
|
37
38
|
|
38
39
|
elif command == "init_arpakit_project_template":
|
39
|
-
|
40
|
+
version: str = parse_need_type(
|
41
|
+
value=parsed_command.get_value_by_keys(keys=["version"]),
|
42
|
+
need_type=NeedTypes.str_,
|
43
|
+
allow_none=False
|
44
|
+
)
|
45
|
+
project_dirpath: str = parse_need_type(
|
46
|
+
value=parsed_command.get_value_by_keys(keys=["project_dirpath"]),
|
47
|
+
need_type=NeedTypes.str_,
|
48
|
+
allow_none=False
|
49
|
+
)
|
40
50
|
overwrite_if_exists: bool = parse_need_type(
|
41
51
|
value=parsed_command.get_value_by_keys(keys=["overwrite_if_exists"]),
|
42
52
|
need_type=NeedTypes.bool_,
|
43
53
|
allow_none=False
|
44
54
|
)
|
45
|
-
params = parsed_command.key_to_value
|
46
55
|
ignore_paths_startswith: list[str] | None = parse_need_type(
|
47
56
|
value=parsed_command.get_value_by_keys(keys=["ignore_paths_startswith"]),
|
48
57
|
need_type=NeedTypes.list_of_str,
|
@@ -54,11 +63,11 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
54
63
|
allow_none=True
|
55
64
|
)
|
56
65
|
init_arpakit_project_template(
|
66
|
+
version=version,
|
57
67
|
project_dirpath=project_dirpath,
|
58
68
|
overwrite_if_exists=overwrite_if_exists,
|
59
69
|
ignore_paths_startswith=ignore_paths_startswith,
|
60
|
-
only_paths_startswith=only_paths_startswith
|
61
|
-
params=params,
|
70
|
+
only_paths_startswith=only_paths_startswith
|
62
71
|
)
|
63
72
|
|
64
73
|
else:
|
@@ -11,7 +11,7 @@ from typing import Any
|
|
11
11
|
from uuid import uuid4
|
12
12
|
|
13
13
|
from arpakitlib.ar_enumeration_util import Enumeration
|
14
|
-
from arpakitlib.ar_func_util import
|
14
|
+
from arpakitlib.ar_func_util import is_async_callable, is_sync_function, is_async_object
|
15
15
|
from arpakitlib.ar_sleep_util import sync_safe_sleep, async_safe_sleep
|
16
16
|
|
17
17
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -22,20 +22,23 @@ class BaseWorker(ABC):
|
|
22
22
|
self,
|
23
23
|
*,
|
24
24
|
timeout_after_run: timedelta = timedelta(seconds=0.3),
|
25
|
-
|
25
|
+
timeout_after_error_in_run: timedelta = timedelta(seconds=1),
|
26
26
|
startup_funcs: list[Any] | None = None,
|
27
27
|
worker_name: str | None = None,
|
28
28
|
**kwargs
|
29
29
|
):
|
30
30
|
self.timeout_after_run = timeout_after_run
|
31
|
-
self.
|
31
|
+
self.timeout_after_error_in_run = timeout_after_error_in_run
|
32
|
+
|
32
33
|
if startup_funcs is None:
|
33
34
|
startup_funcs = []
|
34
35
|
self.startup_funcs = startup_funcs
|
36
|
+
|
35
37
|
if worker_name is None:
|
36
38
|
worker_name = self.__class__.__name__
|
37
39
|
self.worker_name = worker_name
|
38
40
|
self.worker_id = f"{str(uuid4()).replace('-', '')}_{randint(1000, 99999)}"
|
41
|
+
|
39
42
|
self._logger = logging.getLogger(self.worker_fullname)
|
40
43
|
|
41
44
|
@property
|
@@ -43,19 +46,26 @@ class BaseWorker(ABC):
|
|
43
46
|
return f"{self.worker_name}_{self.worker_id}"
|
44
47
|
|
45
48
|
def sync_run_startup_funcs(self):
|
49
|
+
self._logger.info("start")
|
46
50
|
for startup_func in self.startup_funcs:
|
47
|
-
if
|
51
|
+
if is_async_callable(startup_func):
|
48
52
|
asyncio.run(startup_func())
|
53
|
+
elif is_async_object(startup_func):
|
54
|
+
async def __func():
|
55
|
+
await startup_func
|
56
|
+
|
57
|
+
asyncio.run(__func())
|
49
58
|
elif is_sync_function(startup_func):
|
50
59
|
startup_func()
|
51
60
|
else:
|
52
|
-
raise TypeError("
|
61
|
+
raise TypeError("unknown startup_func type")
|
62
|
+
self._logger.info("finish")
|
53
63
|
|
54
64
|
def sync_on_startup(self):
|
55
65
|
self.sync_run_startup_funcs()
|
56
66
|
|
57
67
|
def sync_run(self):
|
58
|
-
|
68
|
+
pass
|
59
69
|
|
60
70
|
def sync_on_error(self, exception: Exception, **kwargs):
|
61
71
|
pass
|
@@ -65,35 +75,39 @@ class BaseWorker(ABC):
|
|
65
75
|
try:
|
66
76
|
self.sync_on_startup()
|
67
77
|
except Exception as exception:
|
68
|
-
self._logger.error("
|
78
|
+
self._logger.error("exception in sync_on_startup", exc_info=exception)
|
69
79
|
raise
|
70
80
|
while True:
|
71
81
|
try:
|
72
82
|
self.sync_run()
|
73
83
|
except Exception as exception:
|
74
|
-
self._logger.error("
|
84
|
+
self._logger.error("exception in sync_run", exc_info=exception)
|
75
85
|
try:
|
76
86
|
self.sync_on_error(exception=exception)
|
77
87
|
except Exception as exception_:
|
78
|
-
self._logger.error("
|
88
|
+
self._logger.error("exception in sync_on_error", exc_info=exception_)
|
79
89
|
raise
|
80
|
-
sync_safe_sleep(self.
|
90
|
+
sync_safe_sleep(self.timeout_after_error_in_run)
|
81
91
|
sync_safe_sleep(self.timeout_after_run)
|
82
92
|
|
83
93
|
async def async_run_startup_funcs(self):
|
94
|
+
self._logger.info("start")
|
84
95
|
for startup_func in self.startup_funcs:
|
85
|
-
if
|
96
|
+
if is_async_callable(startup_func):
|
86
97
|
await startup_func()
|
98
|
+
elif is_async_object(startup_func):
|
99
|
+
await startup_func
|
87
100
|
elif is_sync_function(startup_func):
|
88
101
|
startup_func()
|
89
102
|
else:
|
90
|
-
raise TypeError("
|
103
|
+
raise TypeError("unknown startup_func type")
|
104
|
+
self._logger.info("finish")
|
91
105
|
|
92
106
|
async def async_on_startup(self):
|
93
107
|
await self.async_run_startup_funcs()
|
94
108
|
|
95
109
|
async def async_run(self):
|
96
|
-
|
110
|
+
pass
|
97
111
|
|
98
112
|
async def async_on_error(self, exception: Exception, **kwargs):
|
99
113
|
pass
|
@@ -103,19 +117,19 @@ class BaseWorker(ABC):
|
|
103
117
|
try:
|
104
118
|
await self.async_on_startup()
|
105
119
|
except Exception as exception:
|
106
|
-
self._logger.error("
|
120
|
+
self._logger.error("exception in async_on_startup", exc_info=exception)
|
107
121
|
raise
|
108
122
|
while True:
|
109
123
|
try:
|
110
124
|
await self.async_run()
|
111
125
|
except Exception as exception:
|
112
|
-
self._logger.error("
|
126
|
+
self._logger.error("exception in async_run", exc_info=exception)
|
113
127
|
try:
|
114
128
|
await self.async_on_error(exception=exception)
|
115
129
|
except Exception as exception_:
|
116
|
-
self._logger.error("
|
130
|
+
self._logger.error("exception in async_on_error", exc_info=exception_)
|
117
131
|
raise
|
118
|
-
await async_safe_sleep(self.
|
132
|
+
await async_safe_sleep(self.timeout_after_error_in_run)
|
119
133
|
await async_safe_sleep(self.timeout_after_run)
|
120
134
|
|
121
135
|
|
@@ -156,6 +170,10 @@ def safe_run_workers_in_background(
|
|
156
170
|
return res
|
157
171
|
|
158
172
|
|
173
|
+
async def a():
|
174
|
+
print("1")
|
175
|
+
|
176
|
+
|
159
177
|
def __example():
|
160
178
|
pass
|
161
179
|
|
arpakitlib/ar_class_util.py
CHANGED
@@ -14,3 +14,14 @@ class CollectingSubclassesMeta(type):
|
|
14
14
|
cls.all_subclasses = []
|
15
15
|
elif bases:
|
16
16
|
cls.all_subclasses.append(cls)
|
17
|
+
|
18
|
+
|
19
|
+
def create_combined_meta(*metas):
|
20
|
+
"""
|
21
|
+
Создает объединённый метакласс для устранения конфликтов.
|
22
|
+
"""
|
23
|
+
|
24
|
+
class CombinedMeta(*metas):
|
25
|
+
pass
|
26
|
+
|
27
|
+
return CombinedMeta
|
arpakitlib/ar_func_util.py
CHANGED
@@ -5,50 +5,40 @@ from typing import Callable
|
|
5
5
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
6
6
|
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def is_async_callable(obj: Callable) -> bool:
|
9
|
+
if inspect.ismethod(obj) or inspect.isfunction(obj):
|
10
|
+
return inspect.iscoroutinefunction(obj)
|
11
|
+
if isinstance(obj, (staticmethod, classmethod)):
|
12
|
+
return inspect.iscoroutinefunction(obj.__func__)
|
13
|
+
return False
|
10
14
|
|
11
15
|
|
12
|
-
def
|
13
|
-
|
16
|
+
def raise_if_not_async_callable(obj: Callable):
|
17
|
+
if not is_async_callable(obj):
|
18
|
+
raise TypeError(f"The provided callable '{obj.__name__}' is not an async")
|
14
19
|
|
15
20
|
|
16
|
-
|
17
|
-
return inspect.isfunction(func) and not is_async_function(func)
|
21
|
+
# ---
|
18
22
|
|
19
23
|
|
20
|
-
def
|
21
|
-
|
22
|
-
raise TypeError(f"The provided function '{func.__name__}' is not an async function")
|
24
|
+
def is_async_object(obj: object) -> bool:
|
25
|
+
return asyncio.iscoroutine(obj)
|
23
26
|
|
24
27
|
|
25
|
-
|
26
|
-
if not is_sync_function(func):
|
27
|
-
raise TypeError(f"The provided function '{func.__name__}' is not a sync function")
|
28
|
+
# ---
|
28
29
|
|
29
30
|
|
30
|
-
def
|
31
|
-
|
32
|
-
raise TypeError(f"The provided function '{func.__name__}' should not be async")
|
31
|
+
def is_sync_function(obj: Callable) -> bool:
|
32
|
+
return callable(obj) and not is_async_callable(obj=obj)
|
33
33
|
|
34
34
|
|
35
|
-
def
|
36
|
-
if is_sync_function(
|
37
|
-
raise TypeError(f"The provided
|
35
|
+
def raise_if_not_sync_callable(obj: Callable):
|
36
|
+
if not is_sync_function(obj):
|
37
|
+
raise TypeError(f"The provided callable '{obj.__name__}' is not an sync")
|
38
38
|
|
39
39
|
|
40
40
|
def __example():
|
41
|
-
|
42
|
-
pass
|
43
|
-
|
44
|
-
async def two():
|
45
|
-
pass
|
46
|
-
|
47
|
-
print(is_sync_function(one))
|
48
|
-
print(is_sync_function(two))
|
49
|
-
|
50
|
-
print(is_async_function(one))
|
51
|
-
print(is_async_function(two))
|
41
|
+
pass
|
52
42
|
|
53
43
|
|
54
44
|
if __name__ == '__main__':
|
@@ -29,6 +29,7 @@ def sync_make_http_request(
|
|
29
29
|
not_raise_for_statuses_: list[int] | None = None,
|
30
30
|
timeout_: timedelta | float = timedelta(seconds=15).total_seconds(),
|
31
31
|
enable_logging_: bool = False,
|
32
|
+
exception_class_: type[Exception] | None = None,
|
32
33
|
**kwargs
|
33
34
|
) -> requests.Response:
|
34
35
|
if isinstance(timeout_, float):
|
@@ -75,7 +76,10 @@ def sync_make_http_request(
|
|
75
76
|
f"{tries_counter}/{max_tries_}, bad try {method} {url} {params}, exception={exception}"
|
76
77
|
)
|
77
78
|
if tries_counter >= max_tries_:
|
78
|
-
|
79
|
+
if exception_class_ is not None:
|
80
|
+
raise exception_class_(exception)
|
81
|
+
else:
|
82
|
+
raise exception
|
79
83
|
sync_safe_sleep(timedelta(seconds=0.1).total_seconds())
|
80
84
|
continue
|
81
85
|
|
@@ -92,6 +96,7 @@ async def async_make_http_request(
|
|
92
96
|
not_raise_for_statuses_: list[int] | None = None,
|
93
97
|
timeout_: timedelta | None = timedelta(seconds=15),
|
94
98
|
enable_logging_: bool = False,
|
99
|
+
exception_class_: type[Exception] | None = None,
|
95
100
|
**kwargs
|
96
101
|
) -> aiohttp.ClientResponse:
|
97
102
|
tries_counter = 0
|
@@ -137,7 +142,10 @@ async def async_make_http_request(
|
|
137
142
|
f"{tries_counter}/{max_tries_}, bad try {method} {url} {params}, exception={exception}"
|
138
143
|
)
|
139
144
|
if tries_counter >= max_tries_:
|
140
|
-
|
145
|
+
if exception_class_ is not None:
|
146
|
+
raise exception_class_(exception)
|
147
|
+
else:
|
148
|
+
raise exception
|
141
149
|
await async_safe_sleep(timedelta(seconds=0.1).total_seconds())
|
142
150
|
continue
|
143
151
|
|
arpakitlib/ar_need_type_util.py
CHANGED
@@ -23,6 +23,9 @@ def parse_need_type(value: Any, need_type: str, allow_none: bool = False) -> Any
|
|
23
23
|
if allow_none and value is None:
|
24
24
|
return None
|
25
25
|
|
26
|
+
if not allow_none and value is None:
|
27
|
+
raise ValueError("value is None")
|
28
|
+
|
26
29
|
NeedTypes.parse_and_validate_values(need_type)
|
27
30
|
|
28
31
|
if need_type == NeedTypes.str_:
|