Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
refactor: minor reorganization of files for better clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Dec 28, 2024
1 parent d8111ee commit 7fef896
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 68 deletions.
3 changes: 2 additions & 1 deletion src/check_phat_nguoi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from logging import Logger, getLogger

from check_phat_nguoi.config import config
from check_phat_nguoi.modules import setup_logger

from .utils.setup_logger import setup_logger

logger: Logger = getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/check_phat_nguoi/config/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Final

from check_phat_nguoi.config.exceptions.no_config_found import NoConfigFoundException
from check_phat_nguoi.utils.constants import CONFIG_PATHS
from check_phat_nguoi.modules.constants.config import CONFIG_PATHS

from .dto import ConfigDTO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
from typing import Dict, override

from aiohttp import ClientConnectionError, ClientSession, ClientTimeout
from pydantic_core.core_schema import tuple_positional_schema

from check_phat_nguoi.config import PlateInfoDTO
from check_phat_nguoi.context import PlateInfoModel, ViolationModel
from check_phat_nguoi.context.plate_context.models.resolution_office import (
ResolutionOfficeModel,
)
from check_phat_nguoi.utils.constants import (

from ..modules.constants.get_data import (
DATETIME_FORMAT_CHECKPHATNGUOI as DATETIME_FORMAT,
)
from check_phat_nguoi.utils.constants import GET_DATA_API_URL_CHECKPHATNGUOI as API_URL
from check_phat_nguoi.utils.constants import OFFICE_NAME_PATTERN

from ..modules.constants.get_data import GET_DATA_API_URL_CHECKPHATNGUOI as API_URL
from ..modules.constants.get_data import OFFICE_NAME_PATTERN
from .get_data_base import GetDataBase

logger = getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from abc import abstractmethod

from check_phat_nguoi.config import PlateInfoDTO
from check_phat_nguoi.config.dto.config import ConfigDTO
from check_phat_nguoi.context import PlateInfoModel


Expand Down
6 changes: 1 addition & 5 deletions src/check_phat_nguoi/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from check_phat_nguoi.modules.setup_logger import setup_logger

from .get_data import *

__all__ = ["setup_logger", "GetDataCheckPhatNguoi"]
from .constants import *
23 changes: 23 additions & 0 deletions src/check_phat_nguoi/modules/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from .config import CONFIG_PATHS, DETAIL_LOG_MESSAGE, SIMPLE_LOG_MESSAGE
from .get_data import (
DATETIME_FORMAT_CHECKPHATNGUOI,
GET_DATA_API_URL_CHECKPHATNGUOI,
OFFICE_NAME_PATTERN,
)
from .notify import (
MESSAGE_MARKDOWN_PATTERN,
RESOLUTION_LOCATION_MARKDOWN_PATTERN,
SEND_MESSAGE_API_URL_TELEGRAM,
)

__all__ = [
"CONFIG_PATHS",
"DETAIL_LOG_MESSAGE",
"SIMPLE_LOG_MESSAGE",
"DATETIME_FORMAT_CHECKPHATNGUOI",
"GET_DATA_API_URL_CHECKPHATNGUOI",
"OFFICE_NAME_PATTERN",
"SEND_MESSAGE_API_URL_TELEGRAM",
"MESSAGE_MARKDOWN_PATTERN",
"RESOLUTION_LOCATION_MARKDOWN_PATTERN",
]
3 changes: 0 additions & 3 deletions src/check_phat_nguoi/modules/constants/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
GET_DATA_API_URL_CHECKPHATNGUOI: LiteralString = (
"https://api.checkphatnguoi.vn/phatnguoi"
)
SEND_MESSAGE_API_URL_TELEGRAM: LiteralString = (
"https://api.telegram.org/bot{bot_token}/sendMessage"
)
DATETIME_FORMAT_CHECKPHATNGUOI: LiteralString = "%H:%M, %d/%m/%Y"

OFFICE_NAME_PATTERN = r"^\d+\."
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from typing import Dict, LiteralString

from check_phat_nguoi.context import PlateInfoModel, PlatesModel
from check_phat_nguoi.context.plate_context.models.resolution_office import (
ResolutionOfficeModel,
)
from check_phat_nguoi.utils.constants import (

from ..modules.constants.notify import (
MESSAGE_MARKDOWN_PATTERN,
RESOLUTION_LOCATION_MARKDOWN_PATTERN,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from aiohttp import ClientConnectionError, ClientSession, ClientTimeout

from check_phat_nguoi.config import TelegramNotifyDTO
from check_phat_nguoi.utils.constants import SEND_MESSAGE_API_URL_TELEGRAM as API_URL

from ..modules.constants.notify import SEND_MESSAGE_API_URL_TELEGRAM as API_URL

logger = getLogger(__name__)

Expand Down
47 changes: 0 additions & 47 deletions src/check_phat_nguoi/utils/constants.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from logging import basicConfig

from check_phat_nguoi.config import config
from check_phat_nguoi.utils.constants import DETAIL_LOG_MESSAGE, SIMPLE_LOG_MESSAGE
from check_phat_nguoi.modules.constants.config import (
DETAIL_LOG_MESSAGE,
SIMPLE_LOG_MESSAGE,
)


def setup_logger() -> None:
Expand Down

0 comments on commit 7fef896

Please sign in to comment.