arpakitlib 1.7.124__py3-none-any.whl → 1.7.207__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.
Files changed (65) hide show
  1. arpakitlib/_arpakit_project_template/README.md +1 -3
  2. arpakitlib/_arpakit_project_template/example.env +1 -0
  3. arpakitlib/_arpakit_project_template/manage/docker_run_postgres_for_dev.sh +3 -3
  4. arpakitlib/_arpakit_project_template/manage/docker_start_postgres_for_dev.sh +1 -1
  5. arpakitlib/_arpakit_project_template/manage/docker_stop_postgres_for_dev.sh +1 -1
  6. arpakitlib/_arpakit_project_template/manage/git_set_arpakit_company_origin.sh +2 -2
  7. arpakitlib/_arpakit_project_template/manage/git_set_arpakit_origin.sh +2 -2
  8. arpakitlib/_arpakit_project_template/manage/{json_beutify.py → json_beautify.py} +2 -2
  9. arpakitlib/_arpakit_project_template/manage/poetry_show_arpakitlib.sh +1 -1
  10. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_1.py +4 -4
  11. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_2.py +4 -4
  12. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_3.py +4 -4
  13. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_4.py +4 -4
  14. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_5.py +4 -4
  15. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_6.py +4 -4
  16. arpakitlib/_arpakit_project_template/manage/sandbox/sandbox_7.py +4 -4
  17. arpakitlib/_arpakit_project_template/src/additional_model/additional_model.py +2 -0
  18. arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py +10 -3
  19. arpakitlib/_arpakit_project_template/src/admin1/model_view.py +0 -18
  20. arpakitlib/_arpakit_project_template/src/api/{start_api_for_dev_with_reload.py → _start_api_with_reload.py} +2 -2
  21. arpakitlib/_arpakit_project_template/src/api/{start_api_for_dev_without_reload.py → _start_api_without_reload.py} +2 -2
  22. arpakitlib/_arpakit_project_template/src/api/create_api_app.py +2 -2
  23. arpakitlib/_arpakit_project_template/src/api/event.py +2 -8
  24. arpakitlib/_arpakit_project_template/src/api/router/v1/get_api_error_info.py +1 -0
  25. arpakitlib/_arpakit_project_template/src/api/router/v1/main_router.py +4 -0
  26. arpakitlib/_arpakit_project_template/src/api/schema/v1/in_.py +1 -0
  27. arpakitlib/_arpakit_project_template/src/api/schema/v1/out.py +2 -0
  28. arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +2 -0
  29. arpakitlib/_arpakit_project_template/src/business_service/hello_world.py +4 -1
  30. arpakitlib/_arpakit_project_template/src/core/{check_logging.py → _check_logging.py} +2 -2
  31. arpakitlib/_arpakit_project_template/src/core/{check_settings.py → _check_settings.py} +2 -4
  32. arpakitlib/_arpakit_project_template/src/core/{generate_settings_env_example.py → _generate_settings_env_example.py} +4 -6
  33. arpakitlib/_arpakit_project_template/src/core/const.py +16 -23
  34. arpakitlib/_arpakit_project_template/src/core/settings.py +24 -21
  35. arpakitlib/_arpakit_project_template/src/core/util.py +3 -0
  36. arpakitlib/_arpakit_project_template/src/db/{check_conn_sqlalchemy_db.py → _check_conn_sqlalchemy_db.py} +2 -2
  37. arpakitlib/_arpakit_project_template/src/db/{init_sqlalchemy_db.py → _init_sqlalchemy_db.py} +2 -2
  38. arpakitlib/_arpakit_project_template/src/db/{reinit_sqlalchemy_db.py → _reinit_sqlalchemy_db.py} +3 -3
  39. arpakitlib/_arpakit_project_template/src/db/const.py +1 -0
  40. arpakitlib/_arpakit_project_template/src/db/util.py +2 -0
  41. arpakitlib/_arpakit_project_template/src/operation_execution/{start_operation_executor_worker.py → _start_operation_executor_worker.py} +2 -4
  42. arpakitlib/_arpakit_project_template/src/operation_execution/{start_scheduled_operation_creator_worker.py → _start_scheduled_operation_creator_worker.py} +2 -4
  43. arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +12 -8
  44. arpakitlib/_arpakit_project_template/src/operation_execution/util.py +1 -0
  45. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_1.py +2 -0
  46. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_2.py +2 -0
  47. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_3.py +2 -0
  48. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_4.py +2 -0
  49. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_5.py +2 -0
  50. arpakitlib/ar_arpakit_project_template_util.py +3 -3
  51. arpakitlib/ar_class_util.py +17 -0
  52. arpakitlib/ar_enumeration_util.py +19 -1
  53. arpakitlib/ar_operation_execution_util.py +1 -0
  54. arpakitlib/ar_settings_util.py +2 -2
  55. arpakitlib/ar_sqladmin_util.py +101 -0
  56. arpakitlib/ar_type_util.py +15 -0
  57. {arpakitlib-1.7.124.dist-info → arpakitlib-1.7.207.dist-info}/METADATA +1 -1
  58. {arpakitlib-1.7.124.dist-info → arpakitlib-1.7.207.dist-info}/RECORD +62 -63
  59. arpakitlib/_arpakit_project_template/NOTICE +0 -16
  60. arpakitlib/_arpakit_project_template/manage/poetry_generate_requirements.txt.sh +0 -1
  61. arpakitlib-1.7.124.dist-info/NOTICE +0 -16
  62. /arpakitlib/{api_key_util.py → ar_api_key_util.py} +0 -0
  63. {arpakitlib-1.7.124.dist-info → arpakitlib-1.7.207.dist-info}/LICENSE +0 -0
  64. {arpakitlib-1.7.124.dist-info → arpakitlib-1.7.207.dist-info}/WHEEL +0 -0
  65. {arpakitlib-1.7.124.dist-info → arpakitlib-1.7.207.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,4 @@
1
- # {PROJECT_NAME}
2
-
3
- ...
1
+ # {{PROJECT_NAME}}
4
2
 
5
3
  ## ❤️ Made by ARPAKIT Company ❤️
6
4
 
@@ -1,5 +1,6 @@
1
1
  # mode_type=
2
2
  # project_name=
3
+ # sql_db_port=
3
4
  # sql_db_url=
4
5
  # sql_db_echo=
5
6
  # api_init_sql_db_at_start=
@@ -1,4 +1,4 @@
1
1
  cd ..
2
- docker rm {PROJECT_NAME}_postgres
3
- docker run --name {PROJECT_NAME}_postgres -d -p {SQL_DB_PORT}:5432 -e POSTGRES_USER={PROJECT_NAME} -e POSTGRES_PASSWORD={PROJECT_NAME} -e POSTGRES_DB={PROJECT_NAME} postgres:16 -c max_connections=100
4
- docker start {PROJECT_NAME}_postgres
2
+ docker rm {{PROJECT_NAME}}_postgres
3
+ docker run --name {{PROJECT_NAME}}_postgres -d -p {{SQL_DB_PORT}}:5432 -e POSTGRES_USER={{PROJECT_NAME}} -e POSTGRES_PASSWORD={{PROJECT_NAME}} -e POSTGRES_DB={{PROJECT_NAME}} postgres:16 -c max_connections=100
4
+ docker start {{PROJECT_NAME}}_postgres
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- docker start {PROJECT_NAME}_postgres
2
+ docker start {{PROJECT_NAME}}_postgres
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- docker stop {PROJECT_NAME}_postgres
2
+ docker stop {{PROJECT_NAME}}_postgres
@@ -1,7 +1,7 @@
1
1
  cd ..
2
2
 
3
3
  git remote remove arpakit_company_github_1
4
- git remote add arpakit_company_github_1 git@github.com:ARPAKIT-Company/{PROJECT_NAME}.git
4
+ git remote add arpakit_company_github_1 git@github.com:ARPAKIT-Company/{{PROJECT_NAME}}.git
5
5
 
6
6
  git remote remove arpakit_company_gitlab_1
7
- git remote add arpakit_company_gitlab_1 git@gitlab.com:ARPAKIT-Company/{PROJECT_NAME}.git
7
+ git remote add arpakit_company_gitlab_1 git@gitlab.com:ARPAKIT-Company/{{PROJECT_NAME}}.git
@@ -1,7 +1,7 @@
1
1
  cd ..
2
2
 
3
3
  git remote remove arpakit_github_1
4
- git remote add arpakit_github_1 git@github.com:arpakit/{PROJECT_NAME}.git
4
+ git remote add arpakit_github_1 git@github.com:arpakit/{{PROJECT_NAME}}.git
5
5
 
6
6
  git remote remove arpakit_gitlab_1
7
- git remote add arpakit_gitlab_1 git@gitlab.com:arpakit/{PROJECT_NAME}.git
7
+ git remote add arpakit_gitlab_1 git@gitlab.com:arpakit/{{PROJECT_NAME}}.git
@@ -1,10 +1,10 @@
1
1
  from arpakitlib.ar_json_util import safely_transfer_str_to_json_obj_to_json_str
2
2
 
3
3
 
4
- def __command():
4
+ def __json_beautify():
5
5
  s = input("JSON:\n")
6
6
  print(safely_transfer_str_to_json_obj_to_json_str(s))
7
7
 
8
8
 
9
9
  if __name__ == '__main__':
10
- __command()
10
+ __json_beautify()
@@ -1,2 +1,2 @@
1
1
  cd ..
2
- poetry show arpakitlib --no-dev
2
+ poetry show arpakitlib --latest
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -1,14 +1,14 @@
1
1
  import asyncio
2
2
 
3
3
 
4
- def __sandbox():
4
+ def _sandbox():
5
5
  pass
6
6
 
7
7
 
8
- async def __async_sandbox():
8
+ async def _async_sandbox():
9
9
  pass
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __sandbox()
14
- asyncio.run(__async_sandbox())
13
+ _sandbox()
14
+ asyncio.run(_async_sandbox())
@@ -4,3 +4,5 @@ from arpakitlib.ar_additional_model_util import BaseAM
4
4
  class ExampleAM(BaseAM):
5
5
  name: str = "Name"
6
6
  surname: str = "Surname"
7
+
8
+ # ...
@@ -1,9 +1,13 @@
1
+ import importlib
2
+ from contextlib import suppress
3
+
1
4
  from fastapi import FastAPI
2
5
  from sqladmin import Admin
3
6
 
7
+ from arpakitlib.ar_sqladmin_util import SimpleModelView
4
8
  from src.admin1.admin_auth import AdminAuth
5
- from src.admin1.model_view import MODEL_VIEWS
6
9
  from src.api.transmitted_api_data import TransmittedAPIData
10
+ from src.core.settings import get_cached_settings
7
11
 
8
12
 
9
13
  def add_admin1_in_app(*, app: FastAPI) -> FastAPI:
@@ -16,10 +20,13 @@ def add_admin1_in_app(*, app: FastAPI) -> FastAPI:
16
20
  engine=transmitted_api_data.sqlalchemy_db.engine,
17
21
  base_url="/admin1",
18
22
  authentication_backend=authentication_backend,
19
- title="{PROJECT_NAME}"
23
+ title=get_cached_settings().project_name
20
24
  )
