arpakitlib 1.7.250__py3-none-any.whl → 1.7.252__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/alembic/README +1 -0
- arpakitlib/_arpakit_project_template/alembic/env.py +83 -0
- arpakitlib/_arpakit_project_template/alembic/script.py.mako +26 -0
- arpakitlib/_arpakit_project_template/alembic.ini +119 -0
- arpakitlib/_arpakit_project_template/example.env +5 -14
- arpakitlib/_arpakit_project_template/manage/docker_run_postgres.sh +4 -3
- arpakitlib/_arpakit_project_template/manage/docker_start_postgres.sh +2 -1
- arpakitlib/_arpakit_project_template/manage/docker_stop_postgres.sh +2 -1
- arpakitlib/_arpakit_project_template/manage/git_set_arpakit_company_origin.sh +4 -2
- arpakitlib/_arpakit_project_template/manage/git_set_arpakit_origin.sh +4 -2
- arpakitlib/_arpakit_project_template/src/additional_model/additional_model.py +0 -7
- arpakitlib/_arpakit_project_template/src/api/auth.py +52 -0
- arpakitlib/_arpakit_project_template/src/api/create_api_app.py +21 -14
- arpakitlib/_arpakit_project_template/src/api/create_handle_exception_.py +13 -13
- arpakitlib/_arpakit_project_template/src/api/event.py +24 -2
- arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +3 -11
- arpakitlib/_arpakit_project_template/src/core/settings.py +3 -111
- arpakitlib/_arpakit_project_template/src/db/util.py +1 -3
- arpakitlib/_arpakit_project_template/src/just_script/__init__.py +0 -0
- arpakitlib/_arpakit_project_template/src/just_script/example.py +16 -0
- arpakitlib/ar_arpakit_project_template_util.py +8 -18
- arpakitlib/ar_arpakit_schedule_uust_api_client_util.py +5 -4
- arpakitlib/ar_arpakitlib_cli_util.py +10 -22
- arpakitlib/ar_class_util.py +0 -1
- arpakitlib/ar_cryptomus_api_client_util.py +21 -0
- arpakitlib/ar_fastapi_util.py +101 -70
- arpakitlib/ar_schedule_uust_api_client_util.py +24 -24
- arpakitlib/ar_settings_util.py +166 -14
- arpakitlib/ar_sqlalchemy_model_util.py +1 -1
- arpakitlib/ar_steam_payment_api_client_util.py +21 -0
- arpakitlib/ar_wata_api_client.py +21 -0
- {arpakitlib-1.7.250.dist-info → arpakitlib-1.7.252.dist-info}/METADATA +1 -1
- {arpakitlib-1.7.250.dist-info → arpakitlib-1.7.252.dist-info}/RECORD +37 -28
- /arpakitlib/_arpakit_project_template/src/core/{_check_settings.py → _show_settings.py} +0 -0
- {arpakitlib-1.7.250.dist-info → arpakitlib-1.7.252.dist-info}/LICENSE +0 -0
- {arpakitlib-1.7.250.dist-info → arpakitlib-1.7.252.dist-info}/WHEEL +0 -0
- {arpakitlib-1.7.250.dist-info → arpakitlib-1.7.252.dist-info}/entry_points.txt +0 -0
@@ -1,121 +1,13 @@
|
|
1
1
|
import os
|
2
2
|
from functools import lru_cache
|
3
|
-
from typing import Any
|
4
|
-
|
5
|
-
import pytz
|
6
|
-
from pydantic import field_validator
|
7
|
-
from pydantic_core.core_schema import ValidationInfo
|
8
3
|
|
9
4
|
from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
|
10
|
-
from arpakitlib.ar_settings_util import
|
11
|
-
from arpakitlib.ar_sqlalchemy_util import generate_sqlalchemy_url
|
5
|
+
from arpakitlib.ar_settings_util import AdvancedSettings
|
12
6
|
from src.core.const import ProjectPaths
|
13
7
|
|
14
8
|
|
15
|
-
class Settings(
|
16
|
-
|
17
|
-
|
18
|
-
sql_db_user: str | None = project_name
|
19
|
-
|
20
|
-
sql_db_password: str | None = project_name
|
21
|
-
|
22
|
-
sql_db_port: int | None = int("{{SQL_DB_PORT}}") if "{{SQL_DB_PORT}}".strip().isdigit() else None
|
23
|
-
|
24
|
-
sql_db_database: str | None = project_name
|
25
|
-
|
26
|
-
sql_db_url: str | None = None
|
27
|
-
|
28
|
-
@field_validator("sql_db_url", mode="after")
|
29
|
-
def validate_sql_db_url(cls, v: Any, validation_info: ValidationInfo, **kwargs) -> str | None:
|
30
|
-
if v is not None:
|
31
|
-
return v
|
32
|
-
|
33
|
-
user = validation_info.data.get("sql_db_user")
|
34
|
-
password = validation_info.data.get("sql_db_password")
|
35
|
-
port = validation_info.data.get("sql_db_port")
|
36
|
-
database = validation_info.data.get("sql_db_database")
|
37
|
-
|
38
|
-
return generate_sqlalchemy_url(
|
39
|
-
base="postgresql",
|
40
|
-
user=user,
|
41
|
-
password=password,
|
42
|
-
port=port,
|
43
|
-
database=database
|
44
|
-
)
|
45
|
-
|
46
|
-
async_sql_db_url: str | None = None
|
47
|
-
|
48
|
-
@field_validator("async_sql_db_url", mode="after")
|
49
|
-
def validate_async_sql_db_url(cls, v: Any, validation_info: ValidationInfo, **kwargs) -> str | None:
|
50
|
-
if v is not None:
|
51
|
-
return v
|
52
|
-
|
53
|
-
user = validation_info.data.get("sql_db_user")
|
54
|
-
password = validation_info.data.get("sql_db_password")
|
55
|
-
port = validation_info.data.get("sql_db_port")
|
56
|
-
database = validation_info.data.get("sql_db_database")
|
57
|
-
|
58
|
-
return generate_sqlalchemy_url(
|
59
|
-
base="postgresql+asyncpg",
|
60
|
-
user=user,
|
61
|
-
password=password,
|
62
|
-
port=port,
|
63
|
-
database=database
|
64
|
-
)
|
65
|
-
|
66
|
-
sql_db_echo: bool = False
|
67
|
-
|
68
|
-
api_init_sql_db_at_start: bool = True
|
69
|
-
|
70
|
-
api_title: str | None = project_name
|
71
|
-
|
72
|
-
api_description: str | None = f"{project_name} (arpakitlib)"
|
73
|
-
|
74
|
-
api_logging_func_before_response: bool = True
|
75
|
-
|
76
|
-
api_story_log_func_before_response: bool = True
|
77
|
-
|
78
|
-
api_start_operation_executor_worker: bool = False
|
79
|
-
|
80
|
-
api_start_scheduled_operation_creator_worker: bool = False
|
81
|
-
|
82
|
-
api_port: int | None = int("{{API_PORT}}") if "{{API_PORT}}".strip().isdigit() else None
|
83
|
-
|
84
|
-
api_correct_api_key: str | None = "1"
|
85
|
-
|
86
|
-
api_correct_token: str | None = "1"
|
87
|
-
|
88
|
-
api_enable_admin1: bool = True
|
89
|
-
|
90
|
-
var_dirname: str | None = "var"
|
91
|
-
|
92
|
-
var_dirpath: str | None = os.path.join(ProjectPaths.base_dirpath, var_dirname)
|
93
|
-
|
94
|
-
log_filename: str | None = "story.log"
|
95
|
-
|
96
|
-
log_filepath: str | None = os.path.join(var_dirpath, log_filename)
|
97
|
-
|
98
|
-
cache_dirname: str | None = "cache"
|
99
|
-
|
100
|
-
cache_dirpath: str | None = os.path.join(var_dirpath, cache_dirname)
|
101
|
-
|
102
|
-
media_dirname: str | None = "media"
|
103
|
-
|
104
|
-
media_dirpath: str | None = os.path.join(var_dirpath, media_dirname)
|
105
|
-
|
106
|
-
dump_dirname: str | None = "dump"
|
107
|
-
|
108
|
-
dump_dirpath: str | None = os.path.join(var_dirpath, dump_dirname)
|
109
|
-
|
110
|
-
local_timezone: str | None = None
|
111
|
-
|
112
|
-
@property
|
113
|
-
def local_timezone_as_pytz(self) -> Any:
|
114
|
-
return pytz.timezone(self.local_timezone)
|
115
|
-
|
116
|
-
admin1_secret_key: str | None = "85a9583cb91c4de7a78d7eb1e5306a04418c9c43014c447ea8ec8dd5deb4cf71"
|
117
|
-
|
118
|
-
# ...
|
9
|
+
class Settings(AdvancedSettings):
|
10
|
+
var_dirpath: str | None = os.path.join(ProjectPaths.base_dirpath, "var")
|
119
11
|
|
120
12
|
|
121
13
|
@lru_cache()
|
@@ -3,12 +3,12 @@ from functools import lru_cache
|
|
3
3
|
from arpakitlib.ar_sqlalchemy_model_util import BaseDBM
|
4
4
|
from arpakitlib.ar_sqlalchemy_util import SQLAlchemyDB
|
5
5
|
from src.core.settings import get_cached_settings
|
6
|
-
from src.db.sqlalchemy_model import import_project_sqlalchemy_models
|
7
6
|
|
8
7
|
|
9
8
|
def get_base_dbm() -> type[BaseDBM]:
|
10
9
|
from arpakitlib.ar_sqlalchemy_model_util import import_ar_sqlalchemy_models
|
11
10
|
import_ar_sqlalchemy_models()
|
11
|
+
from src.db.sqlalchemy_model import import_project_sqlalchemy_models
|
12
12
|
import_project_sqlalchemy_models()
|
13
13
|
return BaseDBM
|
14
14
|
|
@@ -25,5 +25,3 @@ def create_sqlalchemy_db() -> SQLAlchemyDB:
|
|
25
25
|
@lru_cache()
|
26
26
|
def get_cached_sqlalchemy_db() -> SQLAlchemyDB:
|
27
27
|
return create_sqlalchemy_db()
|
28
|
-
|
29
|
-
# ...
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from src.core.util import setup_logging
|
4
|
+
|
5
|
+
_logger = logging.getLogger(__name__)
|
6
|
+
|
7
|
+
|
8
|
+
def send_msg_to_users():
|
9
|
+
setup_logging()
|
10
|
+
input("r u sure?")
|
11
|
+
_logger.info("sending")
|
12
|
+
_logger.info("sent")
|
13
|
+
|
14
|
+
|
15
|
+
if __name__ == '__main__':
|
16
|
+
send_msg_to_users()
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import logging
|
4
4
|
import os
|
5
5
|
|
6
|
-
from arpakitlib.ar_str_util import
|
6
|
+
from arpakitlib.ar_str_util import raise_if_string_blank
|
7
7
|
from arpakitlib.ar_type_util import raise_for_type
|
8
8
|
|
9
9
|
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
@@ -15,23 +15,17 @@ def init_arpakit_project_template(
|
|
15
15
|
*,
|
16
16
|
project_dirpath: str = "./",
|
17
17
|
overwrite_if_exists: bool = False,
|
18
|
-
|
19
|
-
sql_db_port: int | None = None,
|
20
|
-
api_port: int | None = None,
|
18
|
+
params: dict[str, str] | None = None,
|
21
19
|
ignore_paths_startswith: list[str] | str | None = None,
|
22
20
|
only_paths_startswith: list[str] | str | None = None,
|
23
21
|
):
|
24
22
|
raise_if_string_blank(project_dirpath)
|
25
23
|
|
26
|
-
|
27
|
-
project_name = project_name.strip()
|
28
|
-
project_name = make_none_if_blank(project_name)
|
24
|
+
raise_for_type(overwrite_if_exists, bool)
|
29
25
|
|
30
|
-
if
|
31
|
-
|
32
|
-
|
33
|
-
if api_port is not None:
|
34
|
-
raise_for_type(api_port, int)
|
26
|
+
if params is None:
|
27
|
+
params = {}
|
28
|
+
raise_for_type(params, dict)
|
35
29
|
|
36
30
|
if isinstance(ignore_paths_startswith, str):
|
37
31
|
ignore_paths_startswith = [ignore_paths_startswith]
|
@@ -68,12 +62,8 @@ def init_arpakit_project_template(
|
|
68
62
|
continue
|
69
63
|
with open(os.path.join(root, file), "r", encoding="utf-8") as _file:
|
70
64
|
_content = _file.read()
|
71
|
-
|
72
|
-
_content = _content.replace("{{
|
73
|
-
if sql_db_port is not None:
|
74
|
-
_content = _content.replace("{{SQL_DB_PORT}}", str(sql_db_port))
|
75
|
-
if api_port is not None:
|
76
|
-
_content = _content.replace("{{API_PORT}}", str(api_port))
|
65
|
+
for key, value in params.items():
|
66
|
+
_content = _content.replace("{{" + key.upper().strip() + "}}", value)
|
77
67
|
res[rel_path] = _content
|
78
68
|
return res
|
79
69
|
|
@@ -225,10 +225,6 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
225
225
|
else:
|
226
226
|
self.ttl_cache = None
|
227
227
|
|
228
|
-
def clear_cache(self):
|
229
|
-
if self.ttl_cache is not None:
|
230
|
-
self.ttl_cache.clear()
|
231
|
-
|
232
228
|
async def _async_make_http_request(
|
233
229
|
self,
|
234
230
|
*,
|
@@ -242,11 +238,16 @@ class ARPAKITScheduleUUSTAPIClient:
|
|
242
238
|
url=url,
|
243
239
|
headers=self.headers,
|
244
240
|
params=params,
|
241
|
+
max_tries_=5,
|
245
242
|
raise_for_status_=True,
|
246
243
|
**kwargs
|
247
244
|
)
|
248
245
|
return response
|
249
246
|
|
247
|
+
def clear_cache(self):
|
248
|
+
if self.ttl_cache is not None:
|
249
|
+
self.ttl_cache.clear()
|
250
|
+
|
250
251
|
async def check_auth(self) -> dict[str, Any]:
|
251
252
|
response = await self._async_make_http_request(
|
252
253
|
method="GET", url=urljoin(self.base_url, "check_auth")
|
@@ -29,46 +29,34 @@ def execute_arpakitlib_cli(*, full_command: str | None = None):
|
|
29
29
|
print("-c init_arpakit_project_template")
|
30
30
|
print("-project_dirpath ...")
|
31
31
|
print("-overwrite_if_exists ...")
|
32
|
-
print("-project_name ...")
|
33
|
-
print("-sql_db_port ...")
|
34
|
-
print("-api_port ...")
|
35
32
|
print("-ignore_paths_startswith ...")
|
36
33
|
print("-only_paths_startswith ...")
|
37
34
|
print("\n")
|
38
35
|
|
39
36
|
elif command == "init_arpakit_project_template":
|
40
|
-
project_dirpath = raise_if_string_blank(parsed_command.get_value_by_keys(keys=["
|
37
|
+
project_dirpath = raise_if_string_blank(parsed_command.get_value_by_keys(keys=["project_dirpath"]))
|
41
38
|
overwrite_if_exists: bool = parse_need_type(
|
42
|
-
value=parsed_command.get_value_by_keys(keys=["
|
39
|
+
value=parsed_command.get_value_by_keys(keys=["overwrite_if_exists"]),
|
43
40
|
need_type=NeedTypes.bool_,
|
44
41
|
allow_none=False
|
45
42
|
)
|
46
|
-
|
47
|
-
project_name = project_name.strip() if project_name and project_name.strip() else None
|
48
|
-
sql_db_port: int | None = parse_need_type(
|
49
|
-
value=parsed_command.get_value_by_keys(keys=["sdp", "sql_db_port"]),
|
50
|
-
need_type=NeedTypes.int_,
|
51
|
-
allow_none=True
|
52
|
-
)
|
53
|
-
api_port: int | None = parse_need_type(
|
54
|
-
value=parsed_command.get_value_by_keys(keys=["ap", "api_port"]),
|
55
|
-
need_type=NeedTypes.int_,
|
56
|
-
allow_none=True
|
57
|
-
)
|
43
|
+
params = parsed_command.key_to_value
|
58
44
|
ignore_paths_startswith: list[str] | None = parse_need_type(
|
59
|
-
value=parsed_command.get_value_by_keys(keys=["
|
45
|
+
value=parsed_command.get_value_by_keys(keys=["ignore_paths_startswith"]),
|
60
46
|
need_type=NeedTypes.list_of_str,
|
61
47
|
allow_none=True
|
62
48
|
)
|
63
49
|
only_paths_startswith: list[str] | None = parse_need_type(
|
64
|
-
value=parsed_command.get_value_by_keys(keys=["
|
50
|
+
value=parsed_command.get_value_by_keys(keys=["only_paths_startswith"]),
|
65
51
|
need_type=NeedTypes.list_of_str,
|
66
52
|
allow_none=True
|
67
53
|
)
|
68
54
|
init_arpakit_project_template(
|
69
|
-
project_dirpath=project_dirpath,
|
70
|
-
|
71
|
-
|
55
|
+
project_dirpath=project_dirpath,
|
56
|
+
overwrite_if_exists=overwrite_if_exists,
|
57
|
+
params=params,
|
58
|
+
ignore_paths_startswith=ignore_paths_startswith,
|
59
|
+
only_paths_startswith=only_paths_startswith
|
72
60
|
)
|
73
61
|
|
74
62
|
else:
|
arpakitlib/ar_class_util.py
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# arpakit
|
2
|
+
import asyncio
|
3
|
+
|
4
|
+
_ARPAKIT_LIB_MODULE_VERSION = "3.0"
|
5
|
+
|
6
|
+
|
7
|
+
class CryptomusAPIClient:
|
8
|
+
pass
|
9
|
+
|
10
|
+
|
11
|
+
def __example():
|
12
|
+
pass
|
13
|
+
|
14
|
+
|
15
|
+
async def __async_example():
|
16
|
+
pass
|
17
|
+
|
18
|
+
|
19
|
+
if __name__ == '__main__':
|
20
|
+
__example()
|
21
|
+
asyncio.run(__async_example())
|