ecodev-core 0.0.3__tar.gz → 0.0.4__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 (24) hide show
  1. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/LICENSE.md +1 -1
  2. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/PKG-INFO +5 -1
  3. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/README.md +4 -0
  4. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/__init__.py +2 -2
  5. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/authentication.py +10 -0
  6. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/db_insertion.py +1 -1
  7. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/pyproject.toml +1 -1
  8. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/app_activity.py +0 -0
  9. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/app_rights.py +0 -0
  10. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/app_user.py +0 -0
  11. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/auth_configuration.py +0 -0
  12. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/check_dependencies.py +0 -0
  13. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/custom_equal.py +0 -0
  14. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/db_connection.py +0 -0
  15. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/db_filters.py +0 -0
  16. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/db_retrieval.py +0 -0
  17. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/enum_utils.py +0 -0
  18. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/list_utils.py +0 -0
  19. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/logger.py +0 -0
  20. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/pandas_utils.py +0 -0
  21. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/permissions.py +0 -0
  22. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/pydantic_utils.py +0 -0
  23. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/read_write.py +0 -0
  24. {ecodev_core-0.0.3 → ecodev_core-0.0.4}/ecodev_core/safe_utils.py +0 -0
@@ -1,4 +1,4 @@
1
- Copyright 2024 Thomas EPELBAUM
1
+ Copyright 2024 Thomas EPELBAUM for EcoAct
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction,
4
4
  including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ecodev-core
3
- Version: 0.0.3
3
+ Version: 0.0.4
4
4
  Summary: Low level sqlmodel/fastapi/pydantic building blocks
5
5
  License: MIT
6
6
  Author: Thomas Epelbaum
@@ -71,3 +71,7 @@ Starting from a project with a Docker file:
71
71
  * build the new version of the Docker container (typically `docker build --tag xxx .`)
72
72
  * run it with docker compose (`dc up -d`).
73
73
 
74
+ ## Documentation
75
+
76
+ Please find it in the [associated mkdoc website!](https://ecodev-doc.lcabox.com/)
77
+
@@ -23,3 +23,7 @@ Starting from a project with a Docker file:
23
23
  * make sure the `.env` file includes all required fields (see `BaseSettings` and `AuthenticationConfiguration`)
24
24
  * build the new version of the Docker container (typically `docker build --tag xxx .`)
25
25
  * run it with docker compose (`dc up -d`).
26
+
27
+ ## Documentation
28
+
29
+ Please find it in the [associated mkdoc website!](https://ecodev-doc.lcabox.com/)
@@ -20,6 +20,7 @@ from ecodev_core.authentication import is_admin_user
20
20
  from ecodev_core.authentication import is_authorized_user
21
21
  from ecodev_core.authentication import is_monitoring_user
22
22
  from ecodev_core.authentication import JwtAuth
23
+ from ecodev_core.authentication import safe_get_user
23
24
  from ecodev_core.authentication import SCHEME
24
25
  from ecodev_core.authentication import Token
25
26
  from ecodev_core.check_dependencies import check_dependencies
@@ -75,5 +76,4 @@ __all__ = [
75
76
  'enum_converter', 'ServerSideFilter', 'get_rows', 'count_rows', 'ServerSideField', 'get_raw_df',
76
77
  'generic_insertion', 'custom_equal', 'is_authorized_user', 'get_method', 'AppActivity',
77
78
  'fastapi_monitor', 'dash_monitor', 'is_monitoring_user', 'get_recent_activities', 'select_user',
78
- 'get_access_token'
79
- ]
79
+ 'get_access_token', 'safe_get_user']
@@ -148,6 +148,16 @@ def is_authorized_user(token: str = Depends(SCHEME)) -> bool:
148
148
  return False
149
149
 
150
150
 
151
+ def safe_get_user(token: Dict) -> Union[AppUser, None]:
152
+ """
153
+ Safe method returning a user if one found given the passed token
154
+ """
155
+ try:
156
+ return get_user(get_access_token(token))
157
+ except (HTTPException, AttributeError):
158
+ return None
159
+
160
+
151
161
  def get_user(token: str = Depends(SCHEME)) -> AppUser:
152
162
  """
153
163
  Retrieves (if it exists) the db user corresponding to the passed token
@@ -37,7 +37,7 @@ class Insertor(CustomFrozen):
37
37
  - selector: the criteria on which to decide whether to create or update (example: only add
38
38
  a user if a user with the same name is not already present in the db)
39
39
  - convertor: how to convert the raw csv/excel passed by the user to json like db rows
40
- - whether to insert data based on an xlsx (if true) or a csv (if false)
40
+ - read_excel_file: whether to insert data based on an xlsx (if true) or a csv (if false)
41
41
  """
42
42
  reductor: Callable[[Any, Any], Any]
43
43
  db_schema: Callable
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ecodev-core"
3
- version = "0.0.3"
3
+ version = "0.0.4"
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>",