21
25
 
22
- for model_view in MODEL_VIEWS:
26
+ with suppress(Exception):
27
+ importlib.import_module("src.admin1.model_view")
28
+
29
+ for model_view in SimpleModelView.all_subclasses:
23
30
  admin.add_model_view(model_view)
24
31
 
25
32
  return app
@@ -1,19 +1 @@
1
- from sqladmin import ModelView
2
-
3
-
4
- class BaseModelView(ModelView):
5
- can_create = True
6
- can_edit = True
7
- can_delete = True
8
- can_view_details = True
9
- can_export = True
10
- page_size = 50
11
- page_size_options = [25, 50, 100, 200]
12
- save_as = True
13
- save_as_continue = True
14
- export_types = ["xlsx", "csv", "json"]
15
-
16
-
17
- MODEL_VIEWS = []
18
-
19
1
  # ...
@@ -3,7 +3,7 @@ import uvicorn
3
3
  from src.core.settings import get_cached_settings
4
4
 
5
5
 
6
- def __command():
6
+ def _start_api_for_dev_with_reload():
7
7
  uvicorn.run(
8
8
  "src.api.asgi:app",
9
9
  port=get_cached_settings().api_port,
@@ -14,4 +14,4 @@ def __command():
14
14
 
15
15
 
16
16
  if __name__ == '__main__':
17
- __command()
17
+ _start_api_for_dev_with_reload()
@@ -3,7 +3,7 @@ import uvicorn
3
3
  from src.core.settings import get_cached_settings
4
4
 
5
5
 
6
- def __command():
6
+ def _start_api_for_dev_without_reload():
7
7
  uvicorn.run(
8
8
  "src.api.asgi:app",
9
9
  port=get_cached_settings().api_port,
@@ -14,4 +14,4 @@ def __command():
14
14
 
15
15
 
16
16
  if __name__ == '__main__':
17
- __command()
17
+ _start_api_for_dev_without_reload()
@@ -7,7 +7,7 @@ from arpakitlib.ar_type_util import raise_for_type
7
7
  from src.api.event import StartupAPIEvent, ShutdownAPIEvent
8
8
  from src.api.router.main_router import main_api_router
9
9
  from src.api.transmitted_api_data import TransmittedAPIData
10
- from src.core.const import STATIC_DIRPATH
10
+ from src.core.const import ProjectPaths
11
11
  from src.core.settings import get_cached_settings
12
12
  from src.core.util import setup_logging, get_cached_media_file_storage_in_dir, get_cached_cache_file_storage_in_dir, \
13
13
  get_cached_dump_file_storage_in_dir
@@ -63,7 +63,7 @@ def create_api_app() -> FastAPI:
63
63
  transmitted_api_data=transmitted_api_data,
64
64
  main_api_router=main_api_router,
65
65
  media_dirpath=settings.media_dirpath,
66
- static_dirpath=STATIC_DIRPATH
66
+ static_dirpath=ProjectPaths.static_dirpath
67
67
  )
68
68
 
69
69
  if settings.api_enable_admin1:
@@ -35,10 +35,7 @@ class StartupAPIEvent(BaseStartupAPIEvent):
35
35
  worker=OperationExecutorWorker(
36
36
  sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db,
37
37
  operation_executor=OperationExecutor(sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db),
38
- filter_operation_types=None,
39
- startup_funcs=[
40
- self.transmitted_api_data.sqlalchemy_db.init
41
- ]
38
+ filter_operation_types=None
42
39
  ),
43
40
  mode=SafeRunInBackgroundModes.thread
44
41
  )
