From 0b654d9520b1b33d67447659ff364cb52ed88092 Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 20:19:42 +0000 Subject: [PATCH 1/6] working on supressing library logging when library is used --- coverage.xml | 766 +++++++++--------- docs/recipes/fastapi.md | 3 +- docs/recipes/loggingExample.md | 3 +- dsg_lib/__init__.py | 7 + .../__import_sqlalchemy.py | 4 +- .../async_database.py | 3 +- .../database_config.py | 3 +- .../database_operations.py | 3 +- .../common_functions/calendar_functions.py | 3 +- dsg_lib/common_functions/email_validation.py | 3 +- dsg_lib/common_functions/file_functions.py | 3 +- dsg_lib/common_functions/folder_functions.py | 3 +- dsg_lib/common_functions/patterns.py | 3 +- dsg_lib/fastapi_functions/http_codes.py | 3 +- .../system_health_endpoints.py | 3 +- 15 files changed, 418 insertions(+), 395 deletions(-) diff --git a/coverage.xml b/coverage.xml index 4bbc9403..6028a04d 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -12,6 +12,10 @@ + + + + @@ -21,9 +25,9 @@ - + @@ -33,23 +37,23 @@ - - - - - + + + + - - + + - - + + - - - + + + + @@ -97,216 +101,216 @@ - - - - - - + + + + + - + - + - - - - + + + + - + - - + + + - - + - - - - - + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - + - + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + - + - - + + - + - + - - + + - - - - - - - + + + + + + + - + - - + + - + - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + + @@ -320,79 +324,79 @@ - - - - + + + - + - + - - - - - + + + + + - - + + - + + - - - - + + + - - - - + + + + - + - + - - - + + + - + - - + + - + - + - + + @@ -400,227 +404,227 @@ - - - - - - + + + + + - - + + - + - + - + - + - - - - + + + + - + - + - - - - + + + + - - - + + + - - + + - + - + - - - + + + - - + + - + - + - + - + - + - - + + - + - - - + + + - + - + - + - + - + - + - - - - - + + + + + - + - + - - + + - - + + - + - - + + - + - - - - - - - + + + + + + + - + - + - + - - + + - + - + - + - + + - - + - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + @@ -677,23 +681,23 @@ - - - + + - - + + - - - - - + + + + + - + + @@ -713,78 +717,78 @@ - - - - - - - - - - - - + + + + + + + + + + + - + - + - + + - + + - - - - + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - - + + + - + - - + diff --git a/docs/recipes/fastapi.md b/docs/recipes/fastapi.md index 82c706e7..e2ff9827 100644 --- a/docs/recipes/fastapi.md +++ b/docs/recipes/fastapi.md @@ -26,7 +26,8 @@ from contextlib import asynccontextmanager from fastapi import Body, FastAPI, Query from fastapi.responses import RedirectResponse # from loguru import logger -import logging as logger +# import logging as logger +from . import logger from pydantic import BaseModel, EmailStr from sqlalchemy import Column, ForeignKey, Select, String from sqlalchemy.orm import relationship diff --git a/docs/recipes/loggingExample.md b/docs/recipes/loggingExample.md index e5f39787..af5b515c 100644 --- a/docs/recipes/loggingExample.md +++ b/docs/recipes/loggingExample.md @@ -13,7 +13,8 @@ import secrets import threading # from loguru import logger -import logging as logger +# import logging as logger +from . import logger from tqdm import tqdm from dsg_lib.common_functions import logging_config diff --git a/dsg_lib/__init__.py b/dsg_lib/__init__.py index fda496d8..14f428af 100644 --- a/dsg_lib/__init__.py +++ b/dsg_lib/__init__.py @@ -10,3 +10,10 @@ """ __version__ = "0.14.2" + +import logging + +# Configure the library's logger +logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) +logger.propagate = False diff --git a/dsg_lib/async_database_functions/__import_sqlalchemy.py b/dsg_lib/async_database_functions/__import_sqlalchemy.py index ef1aa06b..acfc5cac 100644 --- a/dsg_lib/async_database_functions/__import_sqlalchemy.py +++ b/dsg_lib/async_database_functions/__import_sqlalchemy.py @@ -25,7 +25,9 @@ 2024/07/26 """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger + from typing import Tuple from packaging import version as packaging_version diff --git a/dsg_lib/async_database_functions/async_database.py b/dsg_lib/async_database_functions/async_database.py index 150f7ee9..6ad23ef8 100644 --- a/dsg_lib/async_database_functions/async_database.py +++ b/dsg_lib/async_database_functions/async_database.py @@ -51,7 +51,8 @@ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger from .database_config import BASE, DBConfig diff --git a/dsg_lib/async_database_functions/database_config.py b/dsg_lib/async_database_functions/database_config.py index 1a2d1b85..e26a5547 100644 --- a/dsg_lib/async_database_functions/database_config.py +++ b/dsg_lib/async_database_functions/database_config.py @@ -44,7 +44,8 @@ License: MIT """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger from contextlib import asynccontextmanager from typing import Dict diff --git a/dsg_lib/async_database_functions/database_operations.py b/dsg_lib/async_database_functions/database_operations.py index 0557695c..59c75ace 100644 --- a/dsg_lib/async_database_functions/database_operations.py +++ b/dsg_lib/async_database_functions/database_operations.py @@ -30,7 +30,8 @@ """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger import time from typing import Dict, List, Type diff --git a/dsg_lib/common_functions/calendar_functions.py b/dsg_lib/common_functions/calendar_functions.py index 7574cfb2..57b6cd34 100644 --- a/dsg_lib/common_functions/calendar_functions.py +++ b/dsg_lib/common_functions/calendar_functions.py @@ -51,7 +51,8 @@ License: MIT """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger def get_month(month: int) -> str: diff --git a/dsg_lib/common_functions/email_validation.py b/dsg_lib/common_functions/email_validation.py index 59ebe9fe..908df058 100644 --- a/dsg_lib/common_functions/email_validation.py +++ b/dsg_lib/common_functions/email_validation.py @@ -37,7 +37,8 @@ License: MIT """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger from enum import Enum from typing import Dict, List, Union diff --git a/dsg_lib/common_functions/file_functions.py b/dsg_lib/common_functions/file_functions.py index 4140744a..1061e839 100644 --- a/dsg_lib/common_functions/file_functions.py +++ b/dsg_lib/common_functions/file_functions.py @@ -41,7 +41,8 @@ import csv import json # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger import os import random from datetime import datetime diff --git a/dsg_lib/common_functions/folder_functions.py b/dsg_lib/common_functions/folder_functions.py index de69d1e2..6afb4062 100644 --- a/dsg_lib/common_functions/folder_functions.py +++ b/dsg_lib/common_functions/folder_functions.py @@ -38,7 +38,8 @@ """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger import re from datetime import datetime from pathlib import Path diff --git a/dsg_lib/common_functions/patterns.py b/dsg_lib/common_functions/patterns.py index 3bc97ba8..03646588 100644 --- a/dsg_lib/common_functions/patterns.py +++ b/dsg_lib/common_functions/patterns.py @@ -39,7 +39,8 @@ """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger import re diff --git a/dsg_lib/fastapi_functions/http_codes.py b/dsg_lib/fastapi_functions/http_codes.py index 586163a8..4f9b8a27 100644 --- a/dsg_lib/fastapi_functions/http_codes.py +++ b/dsg_lib/fastapi_functions/http_codes.py @@ -29,7 +29,8 @@ License: MIT """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import logger from typing import Dict, List, Union from ._all_codes import ALL_HTTP_CODES diff --git a/dsg_lib/fastapi_functions/system_health_endpoints.py b/dsg_lib/fastapi_functions/system_health_endpoints.py index 1a2f9647..dbdeca25 100644 --- a/dsg_lib/fastapi_functions/system_health_endpoints.py +++ b/dsg_lib/fastapi_functions/system_health_endpoints.py @@ -69,8 +69,7 @@ """ # Importing database connector module -# from loguru import logger -import logging as logger +from loguru import logger # Import necessary modules import time import tracemalloc From 2fe6cfd4f011ec22c8b4759a0f6483514ac0960f Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 20:52:53 +0000 Subject: [PATCH 2/6] working on suppressing standard logging, unless wanted. --- dsg_lib/__init__.py | 16 ++++++++++------ .../__import_sqlalchemy.py | 2 +- .../async_database_functions/async_database.py | 2 +- .../async_database_functions/database_config.py | 2 +- .../database_operations.py | 2 +- dsg_lib/common_functions/calendar_functions.py | 2 +- dsg_lib/common_functions/email_validation.py | 2 +- dsg_lib/common_functions/file_functions.py | 2 +- dsg_lib/common_functions/folder_functions.py | 2 +- dsg_lib/common_functions/patterns.py | 2 +- dsg_lib/fastapi_functions/http_codes.py | 2 +- .../fastapi_functions/system_health_endpoints.py | 2 +- examples/fastapi_example.py | 8 ++++---- 13 files changed, 25 insertions(+), 21 deletions(-) diff --git a/dsg_lib/__init__.py b/dsg_lib/__init__.py index 14f428af..4e1ca02e 100644 --- a/dsg_lib/__init__.py +++ b/dsg_lib/__init__.py @@ -3,17 +3,21 @@ DevSetGo Library ========= -DevSetGo Library is a Python library offering reusable functions for efficient coding. It includes file operations, calendar utilities, pattern matching, advanced logging with loguru, FastAPI endpoints, async database handling, and email validation. Designed for ease of use and versatility, it's a valuable tool for Python developers. - Author: Mike Ryan License: MIT """ - +from datetime import date __version__ = "0.14.2" +__author__ = "Mike Ryan" +__license__ = "MIT" +__copyright__ = f"Copyright© 2021-{date.today().year}" +__site__ = "https://github.com/devsetgo/devsetgo_lib" + +# Import the library's modules import logging # Configure the library's logger -logger = logging.getLogger(__name__) -logger.addHandler(logging.NullHandler()) -logger.propagate = False +LOGGER = logging.getLogger("devsetgo_lib") +LOGGER.addHandler(logging.NullHandler()) +LOGGER.propagate = False diff --git a/dsg_lib/async_database_functions/__import_sqlalchemy.py b/dsg_lib/async_database_functions/__import_sqlalchemy.py index acfc5cac..43706cc7 100644 --- a/dsg_lib/async_database_functions/__import_sqlalchemy.py +++ b/dsg_lib/async_database_functions/__import_sqlalchemy.py @@ -26,7 +26,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger from typing import Tuple diff --git a/dsg_lib/async_database_functions/async_database.py b/dsg_lib/async_database_functions/async_database.py index 6ad23ef8..8e3b11e9 100644 --- a/dsg_lib/async_database_functions/async_database.py +++ b/dsg_lib/async_database_functions/async_database.py @@ -52,7 +52,7 @@ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger from .database_config import BASE, DBConfig diff --git a/dsg_lib/async_database_functions/database_config.py b/dsg_lib/async_database_functions/database_config.py index e26a5547..384369a0 100644 --- a/dsg_lib/async_database_functions/database_config.py +++ b/dsg_lib/async_database_functions/database_config.py @@ -45,7 +45,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger from contextlib import asynccontextmanager from typing import Dict diff --git a/dsg_lib/async_database_functions/database_operations.py b/dsg_lib/async_database_functions/database_operations.py index 59c75ace..57251cdb 100644 --- a/dsg_lib/async_database_functions/database_operations.py +++ b/dsg_lib/async_database_functions/database_operations.py @@ -31,7 +31,7 @@ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger import time from typing import Dict, List, Type diff --git a/dsg_lib/common_functions/calendar_functions.py b/dsg_lib/common_functions/calendar_functions.py index 57b6cd34..a56c196d 100644 --- a/dsg_lib/common_functions/calendar_functions.py +++ b/dsg_lib/common_functions/calendar_functions.py @@ -52,7 +52,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger def get_month(month: int) -> str: diff --git a/dsg_lib/common_functions/email_validation.py b/dsg_lib/common_functions/email_validation.py index 908df058..eec70760 100644 --- a/dsg_lib/common_functions/email_validation.py +++ b/dsg_lib/common_functions/email_validation.py @@ -38,7 +38,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger from enum import Enum from typing import Dict, List, Union diff --git a/dsg_lib/common_functions/file_functions.py b/dsg_lib/common_functions/file_functions.py index 1061e839..e4f98df9 100644 --- a/dsg_lib/common_functions/file_functions.py +++ b/dsg_lib/common_functions/file_functions.py @@ -42,7 +42,7 @@ import json # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger import os import random from datetime import datetime diff --git a/dsg_lib/common_functions/folder_functions.py b/dsg_lib/common_functions/folder_functions.py index 6afb4062..27452369 100644 --- a/dsg_lib/common_functions/folder_functions.py +++ b/dsg_lib/common_functions/folder_functions.py @@ -39,7 +39,7 @@ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger import re from datetime import datetime from pathlib import Path diff --git a/dsg_lib/common_functions/patterns.py b/dsg_lib/common_functions/patterns.py index 03646588..b174466b 100644 --- a/dsg_lib/common_functions/patterns.py +++ b/dsg_lib/common_functions/patterns.py @@ -40,7 +40,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger import re diff --git a/dsg_lib/fastapi_functions/http_codes.py b/dsg_lib/fastapi_functions/http_codes.py index 4f9b8a27..63a82b12 100644 --- a/dsg_lib/fastapi_functions/http_codes.py +++ b/dsg_lib/fastapi_functions/http_codes.py @@ -30,7 +30,7 @@ """ # from loguru import logger # import logging as logger -from .. import logger +from .. import LOGGER as logger from typing import Dict, List, Union from ._all_codes import ALL_HTTP_CODES diff --git a/dsg_lib/fastapi_functions/system_health_endpoints.py b/dsg_lib/fastapi_functions/system_health_endpoints.py index dbdeca25..d5c55eaf 100644 --- a/dsg_lib/fastapi_functions/system_health_endpoints.py +++ b/dsg_lib/fastapi_functions/system_health_endpoints.py @@ -381,7 +381,7 @@ async def get_heapdump(): } ) - logger.debug(f"Heap dump returned {heap_dump}") + logger.info(f"Heap dump returned {heap_dump}") memory_use = tracemalloc.get_traced_memory() return { "memory_use": { diff --git a/examples/fastapi_example.py b/examples/fastapi_example.py index 837e22fd..ae18c882 100644 --- a/examples/fastapi_example.py +++ b/examples/fastapi_example.py @@ -5,8 +5,8 @@ License: MIT """ import datetime -# from loguru import logger -import logging as logger +from loguru import logger + import secrets import time from contextlib import asynccontextmanager @@ -28,7 +28,7 @@ from dsg_lib.fastapi_functions import system_health_endpoints # , system_tools_endpoints logging_config.config_log( - logging_level="INFO", log_serializer=False, log_name="log.log" + logging_level="INFO", log_serializer=False, logging_directory="log", log_name="log.log", intercept_standard_logging=False ) # Create a DBConfig instance config = { @@ -345,4 +345,4 @@ async def read_list_of_records( if __name__ == "__main__": import uvicorn - uvicorn.run(app, host="127.0.0.1", port=5000) + uvicorn.run(app, host="127.0.0.1", port=5001) From 27c3e8c39ad4c97ad46391ae0b1f316b21ccbfaa Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 20:53:08 +0000 Subject: [PATCH 3/6] working on suppressing standard logging, unless wanted. --- coverage.xml | 1013 +++++++++++++++++++++++++------------------------- 1 file changed, 509 insertions(+), 504 deletions(-) diff --git a/coverage.xml b/coverage.xml index 6028a04d..c75cbea9 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,9 +1,9 @@ - + - /github/workspace + /workspaces/devsetgo_lib @@ -11,16 +11,21 @@ + + + + - - + + + - + @@ -34,7 +39,7 @@ - + @@ -45,15 +50,15 @@ - - + + - - - - - - + + + + + + @@ -98,7 +103,7 @@ - + @@ -113,21 +118,21 @@ - - - + + + - - - - + + + + - + @@ -137,219 +142,219 @@ - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - + @@ -360,46 +365,46 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -413,166 +418,166 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + @@ -584,50 +589,50 @@ - - - - - - - - + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - + @@ -641,68 +646,68 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + @@ -714,7 +719,7 @@ - + @@ -722,8 +727,8 @@ - - + + @@ -739,7 +744,7 @@ - + @@ -761,33 +766,33 @@ - - + + - - - - - - + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + From 0450e1ce4fca9cc7f4a42da879c13f0907977f4b Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 21:08:47 +0000 Subject: [PATCH 4/6] formatting --- dsg_lib/__init__.py | 1 + dsg_lib/async_database_functions/__import_sqlalchemy.py | 8 ++++---- dsg_lib/async_database_functions/async_database.py | 3 +-- dsg_lib/async_database_functions/database_config.py | 6 +++--- dsg_lib/async_database_functions/database_operations.py | 6 +++--- dsg_lib/common_functions/calendar_functions.py | 2 +- dsg_lib/common_functions/email_validation.py | 7 ++++--- dsg_lib/common_functions/file_functions.py | 7 ++++--- dsg_lib/common_functions/folder_functions.py | 7 ++++--- dsg_lib/common_functions/patterns.py | 5 +++-- dsg_lib/fastapi_functions/http_codes.py | 6 +++--- dsg_lib/fastapi_functions/system_health_endpoints.py | 4 ++-- examples/fastapi_example.py | 3 +-- 13 files changed, 34 insertions(+), 31 deletions(-) diff --git a/dsg_lib/__init__.py b/dsg_lib/__init__.py index 4e1ca02e..05a99cda 100644 --- a/dsg_lib/__init__.py +++ b/dsg_lib/__init__.py @@ -7,6 +7,7 @@ License: MIT """ from datetime import date + __version__ = "0.14.2" __author__ = "Mike Ryan" __license__ = "MIT" diff --git a/dsg_lib/async_database_functions/__import_sqlalchemy.py b/dsg_lib/async_database_functions/__import_sqlalchemy.py index 43706cc7..161cdde9 100644 --- a/dsg_lib/async_database_functions/__import_sqlalchemy.py +++ b/dsg_lib/async_database_functions/__import_sqlalchemy.py @@ -24,14 +24,14 @@ Date Updated: 2024/07/26 """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger - from typing import Tuple from packaging import version as packaging_version +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Importing AsyncDatabase class from local module async_database diff --git a/dsg_lib/async_database_functions/async_database.py b/dsg_lib/async_database_functions/async_database.py index 8e3b11e9..ede01d8c 100644 --- a/dsg_lib/async_database_functions/async_database.py +++ b/dsg_lib/async_database_functions/async_database.py @@ -52,8 +52,7 @@ # from loguru import logger # import logging as logger -from .. import LOGGER as logger - +from .. import LOGGER as logger from .database_config import BASE, DBConfig diff --git a/dsg_lib/async_database_functions/database_config.py b/dsg_lib/async_database_functions/database_config.py index 384369a0..3eacf072 100644 --- a/dsg_lib/async_database_functions/database_config.py +++ b/dsg_lib/async_database_functions/database_config.py @@ -43,12 +43,12 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger from contextlib import asynccontextmanager from typing import Dict +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from .__import_sqlalchemy import import_sqlalchemy ( diff --git a/dsg_lib/async_database_functions/database_operations.py b/dsg_lib/async_database_functions/database_operations.py index 57251cdb..cffa2e78 100644 --- a/dsg_lib/async_database_functions/database_operations.py +++ b/dsg_lib/async_database_functions/database_operations.py @@ -29,15 +29,15 @@ License: MIT """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger import time from typing import Dict, List, Type from sqlalchemy import delete from sqlalchemy.ext.declarative import DeclarativeMeta +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from .__import_sqlalchemy import import_sqlalchemy # Importing AsyncDatabase class from local module async_database from .async_database import AsyncDatabase diff --git a/dsg_lib/common_functions/calendar_functions.py b/dsg_lib/common_functions/calendar_functions.py index a56c196d..b965f05e 100644 --- a/dsg_lib/common_functions/calendar_functions.py +++ b/dsg_lib/common_functions/calendar_functions.py @@ -52,7 +52,7 @@ """ # from loguru import logger # import logging as logger -from .. import LOGGER as logger +from .. import LOGGER as logger def get_month(month: int) -> str: diff --git a/dsg_lib/common_functions/email_validation.py b/dsg_lib/common_functions/email_validation.py index eec70760..29ca5301 100644 --- a/dsg_lib/common_functions/email_validation.py +++ b/dsg_lib/common_functions/email_validation.py @@ -36,9 +36,6 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger from enum import Enum from typing import Dict, List, Union @@ -49,6 +46,10 @@ validate_email, ) +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + class DNSType(Enum): """ diff --git a/dsg_lib/common_functions/file_functions.py b/dsg_lib/common_functions/file_functions.py index e4f98df9..183c8fba 100644 --- a/dsg_lib/common_functions/file_functions.py +++ b/dsg_lib/common_functions/file_functions.py @@ -40,15 +40,16 @@ # Import required modules import csv import json -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger import os import random from datetime import datetime from pathlib import Path from typing import List +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Set the path to the directory where the files are located directory_to_files: str = "data" diff --git a/dsg_lib/common_functions/folder_functions.py b/dsg_lib/common_functions/folder_functions.py index 27452369..768c32eb 100644 --- a/dsg_lib/common_functions/folder_functions.py +++ b/dsg_lib/common_functions/folder_functions.py @@ -37,14 +37,15 @@ License: MIT """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger import re from datetime import datetime from pathlib import Path from typing import List, Tuple +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Define the directory where the files are located directory_to__files: str = "data" file_directory = f"{directory_to__files}/csv" diff --git a/dsg_lib/common_functions/patterns.py b/dsg_lib/common_functions/patterns.py index b174466b..e9930360 100644 --- a/dsg_lib/common_functions/patterns.py +++ b/dsg_lib/common_functions/patterns.py @@ -38,10 +38,11 @@ License: MIT """ +import re + # from loguru import logger # import logging as logger -from .. import LOGGER as logger -import re +from .. import LOGGER as logger def pattern_between_two_char( diff --git a/dsg_lib/fastapi_functions/http_codes.py b/dsg_lib/fastapi_functions/http_codes.py index 63a82b12..1abc95f3 100644 --- a/dsg_lib/fastapi_functions/http_codes.py +++ b/dsg_lib/fastapi_functions/http_codes.py @@ -28,11 +28,11 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -# import logging as logger -from .. import LOGGER as logger from typing import Dict, List, Union +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from ._all_codes import ALL_HTTP_CODES # TODO: Create a way to extend the ALL_HTTP_CODES dictionary with custom codes. diff --git a/dsg_lib/fastapi_functions/system_health_endpoints.py b/dsg_lib/fastapi_functions/system_health_endpoints.py index d5c55eaf..f93b78df 100644 --- a/dsg_lib/fastapi_functions/system_health_endpoints.py +++ b/dsg_lib/fastapi_functions/system_health_endpoints.py @@ -68,12 +68,12 @@ License: MIT """ -# Importing database connector module -from loguru import logger # Import necessary modules import time import tracemalloc +# Importing database connector module +from loguru import logger from packaging import version as packaging_version from dsg_lib.fastapi_functions.http_codes import generate_code_dict diff --git a/examples/fastapi_example.py b/examples/fastapi_example.py index ae18c882..ef2b3b10 100644 --- a/examples/fastapi_example.py +++ b/examples/fastapi_example.py @@ -5,14 +5,13 @@ License: MIT """ import datetime -from loguru import logger - import secrets import time from contextlib import asynccontextmanager from fastapi import Body, FastAPI, Query from fastapi.responses import RedirectResponse +from loguru import logger from pydantic import BaseModel, EmailStr from sqlalchemy import Column, ForeignKey, Select, String from sqlalchemy.orm import relationship From f43a68a99f4a212570ad4b003e6b787ada1f1ad2 Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 21:10:54 +0000 Subject: [PATCH 5/6] bump to 0.14.3 --- .bumpversion.cfg | 2 +- dsg_lib/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ca7daa5a..ccca252b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.14.2 +current_version = 0.14.3 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[a-z]+)(?P\d+))? diff --git a/dsg_lib/__init__.py b/dsg_lib/__init__.py index 05a99cda..d55ea68f 100644 --- a/dsg_lib/__init__.py +++ b/dsg_lib/__init__.py @@ -8,7 +8,7 @@ """ from datetime import date -__version__ = "0.14.2" +__version__ = "0.14.3" __author__ = "Mike Ryan" __license__ = "MIT" __copyright__ = f"Copyright© 2021-{date.today().year}" diff --git a/pyproject.toml b/pyproject.toml index 8b972c66..a66b584f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "hatchling.build" [project] name = "devsetgo_lib" -version = "0.14.2" +version = "0.14.3" requires-python = ">=3.9" description = """ DevSetGo Library is a Python library offering reusable functions for efficient coding. It includes file operations, calendar utilities, pattern matching, advanced logging with loguru, FastAPI endpoints, async database handling, and email validation. Designed for ease of use and versatility, it's a valuable tool for Python developers. From 9af75a9a0dc1d87f6bee96556624e0301cdaade1 Mon Sep 17 00:00:00 2001 From: devsetgo Date: Sat, 31 Aug 2024 21:25:47 +0000 Subject: [PATCH 6/6] run of tests --- coverage.xml | 1108 +++++++++++++++++++++++++------------------------- 1 file changed, 554 insertions(+), 554 deletions(-) diff --git a/coverage.xml b/coverage.xml index c75cbea9..f6eb53cc 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,9 +1,9 @@ - + - /workspaces/devsetgo_lib + /github/workspace @@ -12,26 +12,26 @@ - - - + + + - + + - @@ -39,26 +39,26 @@ - + - - - + + + + - - - - - - - - - - - + + + + + + + + + + @@ -103,12 +103,12 @@ - + - - - + + + @@ -118,521 +118,521 @@ - - - + + + - - - - + + + + - + - + + - - + - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - + - + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -646,68 +646,68 @@ - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + @@ -719,16 +719,16 @@ - + - - + + - - + + @@ -744,12 +744,12 @@ - + - - + + @@ -766,33 +766,33 @@ - - + + - - - - - - + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + +