tracktolib 0.46.1__py3-none-any.whl → 0.46.2__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.
tracktolib/api.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import json
2
- import os
3
2
  import warnings
4
3
  from dataclasses import field, dataclass
5
4
  from inspect import getdoc
@@ -24,7 +23,6 @@ from .utils import json_serial
24
23
 
25
24
  try:
26
25
  from fastapi import params, APIRouter
27
- from fastapi.routing import APIRoute
28
26
  from fastapi.responses import JSONResponse
29
27
  from pydantic.alias_generators import to_camel
30
28
  from pydantic import BaseModel, ConfigDict
@@ -204,58 +202,6 @@ def _get_method_wrapper(
204
202
  _NoneType = type(None)
205
203
 
206
204
 
207
- class IgnoreConfig(BaseModel):
208
- endpoints: dict[str, dict[Method, bool]]
209
- ignore_missing: bool = True
210
-
211
-
212
- def get_ignore_config() -> IgnoreConfig | None:
213
- _config = os.getenv("IGNORE_CONFIG")
214
- return IgnoreConfig.model_validate_json(_config) if _config else None
215
-
216
-
217
- def set_ignore_config(config: str | IgnoreConfig):
218
- if isinstance(config, str):
219
- config = IgnoreConfig.model_validate_json(config)
220
- os.environ["IGNORE_CONFIG"] = config.model_dump_json()
221
-
222
-
223
- def _filter_route(route: APIRoute, ignored_route: dict[Method, bool], ignore_missing: bool) -> APIRoute | None:
224
- # If no config is provided and default is to ignore missing, return the route
225
- if ignored_route is None and not ignore_missing:
226
- return route
227
-
228
- has_methods = False
229
- enabled_methods = {method for method, has_access in ignored_route.items() if has_access}
230
- for method in list(route.methods):
231
- # If the config is not specified, we remove the method if ignore_missing is True
232
- if method not in ignored_route:
233
- if ignore_missing:
234
- route.methods -= {method}
235
- continue
236
- else:
237
- has_methods = True
238
- continue
239
- elif method not in enabled_methods:
240
- route.methods -= {method}
241
- else:
242
- has_methods = True
243
-
244
- if not has_methods:
245
- return None
246
- return route
247
-
248
-
249
- def filter_routes(routes: list[APIRoute], ignore_config: IgnoreConfig) -> list[APIRoute]:
250
- _routes = []
251
- for route in routes:
252
- _ignored_route = ignore_config.endpoints.get(route.path)
253
- _route = _filter_route(route, _ignored_route or {}, ignore_missing=ignore_config.ignore_missing)
254
- if _route is not None:
255
- _routes.append(_route)
256
- return _routes
257
-
258
-
259
205
  def _get_return_type(fn):
260
206
  return_type = get_type_hints(fn)["return"]
261
207
  _args = get_args(return_type)
@@ -271,7 +217,6 @@ def add_endpoint(
271
217
  *,
272
218
  dependencies: Dependencies = None,
273
219
  ):
274
- _ignore_config = get_ignore_config()
275
220
  for _method, _meta in endpoint.methods.items():
276
221
  _fn = _meta["fn"]
277
222
  _status_code = _meta["status_code"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tracktolib
3
- Version: 0.46.1
3
+ Version: 0.46.2
4
4
  Summary: Utility library for python
5
5
  Home-page: https://github.com/tracktor/tracktolib
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
2
2
  tracktolib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- tracktolib/api.py,sha256=DILKtPQn6HRXmQk5FgYHA9o5ToSNGudHsMEF_ZXEuI8,9826
3
+ tracktolib/api.py,sha256=nIS1P0woUwrDNzyPVw5a3dt5GpImps5WZ1HFegHkj2g,7947
4
4
  tracktolib/http_utils.py,sha256=dqjRJTNCo1qDnvQBTcImw1ibi1LnqETrpWDAU5txBHs,2633
5
5
  tracktolib/logs.py,sha256=enezPjBU4v2s8knG_V6kIbQsoyxfNIKEpKVSSkr_2U8,2212
6
6
  tracktolib/pg/__init__.py,sha256=32kKBJzIDyppszZMAOSMgM3ggz7Ow0TaNKiMs740gyw,333
@@ -13,7 +13,7 @@ tracktolib/s3/minio.py,sha256=JaRpHOM6NqpMieplp58Fpc7uTh7PItyP8On7jMXhB-Q,1234
13
13
  tracktolib/s3/s3.py,sha256=0aPUo3Vnfy5Rk_Qp_y0KkCZa2kuMWw2JU2xrodn7oAE,3486
14
14
  tracktolib/tests.py,sha256=FS0uae3ShiiJOD7WE2WEv9h3QwRJCbLDHpe_8Ikc0j0,554
15
15
  tracktolib/utils.py,sha256=YZZROGgOioblJkqgneHGZRbof45nmZ-VLSk9LqcVkkE,4847
16
- tracktolib-0.46.1.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
17
- tracktolib-0.46.1.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
18
- tracktolib-0.46.1.dist-info/METADATA,sha256=wi_XoRBTxEhgO2DvDPf1h_cf4XL8mcd0JP4i76_lHu0,3610
19
- tracktolib-0.46.1.dist-info/RECORD,,
16
+ tracktolib-0.46.2.dist-info/LICENSE,sha256=uUanH0X7SeZEPdsRTHegMSMTiIHMurt9H0jSwEwKE1Y,1081
17
+ tracktolib-0.46.2.dist-info/WHEEL,sha256=vxFmldFsRN_Hx10GDvsdv1wroKq8r5Lzvjp6GZ4OO8c,88
18
+ tracktolib-0.46.2.dist-info/METADATA,sha256=llhCmztMMABZ10LT9TtpR72HsPn0dKGV5-MvXbaPo6k,3610
19
+ tracktolib-0.46.2.dist-info/RECORD,,