@@ -48,10 +45,7 @@ class StartupAPIEvent(BaseStartupAPIEvent):
48
45
  _ = safe_run_worker_in_background(
49
46
  worker=ScheduledOperationCreatorWorker(
50
47
  sqlalchemy_db=self.transmitted_api_data.sqlalchemy_db,
51
- scheduled_operations=SCHEDULED_OPERATIONS,
52
- startup_funcs=[
53
- self.transmitted_api_data.sqlalchemy_db.init
54
- ]
48
+ scheduled_operations=SCHEDULED_OPERATIONS
55
49
  ),
56
50
  mode=SafeRunInBackgroundModes.async_task
57
51
  )
@@ -12,6 +12,7 @@ api_router = APIRouter()
12
12
 
13
13
  @api_router.get(
14
14
  "",
15
+ name="Get API Error info",
15
16
  response_model=APIErrorInfoSO | ErrorSO,
16
17
  status_code=status.HTTP_200_OK
17
18
  )
@@ -4,8 +4,12 @@ from src.api.router.v1 import get_api_error_info
4
4
 
5
5
  main_v1_api_router = APIRouter()
6
6
 
7
+ # API Error Info
8
+
7
9
  main_v1_api_router.include_router(
8
10
  router=get_api_error_info.api_router,
9
11
  prefix="/get_api_error_info",
10
12
  tags=["API Error Info"]
11
13
  )
