panther 4.2.2__py3-none-any.whl → 4.2.4__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.
- panther/__init__.py +1 -1
- panther/cli/utils.py +1 -1
- panther/db/connections.py +1 -1
- panther/db/queries/queries.py +20 -0
- panther/db/utils.py +1 -1
- panther/logging.py +0 -5
- panther/utils.py +14 -0
- panther/websocket.py +6 -0
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/METADATA +10 -10
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/RECORD +14 -14
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/WHEEL +1 -1
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/LICENSE +0 -0
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/entry_points.txt +0 -0
- {panther-4.2.2.dist-info → panther-4.2.4.dist-info}/top_level.txt +0 -0
panther/__init__.py
CHANGED
panther/cli/utils.py
CHANGED
@@ -142,7 +142,7 @@ def print_info(config: Config):
|
|
142
142
|
if config.HAS_WS:
|
143
143
|
try:
|
144
144
|
import gunicorn
|
145
|
-
gunicorn_msg = f'{h} * You have WS so make sure to run gunicorn with --preload{h}\n'
|
145
|
+
gunicorn_msg = f'{h} * You have WS, so make sure to run gunicorn with --preload{h}\n'
|
146
146
|
except ImportError:
|
147
147
|
pass
|
148
148
|
|
panther/db/connections.py
CHANGED
@@ -75,7 +75,7 @@ class MongoDBConnection(BaseDatabaseConnection):
|
|
75
75
|
|
76
76
|
class PantherDBConnection(BaseDatabaseConnection):
|
77
77
|
def init(self, path: str | None = None, encryption: bool = False):
|
78
|
-
params = {'db_name':
|
78
|
+
params = {'db_name': path, 'return_dict': True, 'return_cursor': True}
|
79
79
|
if encryption:
|
80
80
|
try:
|
81
81
|
import cryptography
|
panther/db/queries/queries.py
CHANGED
@@ -364,6 +364,26 @@ class Query(BaseQuery):
|
|
364
364
|
|
365
365
|
raise NotFoundAPIError(detail=f'{cls.__name__} Does Not Exist')
|
366
366
|
|
367
|
+
@classmethod
|
368
|
+
async def exists(cls, _filter: dict | None = None, /, **kwargs) -> bool:
|
369
|
+
"""
|
370
|
+
Check if document exists in collection or not
|
371
|
+
|
372
|
+
Example:
|
373
|
+
-------
|
374
|
+
>>> from app.models import User
|
375
|
+
|
376
|
+
>>> await User.exists(age=18, name='Ali')
|
377
|
+
or
|
378
|
+
>>> await User.exists({'age': 18, 'name': 'Ali'})
|
379
|
+
or
|
380
|
+
>>> await User.exists({'age': 18}, name='Ali')
|
381
|
+
"""
|
382
|
+
if await cls.count(_filter, **kwargs) > 0:
|
383
|
+
return True
|
384
|
+
else:
|
385
|
+
return False
|
386
|
+
|
367
387
|
async def save(self) -> None:
|
368
388
|
"""
|
369
389
|
Save the document
|
panther/db/utils.py
CHANGED
@@ -29,7 +29,7 @@ def log_query(func):
|
|
29
29
|
def check_connection(func):
|
30
30
|
async def wrapper(*args, **kwargs):
|
31
31
|
if config.QUERY_ENGINE is None:
|
32
|
-
msg = "You don't have active database connection, Check your
|
32
|
+
msg = "You don't have active database connection, Check your DATABASE block in configs"
|
33
33
|
raise NotImplementedError(msg)
|
34
34
|
return await func(*args, **kwargs)
|
35
35
|
|
panther/logging.py
CHANGED
panther/utils.py
CHANGED
@@ -50,6 +50,20 @@ def generate_secret_key() -> str:
|
|
50
50
|
|
51
51
|
|
52
52
|
def round_datetime(dt: datetime, delta: timedelta):
|
53
|
+
"""
|
54
|
+
Example:
|
55
|
+
>>> round_datetime(datetime(2024, 7, 15, 13, 22, 11, 562159), timedelta(days=2))
|
56
|
+
datetime.datetime(2024, 7, 16, 0, 0)
|
57
|
+
|
58
|
+
>>> round_datetime(datetime(2024, 7, 16, 13, 22, 11, 562159), timedelta(days=2))
|
59
|
+
datetime.datetime(2024, 7, 16, 0, 0)
|
60
|
+
|
61
|
+
>>> round_datetime(datetime(2024, 7, 17, 13, 22, 11, 562159), timedelta(days=2))
|
62
|
+
datetime.datetime(2024, 7, 18, 0, 0)
|
63
|
+
|
64
|
+
>>> round_datetime(datetime(2024, 7, 18, 13, 22, 11, 562159), timedelta(days=2))
|
65
|
+
datetime.datetime(2024, 7, 18, 0, 0)
|
66
|
+
"""
|
53
67
|
return datetime.min + round((dt - datetime.min) / delta) * delta
|
54
68
|
|
55
69
|
|
panther/websocket.py
CHANGED
@@ -27,6 +27,12 @@ class GenericWebsocket(Websocket):
|
|
27
27
|
"""
|
28
28
|
return await super().send(data=data)
|
29
29
|
|
30
|
+
async def close(self, code: int = status.WS_1000_NORMAL_CLOSURE, reason: str = ''):
|
31
|
+
"""
|
32
|
+
Called whenever server or client, wants to close the connection
|
33
|
+
"""
|
34
|
+
return await super().close(code=code, reason=reason)
|
35
|
+
|
30
36
|
|
31
37
|
async def send_message_to_websocket(connection_id: str, data: any):
|
32
38
|
await config.WEBSOCKET_CONNECTIONS.publish(connection_id=connection_id, action='send', data=data)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: panther
|
3
|
-
Version: 4.2.
|
3
|
+
Version: 4.2.4
|
4
4
|
Summary: Fast & Friendly, Web Framework For Building Async APIs
|
5
5
|
Home-page: https://github.com/alirn76/panther
|
6
6
|
Author: Ali RajabNezhad
|
@@ -13,20 +13,20 @@ Classifier: Programming Language :: Python :: 3.12
|
|
13
13
|
Requires-Python: >=3.10
|
14
14
|
Description-Content-Type: text/markdown
|
15
15
|
License-File: LICENSE
|
16
|
-
Requires-Dist: httptools ~=0.6
|
17
|
-
Requires-Dist: pantherdb
|
18
|
-
Requires-Dist: pydantic ~=2.
|
19
|
-
Requires-Dist: rich ~=13.7
|
20
|
-
Requires-Dist: uvicorn ~=0.27
|
16
|
+
Requires-Dist: httptools ~=0.6.1
|
17
|
+
Requires-Dist: pantherdb ~=2.1.0
|
18
|
+
Requires-Dist: pydantic ~=2.7.4
|
19
|
+
Requires-Dist: rich ~=13.7.1
|
20
|
+
Requires-Dist: uvicorn ~=0.27.1
|
21
21
|
Requires-Dist: pytz ~=2024.1
|
22
22
|
Provides-Extra: full
|
23
23
|
Requires-Dist: redis ==5.0.1 ; extra == 'full'
|
24
|
-
Requires-Dist: motor ~=3.
|
24
|
+
Requires-Dist: motor ~=3.5.0 ; extra == 'full'
|
25
25
|
Requires-Dist: bpython ~=0.24 ; extra == 'full'
|
26
26
|
Requires-Dist: ruff ~=0.1.9 ; extra == 'full'
|
27
|
-
Requires-Dist: python-jose ~=3.3 ; extra == 'full'
|
27
|
+
Requires-Dist: python-jose ~=3.3.0 ; extra == 'full'
|
28
28
|
Requires-Dist: websockets ~=12.0 ; extra == 'full'
|
29
|
-
Requires-Dist: cryptography ~=42.0 ; extra == 'full'
|
29
|
+
Requires-Dist: cryptography ~=42.0.8 ; extra == 'full'
|
30
30
|
Requires-Dist: watchfiles ~=0.21.0 ; extra == 'full'
|
31
31
|
|
32
32
|
|
@@ -56,7 +56,7 @@ Requires-Dist: watchfiles ~=0.21.0 ; extra == 'full'
|
|
56
56
|
- Support Custom **Middlewares**
|
57
57
|
- Support Custom **Throttling**
|
58
58
|
- Support **Function-Base** and **Class-Base** APIs
|
59
|
-
- It's One Of The **Fastest Python Framework**
|
59
|
+
- It's One Of The **Fastest Python Framework** ([Benchmark](https://www.techempower.com/benchmarks/#section=test&runid=d3364379-1bf7-465f-bcb1-e9c65b4840f9&hw=ph&test=fortune&l=zik0zj-6bi))
|
60
60
|
---
|
61
61
|
|
62
62
|
### Supported by
|
@@ -1,4 +1,4 @@
|
|
1
|
-
panther/__init__.py,sha256=
|
1
|
+
panther/__init__.py,sha256=jXiDH-UBeYxx2lgu4JXs2xheg9VZnc4TKPmqsisk1KQ,110
|
2
2
|
panther/_load_configs.py,sha256=AVkoixkUFkBQiTmrLrwCmg0eiPW2U_Uw2EGNEGQRfnI,9281
|
3
3
|
panther/_utils.py,sha256=j0rwIxTf0rtcZAAD-1nGE-_bWpvinyKtnwt3uO0hMmY,4330
|
4
4
|
panther/app.py,sha256=e2eb4sXIaBje5vpcm4pbvvEO_sj83pLfBHCIZJFFX38,8222
|
@@ -12,7 +12,7 @@ panther/events.py,sha256=bxDqrfiNNBlvD03vEk2LDK4xbMzTMFVcgAjx2ein7mI,1158
|
|
12
12
|
panther/exceptions.py,sha256=7rHdJIES2__kqOStIqbHl3Uxask2lzKgLQlkZvvDwFA,1591
|
13
13
|
panther/file_handler.py,sha256=I94tpbtTVniBnnUMkFr3Eis6kPDt8sLzS5u8TzFrR5I,1323
|
14
14
|
panther/generics.py,sha256=D2ia7M4ML15kMZiuCIMpL7ZfQhMmKpqE4wCmuRE-q4Y,7233
|
15
|
-
panther/logging.py,sha256=
|
15
|
+
panther/logging.py,sha256=SGgF9faQM1QmbmMPVc6m1DY-TbV329kTD8BuzGLx3I0,2073
|
16
16
|
panther/main.py,sha256=UbIxwaojvY_vH9nYfBpkulRBqVEj4Lbl81Er4XW_KCY,9334
|
17
17
|
panther/monitoring.py,sha256=y1F3c8FJlnmooM-m1nSyOTa9eWq0v1nHnmw9zz-4Kls,1314
|
18
18
|
panther/pagination.py,sha256=ANJrEF0q1nVAfD33I4nZfUUxFcETzJb01gIhbZX3HEw,1639
|
@@ -24,34 +24,34 @@ panther/serializer.py,sha256=UX-cVS-11KnxijUhPXsBs_Pb-Sm3EVzUQFTf9bFQT0A,9096
|
|
24
24
|
panther/status.py,sha256=Gc_PnYrHfInTsZpGbqiCfDB-py1C7Rh8KMdb6Lq9Exs,3346
|
25
25
|
panther/test.py,sha256=RsQtP5IURLWR__BihOjruWoX3NscmGDqDqj1CfAb3bI,7037
|
26
26
|
panther/throttling.py,sha256=mVa_mGv6w_Ad7LLtV4eG5QpDwwNsk4QjFFi0mIHQBnE,231
|
27
|
-
panther/utils.py,sha256=
|
28
|
-
panther/websocket.py,sha256=
|
27
|
+
panther/utils.py,sha256=6ZkHWm4FniOv-Hufknq2tVclrfIbxyzCL-gDlx6uNaQ,3977
|
28
|
+
panther/websocket.py,sha256=YRWgc_FUrv94-dnM2nm41EDgCsqZHxQ1N53Gma7c9s0,1452
|
29
29
|
panther/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
30
|
panther/cli/create_command.py,sha256=mT5GFzsTYZbzqShNHlw_UIkMcWLw9btm2mTwcg7TlfI,10292
|
31
31
|
panther/cli/main.py,sha256=pCqnOTazgMhTvFHTugutIsiFXueU5kx2VmGngwAl54Q,1679
|
32
32
|
panther/cli/monitor_command.py,sha256=sbnxQOSy0Q6GB-ELrfyoY6S-ZwgbI7eZyKx7YkvrEas,3383
|
33
33
|
panther/cli/run_command.py,sha256=yWcDoWC-c4ph4M5EDj0jvR9xSjh-apG5r6-NpDdArUo,2195
|
34
34
|
panther/cli/template.py,sha256=hVkY1A3HZDVGEZzRkMtYte6FagKGTAxoFeG0wot7Zn4,5320
|
35
|
-
panther/cli/utils.py,sha256=
|
35
|
+
panther/cli/utils.py,sha256=g_Xkvh_GCFrc3Remgp02lVi3YkmCAvcNKuAY_QvBTLI,5290
|
36
36
|
panther/db/__init__.py,sha256=w9lEL0vRqb18Qx_iUJipUR_fi5GQ5uVX0DWycx14x08,50
|
37
|
-
panther/db/connections.py,sha256=
|
37
|
+
panther/db/connections.py,sha256=8QHQ_tmni4gfLHQCR7jmBFfvFgJCOrTQXdQiDRJRuv0,4205
|
38
38
|
panther/db/cursor.py,sha256=jJ6bhz_Zljt3-AoeVdi563e2q3MSDJPP33WVbQk-goE,1287
|
39
39
|
panther/db/models.py,sha256=GRbKXJiwnxQJ_SjuPfXPzA5miH_djZNTPPyqiRp5DI8,2561
|
40
|
-
panther/db/utils.py,sha256=
|
40
|
+
panther/db/utils.py,sha256=ZZa3TMkuRtssl5ZRItFLonyxvMFsTq4fmTD4BblhLDA,1589
|
41
41
|
panther/db/queries/__init__.py,sha256=uF4gvBjLBJ-Yl3WLqoZEVNtHCVhFRKW3_Vi44pJxDNI,45
|
42
42
|
panther/db/queries/base_queries.py,sha256=8HhdlsSW-lgz3-IrZYfOtHNC3TBWbCNErDR4XE718AY,3764
|
43
43
|
panther/db/queries/mongodb_queries.py,sha256=4CQRdmgmKFIpnv6xijS0BMJO-Sf5beyuzmw8Z9jLtnA,5599
|
44
44
|
panther/db/queries/pantherdb_queries.py,sha256=_dA4gXk1IA5jzIy6_6o1zgdZeeka6SPihvQeSkj7h68,4481
|
45
|
-
panther/db/queries/queries.py,sha256=
|
45
|
+
panther/db/queries/queries.py,sha256=dWTiOjdIbrD_TajiyIlCKuFNyn-dkVEWvUFsmH2grjg,12236
|
46
46
|
panther/middlewares/__init__.py,sha256=ydo0bSadGqa2v7Xy1oCTkF2uXrImedXjiyx2vPTwPhE,66
|
47
47
|
panther/middlewares/base.py,sha256=tX0MBvDBkbsAB_DilRIYvcggSAqCzazRTb9MegZNdlA,843
|
48
48
|
panther/panel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
49
|
panther/panel/apis.py,sha256=COsbwKZyTgyHvHYbpDfusifAH9ojMS3z1KhZCt9M-Ms,2428
|
50
50
|
panther/panel/urls.py,sha256=JiV-H4dWE-m_bfaTTVxzOxTvJmOWhyLOvcbM7xU3Bn4,240
|
51
51
|
panther/panel/utils.py,sha256=0Rv79oR5IEqalqwpRKQHMn1p5duVY5mxMqDKiA5mWx4,437
|
52
|
-
panther-4.2.
|
53
|
-
panther-4.2.
|
54
|
-
panther-4.2.
|
55
|
-
panther-4.2.
|
56
|
-
panther-4.2.
|
57
|
-
panther-4.2.
|
52
|
+
panther-4.2.4.dist-info/LICENSE,sha256=2aF1hL2aC0zRPjzUkSxJUzZbn2_uLoOkn7DHjzZni-I,1524
|
53
|
+
panther-4.2.4.dist-info/METADATA,sha256=Nv8m1lQFmOM4DYsFWSARsnbR0EE5MwatWuGHP1JvDw4,6532
|
54
|
+
panther-4.2.4.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
55
|
+
panther-4.2.4.dist-info/entry_points.txt,sha256=6GPxYFGuzVfNB4YpHFJvYex6iWah5_tLnirAHwj2Qsg,51
|
56
|
+
panther-4.2.4.dist-info/top_level.txt,sha256=VbBs02JGXTIoHMzsX-eLOk2MCbBZzQbLhWiYpI7xI2g,8
|
57
|
+
panther-4.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|