nlbone 0.1.25__py3-none-any.whl → 0.1.27__py3-none-any.whl

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.
nlbone/config/settings.py CHANGED
@@ -1,10 +1,27 @@
1
+ import os
1
2
  from functools import lru_cache
3
+ from pathlib import Path
2
4
  from typing import Literal
3
-
4
5
  from pydantic import AnyHttpUrl, Field, SecretStr
5
6
  from pydantic_settings import BaseSettings, SettingsConfigDict
6
7
 
7
8
 
9
+ def _guess_env_file() -> str | None:
10
+ explicit = os.getenv("NLBONE_ENV_FILE")
11
+ if explicit:
12
+ return explicit
13
+
14
+ cwd_env = Path.cwd() / ".env"
15
+ if cwd_env.exists():
16
+ return str(cwd_env)
17
+
18
+ for i in range(1, 8):
19
+ p = Path(__file__).resolve().parents[i]
20
+ f = p / ".env"
21
+ if f.exists():
22
+ return str(f)
23
+
24
+
8
25
  class Settings(BaseSettings):
9
26
  # ---------------------------
10
27
  # App
@@ -39,18 +56,19 @@ class Settings(BaseSettings):
39
56
 
40
57
  model_config = SettingsConfigDict(
41
58
  env_prefix="NLBONE_",
42
- env_file=".env",
59
+ env_file=None,
43
60
  env_file_encoding="utf-8",
44
61
  extra="ignore",
45
62
  )
46
63
 
47
64
 
48
- @lru_cache(maxsize=1)
49
- def get_settings() -> Settings:
65
+ @lru_cache(maxsize=4)
66
+ def get_settings(env_file: str | None = None) -> Settings:
50
67
  """
51
68
  Cached settings for fast access across the app.
52
69
  Usage:
53
70
  from nlbone.config.settings import get_settings
54
71
  settings = get_settings()
55
72
  """
73
+ env_file = env_file or _guess_env_file()
56
74
  return Settings()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nlbone
3
- Version: 0.1.25
3
+ Version: 0.1.27
4
4
  Summary: Backbone package for interfaces and infrastructure in Python projects
5
5
  Author-email: Amir Hosein Kahkbazzadeh <a.khakbazzadeh@gmail.com>
6
6
  License: MIT
@@ -9,6 +9,7 @@ Requires-Python: >=3.10
9
9
  Requires-Dist: anyio>=4.0
10
10
  Requires-Dist: fastapi>=0.116
11
11
  Requires-Dist: httpx>=0.27
12
+ Requires-Dist: psycopg>=3.2.9
12
13
  Requires-Dist: pydantic-settings>=2.0
13
14
  Requires-Dist: pydantic>=2.0
14
15
  Requires-Dist: python-keycloak==5.8.1
@@ -21,7 +21,7 @@ nlbone/adapters/messaging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
21
21
  nlbone/adapters/messaging/redis.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  nlbone/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  nlbone/config/logging.py,sha256=68WRQejEpL6eHEY_cOgdlOjndKc-RWth0n4YmXnceC8,5041
24
- nlbone/config/settings.py,sha256=f9zIRsWce8v8ZFI0dd4vBY9O-Oo7TKEBDT4wOA8bKcs,1791
24
+ nlbone/config/settings.py,sha256=odRZiSyc-cYpFatgYc2pIIcjYDnw-8gJoEdRvM4Gk48,2254
25
25
  nlbone/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  nlbone/core/{__init__.py},sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  nlbone/core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -51,7 +51,7 @@ nlbone/interfaces/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
51
51
  nlbone/interfaces/jobs/sync_tokens.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  nlbone/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
53
  nlbone/utils/time.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
- nlbone-0.1.25.dist-info/METADATA,sha256=44eO-O3dnoQOQ5kTu45_2gXBjAI2iBL89STpa2HRbS8,2226
55
- nlbone-0.1.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- nlbone-0.1.25.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
- nlbone-0.1.25.dist-info/RECORD,,
54
+ nlbone-0.1.27.dist-info/METADATA,sha256=Puv-PkGfGKVmy6zme0a3WEk23m8-ZtUi9uJcmKDhMM0,2256
55
+ nlbone-0.1.27.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ nlbone-0.1.27.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
+ nlbone-0.1.27.dist-info/RECORD,,