14
+
15
+ # ...
@@ -4,3 +4,5 @@ from arpakitlib.ar_fastapi_util import BaseSO
4
4
  class APIErrorInfoSO(BaseSO):
5
5
  api_error_codes: list[str] = []
6
6
  api_error_specification_codes: list[str] = []
7
+
8
+ # ...
@@ -11,3 +11,5 @@ class TransmittedAPIData(BaseTransmittedAPIData):
11
11
  media_file_storage_in_dir: FileStorageInDir | None = None
12
12
  cache_file_storage_in_dir: FileStorageInDir | None = None
13
13
  dump_file_storage_in_dir: FileStorageInDir | None = None
14
+
15
+ # ...
@@ -1,5 +1,7 @@
1
1
  import logging
2
2
 
3
+ from src.core.util import setup_logging
4
+
3
5
  _logger = logging.getLogger(__name__)
4
6
 
5
7
 
@@ -9,4 +11,5 @@ def hello_world() -> str:
9
11
 
10
12
 
11
13
  if __name__ == '__main__':
12
- print(hello_world())
14
+ setup_logging()
15
+ hello_world()
@@ -5,10 +5,10 @@ from src.core.util import setup_logging
5
5
  _logger = logging.getLogger(__name__)
6
6
 
7
7
 
8
- def __check_logging():
8
+ def _check_logging():
9
9
  setup_logging()
