arpakitlib 1.7.257__py3-none-any.whl → 1.8.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.
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/README.md +1 -1
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/env.py +3 -3
- arpakitlib/_arpakit_project_template_v_1/api/asgi.py +3 -0
- arpakitlib/_arpakit_project_template_v_1/api/auth.py +235 -0
- arpakitlib/_arpakit_project_template_v_1/api/const.py +18 -0
- arpakitlib/_arpakit_project_template_v_1/api/create_api_app.py +71 -0
- arpakitlib/_arpakit_project_template_v_1/api/event.py +74 -0
- arpakitlib/_arpakit_project_template_v_1/api/exception.py +38 -0
- arpakitlib/_arpakit_project_template_v_1/api/exception_handler.py +308 -0
- arpakitlib/_arpakit_project_template_v_1/api/openapi_ui.py +28 -0
- arpakitlib/_arpakit_project_template_v_1/api/response.py +31 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/api/router/main_router.py +4 -3
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/arpakit_project_template.py +22 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/check_auth.py +30 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/clear_log_file.py +25 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/get_errors_info.py +24 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/get_log_file.py +23 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/healthcheck.py +21 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/main_router.py +67 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/now_utc_datetime.py +21 -0
- arpakitlib/_arpakit_project_template_v_1/api/router/v1/raise_fake_error.py +35 -0
- arpakitlib/_arpakit_project_template_v_1/api/schema/base_schema.py +26 -0
- arpakitlib/_arpakit_project_template_v_1/api/schema/common/in_.py +5 -0
- arpakitlib/_arpakit_project_template_v_1/api/schema/common/out.py +60 -0
- arpakitlib/_arpakit_project_template_v_1/api/schema/v1/in_.py +5 -0
- arpakitlib/_arpakit_project_template_v_1/api/schema/v1/out.py +47 -0
- arpakitlib/_arpakit_project_template_v_1/arpakitlib_project_template.json +3 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/business_service/hello_world.py +1 -1
- arpakitlib/_arpakit_project_template_v_1/business_service/remove_operations.py +51 -0
- arpakitlib/_arpakit_project_template_v_1/command/alembic_history.sh +2 -0
- arpakitlib/_arpakit_project_template_v_1/command/alembic_revision_autogenerate.sh +2 -0
- arpakitlib/{_arpakit_project_template/manage/json_beautify.py → _arpakit_project_template_v_1/command/beautify_json.py} +2 -2
- arpakitlib/{_arpakit_project_template/src/core/_check_logging.py → _arpakit_project_template_v_1/command/check_logging.py} +3 -3
- arpakitlib/_arpakit_project_template_v_1/command/check_sqlalchemy_db.py +11 -0
- arpakitlib/_arpakit_project_template_v_1/command/drop_json_db.py +13 -0
- arpakitlib/_arpakit_project_template_v_1/command/drop_sqlalchemy_db.py +14 -0
- arpakitlib/{_arpakit_project_template/src/core/_generate_settings_env_example.py → _arpakit_project_template_v_1/command/generate_settings_env_example.py} +4 -4
- arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/hello_world.py +2 -2
- arpakitlib/_arpakit_project_template_v_1/command/init_json_db.py +11 -0
- arpakitlib/_arpakit_project_template_v_1/command/init_sqlalchemy_db.py +11 -0
- arpakitlib/_arpakit_project_template_v_1/command/reinit_json_db.py +13 -0
- arpakitlib/_arpakit_project_template_v_1/command/reinit_sqlalchemy_db.py +13 -0
- arpakitlib/_arpakit_project_template_v_1/command/remove_operations.py +13 -0
- arpakitlib/_arpakit_project_template_v_1/command/remove_story_logs.py +16 -0
- arpakitlib/_arpakit_project_template_v_1/command/rm_all_records_in_json_db.py +13 -0
- arpakitlib/{_arpakit_project_template/src/core/_show_settings.py → _arpakit_project_template_v_1/command/show_settings.py} +3 -3
- arpakitlib/{_arpakit_project_template/src/api/_start_api_with_reload.py → _arpakit_project_template_v_1/command/start_api_with_reload.py} +5 -5
- arpakitlib/{_arpakit_project_template/src/api/_start_api_without_reload.py → _arpakit_project_template_v_1/command/start_api_without_reload.py} +5 -5
- arpakitlib/_arpakit_project_template_v_1/command/start_async_operation_executor_worker.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/command/start_async_scheduled_operation_creator_worker.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/command/start_sync_operation_executor_worker.py +15 -0
- arpakitlib/_arpakit_project_template_v_1/command/start_sync_operation_executor_workers.py +22 -0
- arpakitlib/_arpakit_project_template_v_1/command/start_sync_scheduled_operation_creator_worker.py +12 -0
- arpakitlib/_arpakit_project_template_v_1/core/cache_file_storage_in_dir.py +23 -0
- arpakitlib/_arpakit_project_template_v_1/core/const.py +33 -0
- arpakitlib/_arpakit_project_template_v_1/core/dump_file_storage_in_dir.py +23 -0
- arpakitlib/_arpakit_project_template_v_1/core/jinja2_templates.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/core/media_file_storage_in_dir.py +23 -0
- arpakitlib/_arpakit_project_template_v_1/core/settings.py +195 -0
- arpakitlib/_arpakit_project_template_v_1/core/util.py +29 -0
- arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/example.env +13 -7
- arpakitlib/_arpakit_project_template_v_1/json_db/json_db.py +28 -0
- arpakitlib/_arpakit_project_template_v_1/operation_execution/operation_executor_worker.py +256 -0
- arpakitlib/_arpakit_project_template_v_1/operation_execution/scheduled_operation_creator_worker.py +106 -0
- arpakitlib/_arpakit_project_template_v_1/operation_execution/scheduled_operations.py +49 -0
- arpakitlib/_arpakit_project_template_v_1/operation_execution/util.py +29 -0
- arpakitlib/_arpakit_project_template_v_1/resource/static/openapi-favicon.png +0 -0
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/index.html +19 -0
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-bundle.js +2 -0
- arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-es-bundle-core.js +1 -1
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-es-bundle-core.js.map +1 -0
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-es-bundle.js +2 -0
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-standalone-preset.js +2 -0
- arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.js +1 -1
- arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui.js.map +1 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_1.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_2.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_3.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_4.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_5.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_6.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_7.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/site/router/main_router.py +3 -0
- arpakitlib/_arpakit_project_template_v_1/sqladmin_/add_admin_in_app.py +24 -0
- arpakitlib/_arpakit_project_template_v_1/sqladmin_/admin_auth.py +54 -0
- arpakitlib/_arpakit_project_template_v_1/sqladmin_/model_view.py +95 -0
- arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/sqlalchemy_db.py +22 -0
- arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/sqlalchemy_model.py +129 -0
- arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/util.py +28 -0
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_3.py → _arpakit_project_template_v_1/test_data/make_test_data_1.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_4.py → _arpakit_project_template_v_1/test_data/make_test_data_2.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_1.py → _arpakit_project_template_v_1/test_data/make_test_data_3.py} +8 -3
- arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_2.py → _arpakit_project_template_v_1/test_data/make_test_data_4.py} +8 -3
- arpakitlib/_arpakit_project_template_v_1/test_data/make_test_data_5.py +22 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/blank/blank.py +5 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/blank/util.py +1 -1
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/const.py +6 -3
- arpakitlib/_arpakit_project_template_v_1/tg_bot/event.py +51 -0
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/filter/not_prod_mode.py +1 -1
- arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/filter/prod_mode.py +1 -1
- arpakitlib/_arpakit_project_template_v_1/tg_bot/kb/static_/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/kb/static_/common.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/init_user.py +24 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/middleware.py +12 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/router/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/router/arpakitlib_.py +10 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/router/error.py +15 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/router/healthcheck.py +10 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/router/main_router.py +14 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/start_tg_bot.py +34 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/tg_bot.py +24 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/tg_bot_dispatcher.py +19 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/transmitted_tg_data.py +58 -0
- arpakitlib/_arpakit_project_template_v_1/tg_bot/util.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/util/__init__.py +0 -0
- arpakitlib/_arpakit_project_template_v_1/util/read_arpakitlib_project_template_file.py +17 -0
- arpakitlib/ar_aiogram_util.py +41 -52
- arpakitlib/ar_arpakit_project_template_util.py +5 -11
- arpakitlib/ar_arpakitlib_cli_util.py +8 -2
- 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_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.257.dist-info → arpakitlib-1.8.1.dist-info}/METADATA +5 -3
- arpakitlib-1.8.1.dist-info/RECORD +261 -0
- {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.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/add_admin_in_app.py +0 -32
- arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py +0 -29
- 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/const.py +0 -41
- 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/json_db/json_db.py +0 -11
- arpakitlib/_arpakit_project_template/src/json_db/util.py +0 -17
- 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/sqlalchemy_db/util.py +0 -27
- 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/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/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.257.dist-info/RECORD +0 -236
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/.gitignore +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/.python-version +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/LICENSE +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/additional_model}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/additional_model/additional_model.py +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/README +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/script.py.mako +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic.ini +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note → _arpakit_project_template_v_1/api}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/resource → _arpakit_project_template_v_1/api/router}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/resource/static → _arpakit_project_template_v_1/api/router/v1}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1/api/schema}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/additional_model → _arpakit_project_template_v_1/api/schema/common}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/admin1 → _arpakit_project_template_v_1/api/schema/v1}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_1.txt → _arpakit_project_template_v_1/api/util.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/api → _arpakit_project_template_v_1/business_service}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/router → _arpakit_project_template_v_1/celery_}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/router/v1 → _arpakit_project_template_v_1/command}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/alembic_upgrade_head .sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_ps_a.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_rm_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_run_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_start_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_stop_postgres.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_commit.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_company_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_company_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_github_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_gitlab_1.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage/git_remote_v.sh → _arpakit_project_template_v_1/command/git_remote.sh} +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_set_arpakit_company_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_set_arpakit_origin.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_status.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_check.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_clear_cache.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_config.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_install.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_lock.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_remove_and_add_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_show.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_show_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_update.sh +0 -0
- /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_update_arpakitlib.sh +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/schema → _arpakit_project_template_v_1/core}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/api/schema/v1 → _arpakit_project_template_v_1/json_db}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/business_service → _arpakit_project_template_v_1/note}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_2.txt → _arpakit_project_template_v_1/note/note_1.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_3.txt → _arpakit_project_template_v_1/note/note_2.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_4.txt → _arpakit_project_template_v_1/note/note_3.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/manage/note/note_5.txt → _arpakit_project_template_v_1/note/note_4.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/src/core/__init__.py → _arpakit_project_template_v_1/note/note_5.txt} +0 -0
- /arpakitlib/{_arpakit_project_template/src/json_db → _arpakit_project_template_v_1/operation_execution}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/just_script/__init__.py → _arpakit_project_template_v_1/operation_execution/const.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/operation_execution → _arpakit_project_template_v_1/resource}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/resource/static/healthcheck → _arpakit_project_template_v_1/resource/static/1} +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/healthcheck +0 -0
- /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/resource/static/helloworld +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/redoc/redoc.standalone.js +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/favicon-16x16.png +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/favicon-32x32.png +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/index.css +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/oauth2-redirect.html +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-initializer.js +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-bundle.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-es-bundle.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-standalone-preset.js.map +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.css +0 -0
- /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.css.map +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/sandbox/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/sqlalchemy_db → _arpakit_project_template_v_1/site}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/test_data/__init__.py → _arpakit_project_template_v_1/site/asgi.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/__init__.py → _arpakit_project_template_v_1/site/consts.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/blank/__init__.py → _arpakit_project_template_v_1/site/create_site_app.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/filter/__init__.py → _arpakit_project_template_v_1/site/event.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/__init__.py → _arpakit_project_template_v_1/site/exception_handler.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb → _arpakit_project_template_v_1/site/router}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_ → _arpakit_project_template_v_1/sqladmin_}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/static_ → _arpakit_project_template_v_1/sqlalchemy_db}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/sqlalchemy_db/const.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/middleware → _arpakit_project_template_v_1/test_data}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/router → _arpakit_project_template_v_1/tg_bot}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/util → _arpakit_project_template_v_1/tg_bot/blank}/__init__.py +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/cmd_arpakitlib.py → _arpakit_project_template_v_1/tg_bot/filter/__init__.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/cmd_healthcheck.py → _arpakit_project_template_v_1/tg_bot/kb/__init__.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_/callback.py → _arpakit_project_template_v_1/tg_bot/kb/inline_/__init__.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_/common.py → _arpakit_project_template_v_1/tg_bot/kb/inline_/callback.py} +0 -0
- /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/static_ → _arpakit_project_template_v_1/tg_bot/kb/inline_}/common.py +0 -0
- {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/entry_points.txt +0 -0
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import logging
|
2
|
+
from typing import Any, Awaitable, Callable, Dict
|
3
|
+
|
4
|
+
from aiogram import BaseMiddleware
|
5
|
+
from aiogram.types import TelegramObject
|
6
|
+
|
7
|
+
from tg_bot.transmitted_tg_data import TransmittedTgBotData
|
8
|
+
|
9
|
+
_logger = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
|
12
|
+
class InitUserTgBotMiddleware(BaseMiddleware):
|
13
|
+
|
14
|
+
async def __call__(
|
15
|
+
self,
|
16
|
+
handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],
|
17
|
+
event: TelegramObject,
|
18
|
+
data: Dict[str, Any],
|
19
|
+
) -> Any:
|
20
|
+
_logger.info("start")
|
21
|
+
transmitted_tg_bot_data: TransmittedTgBotData = data["transmitted_tg_bot_data"]
|
22
|
+
# ...
|
23
|
+
_logger.info("finish")
|
24
|
+
return await handler(event, data)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import aiogram
|
2
|
+
|
3
|
+
from tg_bot.middleware.init_user import InitUserTgBotMiddleware
|
4
|
+
|
5
|
+
|
6
|
+
def register_tg_bot_middleware(
|
7
|
+
*,
|
8
|
+
tg_bot_dp: aiogram.Dispatcher,
|
9
|
+
**kwargs
|
10
|
+
) -> aiogram.Dispatcher:
|
11
|
+
tg_bot_dp.update.outer_middleware.register(InitUserTgBotMiddleware())
|
12
|
+
return tg_bot_dp
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from tg_bot.const import TgBotCommands
|
4
|
+
|
5
|
+
tg_bot_router = aiogram.Router()
|
6
|
+
|
7
|
+
|
8
|
+
@tg_bot_router.message(aiogram.filters.Command(TgBotCommands.arpakitlib))
|
9
|
+
async def _(m: aiogram.types.Message, **kwargs):
|
10
|
+
await m.answer(text="arpakitlib")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import aiogram
|
2
|
+
from aiogram import Router
|
3
|
+
|
4
|
+
from tg_bot.transmitted_tg_data import TransmittedTgBotData
|
5
|
+
|
6
|
+
tg_bot_router = Router()
|
7
|
+
|
8
|
+
|
9
|
+
@tg_bot_router.error()
|
10
|
+
async def _(
|
11
|
+
event: aiogram.types.ErrorEvent,
|
12
|
+
transmitted_tg_bot_data: TransmittedTgBotData,
|
13
|
+
**kwargs
|
14
|
+
):
|
15
|
+
pass
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import aiogram.filters
|
2
|
+
|
3
|
+
from tg_bot.const import TgBotCommands
|
4
|
+
|
5
|
+
tg_bot_router = aiogram.Router()
|
6
|
+
|
7
|
+
|
8
|
+
@tg_bot_router.message(aiogram.filters.Command(TgBotCommands.healthcheck))
|
9
|
+
async def _(m: aiogram.types.Message, **kwargs):
|
10
|
+
await m.answer(text="healthcheck")
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from aiogram import Router
|
2
|
+
|
3
|
+
from tg_bot.router import error
|
4
|
+
from tg_bot.router import healthcheck
|
5
|
+
|
6
|
+
main_tg_bot_router = Router()
|
7
|
+
|
8
|
+
# Healthcheck
|
9
|
+
|
10
|
+
main_tg_bot_router.include_router(router=healthcheck.tg_bot_router)
|
11
|
+
|
12
|
+
# Error
|
13
|
+
|
14
|
+
main_tg_bot_router.include_router(router=error.tg_bot_router)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from arpakitlib.ar_aiogram_util import start_aiogram_tg_bot_with_webhook
|
2
|
+
from core.util import setup_logging
|
3
|
+
from tg_bot.event import add_events_to_tg_bot_dispatcher
|
4
|
+
from tg_bot.tg_bot import create_tg_bot
|
5
|
+
from tg_bot.tg_bot_dispatcher import create_tg_bot_dispatcher
|
6
|
+
from tg_bot.transmitted_tg_data import get_cached_transmitted_tg_bot_data
|
7
|
+
|
8
|
+
|
9
|
+
def start_tg_bot():
|
10
|
+
setup_logging()
|
11
|
+
|
12
|
+
transmitted_tg_bot_data = get_cached_transmitted_tg_bot_data()
|
13
|
+
|
14
|
+
tg_bot = create_tg_bot()
|
15
|
+
|
16
|
+
tg_bot_dispatcher = create_tg_bot_dispatcher()
|
17
|
+
|
18
|
+
add_events_to_tg_bot_dispatcher(tg_bot_dispatcher=tg_bot_dispatcher)
|
19
|
+
|
20
|
+
if transmitted_tg_bot_data.settings.tg_bot_webhook_enabled:
|
21
|
+
tg_bot_dispatcher.start_polling(tg_bot)
|
22
|
+
else:
|
23
|
+
start_aiogram_tg_bot_with_webhook(
|
24
|
+
dispatcher=tg_bot_dispatcher,
|
25
|
+
bot=tg_bot,
|
26
|
+
webhook_secret=transmitted_tg_bot_data.settings.tg_bot_webhook_secret,
|
27
|
+
webhook_path=transmitted_tg_bot_data.settings.tg_bot_webhook_path,
|
28
|
+
webhook_server_hostname=transmitted_tg_bot_data.settings.tg_bot_webhook_server_hostname,
|
29
|
+
webhook_server_port=transmitted_tg_bot_data.settings.tg_bot_webhook_server_port
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
if __name__ == '__main__':
|
34
|
+
start_tg_bot()
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import aiogram
|
2
|
+
from aiogram.client.default import DefaultBotProperties
|
3
|
+
from aiogram.client.session.aiohttp import AiohttpSession
|
4
|
+
from aiogram.enums import ParseMode
|
5
|
+
|
6
|
+
from core.settings import get_cached_settings
|
7
|
+
|
8
|
+
|
9
|
+
def create_tg_bot() -> aiogram.Bot:
|
10
|
+
session: AiohttpSession | None = None
|
11
|
+
if get_cached_settings().tg_bot_proxy_url is not None:
|
12
|
+
session = AiohttpSession(proxy=get_cached_settings().tg_bot_proxy_url)
|
13
|
+
|
14
|
+
tg_bot = aiogram.Bot(
|
15
|
+
token=get_cached_settings().tg_bot_token,
|
16
|
+
session=session,
|
17
|
+
default=DefaultBotProperties(
|
18
|
+
parse_mode=ParseMode.HTML,
|
19
|
+
disable_notification=False,
|
20
|
+
link_preview_is_disabled=True
|
21
|
+
)
|
22
|
+
)
|
23
|
+
|
24
|
+
return tg_bot
|
@@ -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.json_db import get_cached_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_cached_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()
|
File without changes
|
File without changes
|
@@ -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,21 +13,17 @@ _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
22
|
raise_for_type(project_dirpath, str)
|
23
23
|
raise_if_string_blank(project_dirpath)
|
24
24
|
|
25
25
|
raise_for_type(overwrite_if_exists, bool)
|
26
26
|
|
27
|
-
if params is None:
|
28
|
-
params = {}
|
29
|
-
raise_for_type(params, dict)
|
30
|
-
|
31
27
|
if isinstance(ignore_paths_startswith, str):
|
32
28
|
ignore_paths_startswith = [ignore_paths_startswith]
|
33
29
|
if ignore_paths_startswith is None:
|
@@ -40,9 +36,9 @@ def init_arpakit_project_template(
|
|
40
36
|
only_paths_startswith = []
|
41
37
|
raise_for_type(only_paths_startswith, list)
|
42
38
|
|
43
|
-
def _generate_filepath_to_content() -> dict[str,
|
39
|
+
def _generate_filepath_to_content() -> dict[str, bytes]:
|
44
40
|
arpakit_project_template_dirpath = os.path.join(
|
45
|
-
os.path.dirname(os.path.abspath(__file__)), "
|
41
|
+
os.path.dirname(os.path.abspath(__file__)), f"_arpakit_project_template_v_{version}"
|
46
42
|
)
|
47
43
|
res = {}
|
48
44
|
for root, dirs, files in os.walk(arpakit_project_template_dirpath):
|
@@ -63,10 +59,8 @@ def init_arpakit_project_template(
|
|
63
59
|
):
|
64
60
|
_logger.info(f"ignoring file: {rel_path}")
|
65
61
|
continue
|
66
|
-
with open(os.path.join(root, file), "
|
62
|
+
with open(os.path.join(root, file), "rb") as _file:
|
67
63
|
_content = _file.read()
|
68
|
-
for key, value in params.items():
|
69
|
-
_content = _content.replace("{{" + key.upper().strip() + "}}", value)
|
70
64
|
res[rel_path] = _content
|
71
65
|
return res
|
72
66
|
|
@@ -84,6 +78,6 @@ def init_arpakit_project_template(
|
|
84
78
|
|
85
79
|
_logger.info(f"creating file: {full_filepath}")
|
86
80
|
os.makedirs(os.path.dirname(full_filepath), exist_ok=True)
|
87
|
-
with open(full_filepath, "
|
81
|
+
with open(full_filepath, "wb") as file_:
|
88
82
|
file_.write(content)
|
89
83
|
_logger.info(f"file created: {full_filepath}")
|
@@ -26,6 +26,7 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
26
26
|
print("Commands:")
|
27
27
|
print()
|
28
28
|
print("-c init_arpakit_project_template")
|
29
|
+
print("-version (1,) ...")
|
29
30
|
print("-project_dirpath ./")
|
30
31
|
print("-overwrite_if_exists ...")
|
31
32
|
print("-ignore_paths_startswith ...")
|
@@ -36,6 +37,11 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
36
37
|
print("\n")
|
37
38
|
|
38
39
|
elif command == "init_arpakit_project_template":
|
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
|
+
)
|
39
45
|
project_dirpath: str = parse_need_type(
|
40
46
|
value=parsed_command.get_value_by_keys(keys=["project_dirpath"]),
|
41
47
|
need_type=NeedTypes.str_,
|
@@ -57,11 +63,11 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
57
63
|
allow_none=True
|
58
64
|
)
|
59
65
|
init_arpakit_project_template(
|
66
|
+
version=version,
|
60
67
|
project_dirpath=project_dirpath,
|
61
68
|
overwrite_if_exists=overwrite_if_exists,
|
62
69
|
ignore_paths_startswith=ignore_paths_startswith,
|
63
|
-
only_paths_startswith=only_paths_startswith
|
64
|
-
params=parsed_command.key_to_value,
|
70
|
+
only_paths_startswith=only_paths_startswith
|
65
71
|
)
|
66
72
|
|
67
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
|