python-general-be-lib 0.1.0__tar.gz → 0.3.0__tar.gz
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.
- {python_general_be_lib-0.1.0/python_general_be_lib.egg-info → python_general_be_lib-0.3.0}/PKG-INFO +1 -1
- python_general_be_lib-0.3.0/general/interface/repository/handler/__init__.py +4 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/handler/base_handler.py +1 -1
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/handler/interval_handler.py +2 -0
- python_general_be_lib-0.3.0/general/interface/repository/handler/json_handler.py +25 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/many_to_many_repository.py +1 -1
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/logger.py +23 -1
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/pyproject.toml +1 -4
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0/python_general_be_lib.egg-info}/PKG-INFO +1 -1
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/python_general_be_lib.egg-info/SOURCES.txt +1 -1
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/setup.py +2 -3
- python_general_be_lib-0.1.0/general/interface/repository/handler/__init__.py +0 -2
- python_general_be_lib-0.1.0/general/log_config.ini +0 -21
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/LICENSE +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/README.md +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/__init__.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/__init__.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/access_exceptions.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/crud_exceptions.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/exception_interface.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/base/__init__.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/base/base_model.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/base/declarative_base.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/metadata/__init__.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/metadata/crud_metadata.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/metadata/geom_metadata.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/__init__.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/crud_repository.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/geometry_repository.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/handler/ilike_handler.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/view_repository.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/paginator_dto.py +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/python_general_be_lib.egg-info/dependency_links.txt +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/python_general_be_lib.egg-info/requires.txt +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/python_general_be_lib.egg-info/top_level.txt +0 -0
- {python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/setup.cfg +0 -0
{python_general_be_lib-0.1.0/python_general_be_lib.egg-info → python_general_be_lib-0.3.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-general-be-lib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities.
|
|
5
5
|
Author-email: Andrea Di Placido <a.diplacido@arpes.it>, "Arpes S.r.l." <it.admin@arpes.it>
|
|
6
6
|
License: MIT
|
|
@@ -5,7 +5,7 @@ from typing import Any
|
|
|
5
5
|
from sqlalchemy import Select, Update, Delete, Column, not_
|
|
6
6
|
from sqlalchemy.sql.base import ReadOnlyColumnCollection
|
|
7
7
|
|
|
8
|
-
from
|
|
8
|
+
from general.exception.crud_exceptions import HasNoAttributeException
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class BaseHandler:
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
__all__ = ["JsonHandler"]
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from sqlalchemy import Column, Select, Update, Delete
|
|
6
|
+
from sqlalchemy.sql.base import ReadOnlyColumnCollection
|
|
7
|
+
|
|
8
|
+
from .base_handler import BaseHandler
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class JsonHandler(BaseHandler):
|
|
12
|
+
__slots__ = "json_column"
|
|
13
|
+
json_column: str
|
|
14
|
+
|
|
15
|
+
def __init__(self, columns: ReadOnlyColumnCollection[str, Column[Any]]):
|
|
16
|
+
self.columns = columns
|
|
17
|
+
self.json_column = {key for key, column in columns.items() if column.type.python_type == dict}.pop()
|
|
18
|
+
|
|
19
|
+
def prepare_statement(self, stmt: Select | Update | Delete, **where):
|
|
20
|
+
json_keys = {key for key in where.keys() if key not in self.columns}
|
|
21
|
+
json_conditions = {key: where.pop(key) for key in json_keys}
|
|
22
|
+
|
|
23
|
+
stmt = super().prepare_statement(stmt=stmt, **where)
|
|
24
|
+
stmt = stmt.where(*[self.columns[self.json_column][key].as_string() == str(value) for key, value in json_conditions.items()])
|
|
25
|
+
return stmt
|
|
@@ -6,7 +6,7 @@ from pydantic import BaseModel
|
|
|
6
6
|
from sqlalchemy.orm import Session
|
|
7
7
|
|
|
8
8
|
from .crud_repository import CrudRepository
|
|
9
|
-
from
|
|
9
|
+
from ..base import Base
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class ManyToManyRepository[Entity: Base | Type[Base]](CrudRepository[Entity]):
|
|
@@ -21,6 +21,28 @@ color = COLOR['BLUE']
|
|
|
21
21
|
end_color = COLOR['ENDC']
|
|
22
22
|
exc_color = COLOR['RED']
|
|
23
23
|
|
|
24
|
+
LOGGING_CONFIG = {
|
|
25
|
+
"version": 1,
|
|
26
|
+
"disable_existing_loggers": False,
|
|
27
|
+
"formatters": {
|
|
28
|
+
"logformatter": {
|
|
29
|
+
"format": "[%(asctime)s] %(levelname)s - %(message)s"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"handlers": {
|
|
33
|
+
"logconsole": {
|
|
34
|
+
"class": "logging.StreamHandler",
|
|
35
|
+
"level": "INFO",
|
|
36
|
+
"formatter": "logformatter",
|
|
37
|
+
"stream": "ext://sys.stderr"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"root": {
|
|
41
|
+
"level": "INFO",
|
|
42
|
+
"handlers": ["logconsole"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
|
|
25
47
|
class EndpointFilter(logging.Filter):
|
|
26
48
|
def __init__(self, endpoint: str = '', *args, **kwargs):
|
|
@@ -32,7 +54,7 @@ class EndpointFilter(logging.Filter):
|
|
|
32
54
|
|
|
33
55
|
|
|
34
56
|
def init_logger(*filtering_endpoints: str):
|
|
35
|
-
logging.config.
|
|
57
|
+
logging.config.dictConfig(LOGGING_CONFIG)
|
|
36
58
|
logging.info("Logger setted up")
|
|
37
59
|
[logging.getLogger("uvicorn.access").addFilter(EndpointFilter(filtering_endpoint)) for filtering_endpoint in filtering_endpoints]
|
|
38
60
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends.legacy:build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-general-be-lib"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -47,8 +47,5 @@ Repository = "https://github.com/Arpes-IS/python-general-be-lib"
|
|
|
47
47
|
where = ["."]
|
|
48
48
|
include = ["general*"]
|
|
49
49
|
|
|
50
|
-
[tool.setuptools.package-data]
|
|
51
|
-
general = ["log_config.ini"]
|
|
52
|
-
|
|
53
50
|
[tool.pytest.ini_options]
|
|
54
51
|
testpaths = ["tests"]
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0/python_general_be_lib.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-general-be-lib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: General purpose backend library — SQLAlchemy CRUD/Geometry repositories, FastAPI exceptions, Pydantic base models, logger utilities.
|
|
5
5
|
Author-email: Andrea Di Placido <a.diplacido@arpes.it>, "Arpes S.r.l." <it.admin@arpes.it>
|
|
6
6
|
License: MIT
|
|
@@ -3,7 +3,6 @@ README.md
|
|
|
3
3
|
pyproject.toml
|
|
4
4
|
setup.py
|
|
5
5
|
general/__init__.py
|
|
6
|
-
general/log_config.ini
|
|
7
6
|
general/logger.py
|
|
8
7
|
general/paginator_dto.py
|
|
9
8
|
general/exception/__init__.py
|
|
@@ -25,6 +24,7 @@ general/interface/repository/handler/__init__.py
|
|
|
25
24
|
general/interface/repository/handler/base_handler.py
|
|
26
25
|
general/interface/repository/handler/ilike_handler.py
|
|
27
26
|
general/interface/repository/handler/interval_handler.py
|
|
27
|
+
general/interface/repository/handler/json_handler.py
|
|
28
28
|
python_general_be_lib.egg-info/PKG-INFO
|
|
29
29
|
python_general_be_lib.egg-info/SOURCES.txt
|
|
30
30
|
python_general_be_lib.egg-info/dependency_links.txt
|
|
@@ -2,9 +2,8 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="python-general-be-lib",
|
|
5
|
-
version="0.
|
|
5
|
+
version="0.3.0",
|
|
6
6
|
packages=find_packages(include=["general*"]),
|
|
7
|
-
package_data={"general": ["log_config.ini"]},
|
|
8
7
|
python_requires=">=3.12",
|
|
9
8
|
install_requires=[
|
|
10
9
|
"fastapi>=0.100.0",
|
|
@@ -12,4 +11,4 @@ setup(
|
|
|
12
11
|
"sqlalchemy>=2.0.0",
|
|
13
12
|
"geoalchemy2>=0.14.0",
|
|
14
13
|
],
|
|
15
|
-
)
|
|
14
|
+
)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
[loggers]
|
|
2
|
-
keys = root
|
|
3
|
-
|
|
4
|
-
[handlers]
|
|
5
|
-
keys = logconsole
|
|
6
|
-
|
|
7
|
-
[formatters]
|
|
8
|
-
keys = logformatter
|
|
9
|
-
|
|
10
|
-
[logger_root]
|
|
11
|
-
level = INFO
|
|
12
|
-
handlers = logconsole
|
|
13
|
-
|
|
14
|
-
[formatter_logformatter]
|
|
15
|
-
format = [%(asctime)s] %(levelname)s - %(message)s
|
|
16
|
-
|
|
17
|
-
[handler_logconsole]
|
|
18
|
-
class = handlers.logging.StreamHandler
|
|
19
|
-
level = INFO
|
|
20
|
-
args = ()
|
|
21
|
-
formatter = logformatter
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/access_exceptions.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/crud_exceptions.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/exception/exception_interface.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/base/__init__.py
RENAMED
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/base/base_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/metadata/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_general_be_lib-0.1.0 → python_general_be_lib-0.3.0}/general/interface/repository/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|