10
10
  _logger.info("logging is good")
11
11
 
12
12
 
13
13
  if __name__ == '__main__':
14
- __check_logging()
14
+ _check_logging()
@@ -1,12 +1,10 @@
1
1
  from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
2
2
  from src.core.settings import get_cached_settings
3
- from src.core.util import setup_logging
4
3
 
5
4
 
6
- def command():
7
- setup_logging()
5
+ def _check_settings():
8
6
  print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
9
7
 
10
8
 
11
9
  if __name__ == '__main__':
12
- command()
10
+ _check_settings()
@@ -1,16 +1,14 @@
1
1
  import os.path
2
2
 
3
3
  from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
4
- from src.core.const import BASE_DIRPATH
4
+ from src.core.const import ProjectPaths
5
5
  from src.core.settings import Settings, get_cached_settings
6
- from src.core.util import setup_logging
7
6
 
8
7
 
9
- def command():
10
- setup_logging()
8
+ def _generate_settings_env_example():
11
9
  print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
12
- Settings.save_env_example_to_file(filepath=os.path.join(BASE_DIRPATH, "example.env"))
10
+ Settings.save_env_example_to_file(filepath=os.path.join(ProjectPaths.base_dirpath, "example.env"))
13
11
 
14
12
 
15
13
  if __name__ == '__main__':
16
- command()
14
+ _generate_settings_env_example()
@@ -2,41 +2,34 @@ import asyncio
2
2
  import os
3
3
  import pathlib
4
4
 
5
- BASE_DIRPATH: str = str(pathlib.Path(__file__).parent.parent.parent)
5
+ from arpakitlib.ar_enumeration_util import Enumeration
6
+ from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
6
7
 
7
- ENV_FILENAME: str = ".env"
8
8
 
9
- ENV_FILEPATH: str = os.path.join(BASE_DIRPATH, ENV_FILENAME)
9
+ class ProjectPaths(Enumeration):
10
+ base_dirpath: str = str(pathlib.Path(__file__).parent.parent.parent)
10
11
 
11
- SRC_DIRNAME: str = "src"
12
+ env_filename: str = ".env"
13
+ env_filepath: str = os.path.join(base_dirpath, env_filename)
12
14
 
13
- SRC_DIRPATH: str = os.path.join(BASE_DIRPATH, SRC_DIRNAME)
15
+ src_dirname: str = "src"
16
+ src_dirpath: str = os.path.join(base_dirpath, src_dirname)
14
17
 
