nlbone 0.8.1__py3-none-any.whl → 0.8.3__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.
@@ -14,6 +14,7 @@ def assemble_response(
14
14
  session,
15
15
  base_schema: type[BaseModel] | None,
16
16
  scope_map: dict[str, set[str]] = None,
17
+ **kwargs,
17
18
  ) -> Dict[str, Any]:
18
19
  base = {f: getattr(obj, f, None) for f in reg.default_fields - set(reg.rules.keys())}
19
20
  if base_schema:
@@ -24,6 +25,7 @@ def assemble_response(
24
25
  "entity": obj,
25
26
  "db": session,
26
27
  "pricing_service": Container.pricing_service(),
28
+ **kwargs,
27
29
  }
28
30
  roots = {name.split(".", 1)[0] for name in selected_rules.keys()}
29
31
  for root in roots:
nlbone/utils/http.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import json
4
4
  from typing import Any
5
- from urllib.parse import urlparse, urlunparse, urlsplit, urlunsplit
5
+ from urllib.parse import urlparse, urlunparse
6
6
 
7
7
  from nlbone.utils.context import current_request
8
8
 
@@ -32,14 +32,6 @@ def normalize_https_base(url: str, enforce_https: bool = True) -> str:
32
32
 
33
33
 
34
34
  def get_service_base_url() -> str:
35
- req = current_request()
36
-
37
- base_url = req.base_url
38
- if isinstance(base_url, (bytes, bytearray)):
39
- base_url = base_url.decode("utf-8", "strict")
40
-
41
- forwarded_proto = (req.headers.get("x-forwarded-proto") or "").split(",")[0].strip().lower()
42
- scheme = forwarded_proto if forwarded_proto in {"http", "https"} else urlsplit(base_url).scheme or "http"
43
-
44
- parts = urlsplit(base_url)
45
- return urlunsplit((scheme, parts.netloc, parts.path, "", ""))
35
+ req = current_request() # Starlette Request
36
+ url = req.base_url # URL object
37
+ return str(url.replace(scheme="https"))
@@ -0,0 +1,13 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+
5
+ def load_json_file(file_path: str) -> dict:
6
+ path = Path(file_path)
7
+
8
+ if not path.exists():
9
+ raise FileNotFoundError(f"No file found at {file_path}")
10
+
11
+ with path.open(mode='r', encoding='utf-8') as file:
12
+ return json.load(file)
13
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nlbone
3
- Version: 0.8.1
3
+ Version: 0.8.3
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
@@ -75,7 +75,7 @@ nlbone/interfaces/api/exceptions.py,sha256=IggZxV9q6l4jqw-G7SWEmuyXnWgbNXJJT-rmn
75
75
  nlbone/interfaces/api/routers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  nlbone/interfaces/api/schemas.py,sha256=34Tz2EeXyf12rFL9iyYWaB2ftuaXUebQQQxSO9ouV94,133
77
77
  nlbone/interfaces/api/additional_filed/__init__.py,sha256=BWemliLSQV9iq1vdUaF733q0FOSipSWBOQk9eYj732Q,318
78
- nlbone/interfaces/api/additional_filed/assembler.py,sha256=80sFuNiquqdLPOcx7MoQ_ud9fAJtA327M77Z9V47pIU,1956
78
+ nlbone/interfaces/api/additional_filed/assembler.py,sha256=E_TGxorIQ-hC5FiCup5WQ0MmbSGfNaypEf5Plc-rjJs,1988
79
79
  nlbone/interfaces/api/additional_filed/field_registry.py,sha256=IhIvzHWOMtKv8iTdFu7LzQboi4SFTLOyJqKdYPY8xFE,5418
80
80
  nlbone/interfaces/api/additional_filed/resolver.py,sha256=jv1TIBBHN4LBIMwHGipcy4iq0uP0r6udyaqvhRzb8Bk,4655
81
81
  nlbone/interfaces/api/additional_filed/default_field_rules/__init__.py,sha256=LUSAOO3xRUt5ptlraIx7H-7dSkdr1D-WprmnqXRB16g,48
@@ -111,12 +111,13 @@ nlbone/utils/context.py,sha256=Wq3QLYsMzo_xUiVAHLgEPQUG6LhgJTmFn8MO5Qa7S8w,1837
111
111
  nlbone/utils/crypto.py,sha256=PX0Tlf2nqXcGbuv16J26MoUPzo2c4xcD4sZBXxhBXgQ,746
112
112
  nlbone/utils/flatten_dict.py,sha256=nkx8gAcJkjCKG3I5y9clqtjGMZCWyUWRhgD2R8zGEqM,299
113
113
  nlbone/utils/flatten_sqlalchemy_result.py,sha256=JGwQEauoJVjhzvXrOtqabj3wQ7zp2-OPwhuh44sUdUE,625
114
- nlbone/utils/http.py,sha256=Jr15AqXUZKcVfN7-_4SbIGXHr6RWb5TkDHChgCOTxMY,1451
114
+ nlbone/utils/http.py,sha256=llb4aPDL-Uvrht3c_VwJdngdKeT4WsCu1pXSoeI7vWA,1114
115
115
  nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYkS_E,732
116
+ nlbone/utils/read_files.py,sha256=mx8dfvtaaARQFRp_U7OOiERg-GT62h09_lpTzIQsVhs,291
116
117
  nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
117
118
  nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
118
- nlbone-0.8.1.dist-info/METADATA,sha256=usSyN8iAxBHjnqy16NmMevqKcKHc8G5bVLgyHtGzPx0,2294
119
- nlbone-0.8.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
120
- nlbone-0.8.1.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
121
- nlbone-0.8.1.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
- nlbone-0.8.1.dist-info/RECORD,,
119
+ nlbone-0.8.3.dist-info/METADATA,sha256=b7l7LGRljEWHWYG8N-qglOOfhmjfsOQfoJOpAA6_Og8,2294
120
+ nlbone-0.8.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
121
+ nlbone-0.8.3.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
122
+ nlbone-0.8.3.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
+ nlbone-0.8.3.dist-info/RECORD,,
File without changes