ecodev-core 0.0.26__tar.gz → 0.0.28__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.

Potentially problematic release.


This version of ecodev-core might be problematic. Click here for more details.

Files changed (26) hide show
  1. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/PKG-INFO +1 -1
  2. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/__init__.py +2 -1
  3. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/auth_configuration.py +3 -3
  4. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/db_connection.py +5 -5
  5. ecodev_core-0.0.28/ecodev_core/email_sender.py +53 -0
  6. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/pyproject.toml +1 -1
  7. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/LICENSE.md +0 -0
  8. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/README.md +0 -0
  9. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/app_activity.py +0 -0
  10. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/app_rights.py +0 -0
  11. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/app_user.py +0 -0
  12. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/authentication.py +0 -0
  13. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/backup.py +0 -0
  14. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/check_dependencies.py +0 -0
  15. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/custom_equal.py +0 -0
  16. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/db_filters.py +0 -0
  17. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/db_insertion.py +0 -0
  18. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/db_retrieval.py +0 -0
  19. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/enum_utils.py +0 -0
  20. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/list_utils.py +0 -0
  21. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/logger.py +0 -0
  22. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/pandas_utils.py +0 -0
  23. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/permissions.py +0 -0
  24. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/pydantic_utils.py +0 -0
  25. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/read_write.py +0 -0
  26. {ecodev_core-0.0.26 → ecodev_core-0.0.28}/ecodev_core/safe_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ecodev-core
3
- Version: 0.0.26
3
+ Version: 0.0.28
4
4
  Summary: Low level sqlmodel/fastapi/pydantic building blocks
5
5
  License: MIT
6
6
  Author: Thomas Epelbaum
@@ -40,6 +40,7 @@ from ecodev_core.db_insertion import get_raw_df
40
40
  from ecodev_core.db_retrieval import count_rows
41
41
  from ecodev_core.db_retrieval import get_rows
42
42
  from ecodev_core.db_retrieval import ServerSideField
43
+ from ecodev_core.email_sender import send_email
43
44
  from ecodev_core.enum_utils import enum_converter
44
45
  from ecodev_core.list_utils import first_or_default
45
46
  from ecodev_core.list_utils import first_transformed_or_default
@@ -84,4 +85,4 @@ __all__ = [
84
85
  'generic_insertion', 'custom_equal', 'is_authorized_user', 'get_method', 'AppActivity',
85
86
  'fastapi_monitor', 'dash_monitor', 'is_monitoring_user', 'get_recent_activities', 'select_user',
86
87
  'get_access_token', 'safe_get_user', 'backup', 'group_by', 'get_excelfile', 'upsert_new_user',
87
- 'datify', 'safe_drop_columns', 'get_value', 'is_null']
88
+ 'datify', 'safe_drop_columns', 'get_value', 'is_null', 'send_email']
@@ -9,9 +9,9 @@ class AuthenticationConfiguration(BaseSettings):
9
9
  """
10
10
  Simple authentication configuration class
11
11
  """
12
- secret_key: str
13
- algorithm: str
14
- access_token_expire_minutes: int
12
+ secret_key: str = ''
13
+ algorithm: str = ''
14
+ access_token_expire_minutes: int = 0
15
15
  model_config = SettingsConfigDict(env_file='.env')
16
16
 
17
17
 
@@ -20,11 +20,11 @@ class DbSettings(BaseSettings):
20
20
  """
21
21
  Settings class used to connect to the postgresql database
22
22
  """
23
- db_host: str
24
- db_port: str
25
- db_name: str
26
- db_username: str
27
- db_password: str
23
+ db_host: str = ''
24
+ db_port: str = ''
25
+ db_name: str = ''
26
+ db_username: str = ''
27
+ db_password: str = ''
28
28
  model_config = SettingsConfigDict(env_file='.env')
29
29
 
30
30
 
@@ -0,0 +1,53 @@
1
+ """
2
+ Module implementing generic email send
3
+ """
4
+ from email.mime.image import MIMEImage
5
+ from email.mime.multipart import MIMEMultipart
6
+ from email.mime.text import MIMEText
7
+ from pathlib import Path
8
+ from smtplib import SMTP
9
+ from ssl import create_default_context
10
+
11
+ from pydantic_settings import BaseSettings
12
+ from pydantic_settings import SettingsConfigDict
13
+
14
+
15
+ class EmailAuth(BaseSettings):
16
+ """
17
+ Simple authentication configuration class
18
+ """
19
+ email_smtp: str = ''
20
+ email_sender: str = ''
21
+ email_password: str = ''
22
+ model_config = SettingsConfigDict(env_file='.env')
23
+
24
+
25
+ EMAIL_AUTH = EmailAuth()
26
+
27
+
28
+ def send_email(email: str, body: str, topic: str, images: dict[str, Path] | None = None) -> None:
29
+ """
30
+ Generic email sender.
31
+
32
+ Attributes are:
33
+ - email: The email to which to send
34
+ - body: the email body
35
+ - topic: the email topic
36
+ - images: if any, the Dict of image tags:image paths to incorporate in the email
37
+ """
38
+ em = MIMEMultipart('related')
39
+ em['From'] = EMAIL_AUTH.email_sender
40
+ em['To'] = email
41
+ em['Subject'] = topic
42
+ em.attach(MIMEText(body, 'html'))
43
+ for tag, img_path in (images or {}).items():
44
+ with open(img_path, 'rb') as fp:
45
+ img = MIMEImage(fp.read())
46
+ img.add_header('Content-ID', f'<{tag}>')
47
+ em.attach(img)
48
+
49
+ with SMTP(EMAIL_AUTH.email_smtp, 587) as server:
50
+ server.ehlo()
51
+ server.starttls(context=create_default_context())
52
+ server.login(EMAIL_AUTH.email_sender, EMAIL_AUTH.email_password)
53
+ server.sendmail(EMAIL_AUTH.email_sender, email, em.as_string())
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ecodev-core"
3
- version = "0.0.26"
3
+ version = "0.0.28"
4
4
  description = "Low level sqlmodel/fastapi/pydantic building blocks"
5
5
  authors = ["Thomas Epelbaum <tomepel@gmail.com>",
6
6
  "Olivier Gabriel <olivier.gabriel.geom@gmail.com>",
File without changes
File without changes