15
- MANAGE_DIRNAME: str = "manage"
18
+ manage_dirname: str = "manage"
19
+ manage_dirpath: str = os.path.join(base_dirpath, manage_dirname)
16
20
 
17
- MANAGE_DIRPATH: str = os.path.join(BASE_DIRPATH, MANAGE_DIRNAME)
21
+ resource_dirname: str = "resource"
22
+ resource_dirpath: str = os.path.join(base_dirpath, resource_dirname)
18
23
 
19
- RESOURCE_DIRNAME: str = "resource"
24
+ static_dirname: str = "static"
25
+ static_dirpath: str = os.path.join(resource_dirpath, static_dirname)
20
26
 
21
- RESOURCE_DIRPATH: str = os.path.join(BASE_DIRPATH, RESOURCE_DIRNAME)
22
27
 
23
- STATIC_DIRNAME: str = "static"
24
-
25
- STATIC_DIRPATH: str = os.path.join(RESOURCE_DIRPATH, STATIC_DIRNAME)
28
+ # ...
26
29
 
27
30
 
28
31
  def __example():
29
- print(f"BASE_DIRPATH: {BASE_DIRPATH}")
30
- print(f"ENV_FILENAME: {ENV_FILENAME}")
31
- print(f"ENV_FILEPATH: {ENV_FILEPATH}")
32
- print(f"SRC_DIRNAME: {SRC_DIRNAME}")
33
- print(f"SRC_DIRPATH: {SRC_DIRPATH}")
34
- print(f"MANAGE_DIRNAME: {MANAGE_DIRNAME}")
35
- print(f"MANAGE_DIRPATH: {MANAGE_DIRPATH}")
36
- print(f"RESOURCE_DIRNAME: {RESOURCE_DIRNAME}")
37
- print(f"RESOURCE_DIRPATH: {RESOURCE_DIRPATH}")
38
- print(f"STATIC_DIRNAME: {STATIC_DIRNAME}")
39
- print(f"STATIC_DIRPATH: {STATIC_DIRPATH}")
32
+ print(safely_transfer_obj_to_json_str(ProjectPaths.key_to_value()))
40
33
 
41
34
 
42
35
  async def __async_example():
@@ -1,4 +1,3 @@
1
- import asyncio
2
1
  import os
3
2
  from functools import lru_cache
4
3
  from typing import Any
@@ -7,23 +6,36 @@ import pytz
7
6
 
8
7
  from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
9
8
  from arpakitlib.ar_settings_util import SimpleSettings
10
- from src.core.const import BASE_DIRPATH, ENV_FILEPATH
9
+ from src.core.const import ProjectPaths
11
10
 
12
11
 
13
12
  class Settings(SimpleSettings):
14
- project_name: str = "{PROJECT_NAME}"
13
+ project_name: str = "{{PROJECT_NAME}}"
14
+
15
+ sql_db_user: str | None = project_name
16
+
17
+ sql_db_password: str | None = project_name
18
+
19
+ sql_db_port: int | None = int("{{SQL_DB_PORT}}") if "{{SQL_DB_PORT}}".strip().isdigit() else None
20
+
21
+ sql_db_database: str | None = project_name
15
22
 
16
23
  sql_db_url: str | None = (
17
- "postgresql://{PROJECT_NAME}:{PROJECT_NAME}@127.0.0.1:{SQL_DB_PORT}/{PROJECT_NAME}"
18
- ) if (str("{PROJECT_NAME}") and str("{SQL_DB_PORT}").strip().isdigit()) else None
24
+ f"postgresql://{sql_db_user}:{sql_db_password}@127.0.0.1:{sql_db_port}/{sql_db_database}"
25
+ ) if (
26
+ sql_db_user is not None
27
+ and sql_db_password is not None
28
+ and sql_db_port is not None
29
+ and sql_db_database is not None
30
+ ) else None
19
31
 
20
32
  sql_db_echo: bool = False
21
33
 
22
34
  api_init_sql_db_at_start: bool = True
23
35
 
24
- api_title: str = "{PROJECT_NAME}"
36
+ api_title: str = project_name
25
37
 
