This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| from functools import wraps | |
| from typing import Any, Callable | |
| logger = logging.getLogger(__name__) | |
| def section(section_name: str, sep_char: str = "=", sep_len: int = 88) -> Callable: | |
| """Decorator to log a section name at the start and end of a function's execution. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| from typing import List | |
| import aiohttp | |
| async def fetch(url: str, session: aiohttp.ClientSession) -> str: | |
| """Asynchronously fetches the content from a URL using aiohttp. | |
| Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import logging | |
| import logging.config | |
| from datetime import datetime | |
| from pathlib import Path | |
| from typing import Callable, Dict | |
| import tomllib | |
| import yaml | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def setup_logging( | |
| config_filename: PathLike = "logging.yaml", log_dir: PathLike = "logs" | |
| ) -> logging.Logger: | |
| """Get logger object.""" | |
| log_path = Path(log_dir) | |
| log_path.mkdir(exist_ok=True, parents=True) | |
| config = load_config(config_filename) | |
| config["handlers"]["file"]["filename"] = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| from functools import wraps | |
| from pathlib import Path | |
| from typing import Union | |
| logger = logging.getLogger(__name__) | |
| class FileLock: | |
| """ |