26
- api_description: str = "{PROJECT_NAME} (arpakitlib)"
38
+ api_description: str = f"{project_name} (arpakitlib)"
27
39
 
28
40
  api_create_story_log_before_response_in_handle_exception: bool = True
29
41
 
@@ -31,7 +43,7 @@ class Settings(SimpleSettings):
31
43
 
32
44
  api_start_scheduled_operation_creator_worker: bool = False
33
45
 
34
- api_port: int | None = int("{API_PORT}") if "{API_PORT}".strip().isdigit() else None
46
+ api_port: int | None = int("{{API_PORT}}") if "{{API_PORT}}".strip().isdigit() else None
35
47
 
36
48
  api_correct_api_key: str | None = "1"
37
49
 
@@ -41,7 +53,7 @@ class Settings(SimpleSettings):
41
53
 
42
54
  var_dirname: str | None = "var"
43
55
 
44
- var_dirpath: str | None = os.path.join(BASE_DIRPATH, var_dirname)
56
+ var_dirpath: str | None = os.path.join(ProjectPaths.base_dirpath, var_dirname)
45
57
 
46
58
  log_filename: str | None = "story.log"
47
59
 
@@ -72,19 +84,10 @@ class Settings(SimpleSettings):
72
84
 
73
85
  @lru_cache()
74
86
  def get_cached_settings() -> Settings:
75
- if os.path.exists(ENV_FILEPATH):
76
- return Settings(_env_file=ENV_FILEPATH, _env_file_encoding="utf-8")
87
+ if os.path.exists(ProjectPaths.env_filepath):
88
+ return Settings(_env_file=ProjectPaths.env_filepath, _env_file_encoding="utf-8")
77
89
  return Settings()
78
90
 
79
91
 
80
- def __example():
81
- print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
82
-
83
-
84
- async def __async_example():
85
- pass
86
-
87
-
88
92
  if __name__ == '__main__':
89
- __example()
90
- asyncio.run(__async_example())
93
+ print(safely_transfer_obj_to_json_str(get_cached_settings().model_dump(mode="json")))
@@ -45,6 +45,9 @@ def now_local_dt() -> datetime:
45
45
  return now_dt(tz=get_cached_settings().local_timezone_as_pytz)
46
46
 
47
47
 
48
+ # ...
49
+
50
+
48
51
  def __example():
49
52
  pass
50
53
 
@@ -2,10 +2,10 @@ from src.core.util import setup_logging
2
2
  from src.db.util import get_cached_sqlalchemy_db
3
3
 
4
4
 
5
- def command():
5
+ def _check_conn_sqlalchemy_db():
6
6
  setup_logging()
7
7
  get_cached_sqlalchemy_db().check_conn()
8
8
 
9
9
 
10
10
  if __name__ == '__main__':
11
- command()
11
+ _check_conn_sqlalchemy_db()
@@ -2,10 +2,10 @@ from src.core.util import setup_logging
2
2
  from src.db.util import get_cached_sqlalchemy_db
3
3
 
4
4
 
5
- def __init_sqlalchemy_db():
5
+ def _init_sqlalchemy_db():
6
6
  setup_logging()
7
7
  get_cached_sqlalchemy_db().init()
8
8
 
9
9
 
10
10
  if __name__ == '__main__':
11
- __init_sqlalchemy_db()
11
+ _init_sqlalchemy_db()
@@ -3,11 +3,11 @@ from src.core.util import setup_logging
3
3
  from src.db.util import get_cached_sqlalchemy_db
4
4
 
5
5
 
6
- def __reinit_sqlalchemy_db():
6
+ def _reinit_sqlalchemy_db():
7
7
  setup_logging()
8
- get_cached_settings().raise_if_mode_type_not_prod()
8
+ get_cached_settings().raise_if_mode_type_prod()
9
9
  get_cached_sqlalchemy_db().reinit()
10
10
 
11
11
 
12
12
  if __name__ == '__main__':
13
- __reinit_sqlalchemy_db()
13
+ _reinit_sqlalchemy_db()