queus 0.0.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.
- Queue/__init__.py +18 -0
- Queue/exceptions/__init__.py +4 -0
- Queue/exceptions/exceptions.py +11 -0
- Queue/functions/__init__.py +3 -0
- Queue/functions/function01.py +2 -0
- Queue/functions/function02.py +8 -0
- Queue/functions/function03.py +23 -0
- Queue/functions/functions.py +39 -0
- Queue/scripts/__init__.py +1 -0
- Queue/scripts/script01.py +1 -0
- queus-0.0.3.dist-info/METADATA +76 -0
- queus-0.0.3.dist-info/RECORD +14 -0
- queus-0.0.3.dist-info/WHEEL +5 -0
- queus-0.0.3.dist-info/top_level.txt +1 -0
Queue/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
appname = 'queus'
|
|
2
|
+
version = '0.0.3'
|
|
3
|
+
pythons = '~=3.10'
|
|
4
|
+
clinton = 'Clinton Abraham'
|
|
5
|
+
mention = ['queue', 'queues', 'telegram']
|
|
6
|
+
profile = 'https://github.com/Clinton-Abraham'
|
|
7
|
+
|
|
8
|
+
DATA03 = 'Python queue'
|
|
9
|
+
DATA01 = "clintonabrahamc@gmail.com"
|
|
10
|
+
DATA02 = ['Natural Language :: English',
|
|
11
|
+
'Intended Audience :: Developers',
|
|
12
|
+
'Operating System :: OS Independent',
|
|
13
|
+
'Programming Language :: Python :: 3.10',
|
|
14
|
+
'Programming Language :: Python :: 3.11',
|
|
15
|
+
'Programming Language :: Python :: 3.12',
|
|
16
|
+
'Programming Language :: Python :: 3.13',
|
|
17
|
+
'Programming Language :: Python :: 3.14',
|
|
18
|
+
]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class QueueTelegram:
|
|
2
|
+
|
|
3
|
+
async def message(self, tid, imog, text, button=None):
|
|
4
|
+
if self.storage.index(tid) >= self.workers:
|
|
5
|
+
try: await imog.edit(text=text, reply_markup=button)
|
|
6
|
+
except Exception: pass
|
|
7
|
+
|
|
8
|
+
#================================================================================================
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from collections import Counter
|
|
3
|
+
from .function01 import QUEUES
|
|
4
|
+
from ..exceptions import RateLimited
|
|
5
|
+
#==================================================================================================================
|
|
6
|
+
|
|
7
|
+
class QueueCore:
|
|
8
|
+
|
|
9
|
+
async def queue(self, tid):
|
|
10
|
+
while tid in self.storage:
|
|
11
|
+
if self.storage.index(tid) >= self.workers: await asyncio.sleep(self.waiting)
|
|
12
|
+
else: break
|
|
13
|
+
|
|
14
|
+
#==================================================================================================================
|
|
15
|
+
|
|
16
|
+
async def checklimit(self, uid):
|
|
17
|
+
mains = Counter(QUEUES)[uid]
|
|
18
|
+
if mains >= self.limited:
|
|
19
|
+
raise RateLimited(f"Reached Your limit {self.limited}/{self.limited} please wait few minutes.")
|
|
20
|
+
else:
|
|
21
|
+
QUEUES.append(uid)
|
|
22
|
+
|
|
23
|
+
#==================================================================================================================
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from .function01 import Queues
|
|
2
|
+
from .function01 import QUEUES
|
|
3
|
+
from .function03 import QueueCore
|
|
4
|
+
from ..exceptions import Queuefull
|
|
5
|
+
from .function02 import QueueTelegram
|
|
6
|
+
from ..exceptions import QueuedAlready
|
|
7
|
+
#================================================================================================
|
|
8
|
+
|
|
9
|
+
class Queue(QueueCore, QueueTelegram):
|
|
10
|
+
|
|
11
|
+
def __init__(self, **kwargs):
|
|
12
|
+
self.waiting = kwargs.get("wait", 1)
|
|
13
|
+
self.limited = kwargs.get("limit", 100)
|
|
14
|
+
self.workers = kwargs.get("workers", 1)
|
|
15
|
+
self.maxsize = kwargs.get("maxsize", 100)
|
|
16
|
+
self.storage = kwargs.get("storage", Queues)
|
|
17
|
+
|
|
18
|
+
#================================================================================================
|
|
19
|
+
|
|
20
|
+
async def total(self):
|
|
21
|
+
return len(self.storage)
|
|
22
|
+
|
|
23
|
+
async def remove(self, tid, uid=None):
|
|
24
|
+
QUEUES.remove(uid) if uid and uid in QUEUES else 0
|
|
25
|
+
self.storage.remove(tid) if tid in self.storage else 0
|
|
26
|
+
|
|
27
|
+
async def clean(self, uid=None, tid=None):
|
|
28
|
+
QUEUES.remove(uid) if uid else QUEUES.clear()
|
|
29
|
+
self.storage.remove(tid) if tid else self.storage.clear()
|
|
30
|
+
|
|
31
|
+
async def position(self, tid):
|
|
32
|
+
return self.storage.index(tid) - self.workers + 1 if tid in self.storage else 0
|
|
33
|
+
|
|
34
|
+
async def add(self, tid, priority=-1):
|
|
35
|
+
if len(self.storage) >= self.maxsize: raise Queuefull("Hey now I'm very busy.")
|
|
36
|
+
if tid in self.storage: raise QueuedAlready("Already Added!")
|
|
37
|
+
self.storage.append(tid) if priority == -1 else self.storage.insert(priority, tid)
|
|
38
|
+
|
|
39
|
+
#================================================================================================
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: queus
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Python queue
|
|
5
|
+
Home-page: https://github.com/Clinton-Abraham
|
|
6
|
+
Author: Clinton Abraham
|
|
7
|
+
Author-email: clintonabrahamc@gmail.com
|
|
8
|
+
Keywords: queue,queues,telegram
|
|
9
|
+
Classifier: Natural Language :: English
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Requires-Python: ~=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: description
|
|
23
|
+
Dynamic: description-content-type
|
|
24
|
+
Dynamic: home-page
|
|
25
|
+
Dynamic: keywords
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
Dynamic: summary
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
📦 <a href="https://pypi.org/project/Queus" style="text-decoration:none;">QUEUE</a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<a href="https://telegram.me/Space_x_bots"><img src="https://img.shields.io/badge/Sᴘᴀᴄᴇ 𝕩 ʙᴏᴛꜱ-30302f?style=flat&logo=telegram" alt="telegram badge"/></a>
|
|
35
|
+
<a href="https://telegram.me/clinton_abraham"><img src="https://img.shields.io/badge/Cʟɪɴᴛᴏɴ Aʙʀᴀʜᴀᴍ-30302f?style=flat&logo=telegram" alt="telegram badge"/></a>
|
|
36
|
+
<a href="https://telegram.me/sources_codes"><img src="https://img.shields.io/badge/Sᴏᴜʀᴄᴇ ᴄᴏᴅᴇꜱ-30302f?style=flat&logo=telegram" alt="telegram badge"/></a>
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
## USAGE
|
|
40
|
+
<details>
|
|
41
|
+
<summary>Installation</summary>
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install queus
|
|
45
|
+
```
|
|
46
|
+
</details>
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Usage example</summary>
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import asyncio
|
|
53
|
+
from Queue.functions import Queue
|
|
54
|
+
from Queue.functions import Queues
|
|
55
|
+
|
|
56
|
+
queue = Queue(workers=1)
|
|
57
|
+
|
|
58
|
+
async def runtask():
|
|
59
|
+
print("Processing....")
|
|
60
|
+
await asyncio.sleep(10)
|
|
61
|
+
|
|
62
|
+
async def main():
|
|
63
|
+
tasks = ["Task01", "Task02"]
|
|
64
|
+
for task in tasks:
|
|
65
|
+
await queue.add(task)
|
|
66
|
+
await queue.queue(task)
|
|
67
|
+
await runtask()
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
await queue.remove(task)
|
|
71
|
+
OR
|
|
72
|
+
await Queue.remove(task)
|
|
73
|
+
"""
|
|
74
|
+
asyncio.run(main())
|
|
75
|
+
```
|
|
76
|
+
</details>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Queue/__init__.py,sha256=JCmywQ0kRs0Ntx-en8o-bngPj6ReK1YpQ-1rOmWvmzo,639
|
|
2
|
+
Queue/exceptions/__init__.py,sha256=trALJUUDPaawgwh4g-ew__HwJwnEvZwIzv46YmqvLbY,142
|
|
3
|
+
Queue/exceptions/exceptions.py,sha256=tIZiQPzNFyukLiCPCVq9HC3Osyv-Y2dpx5cuYYd9l6g,157
|
|
4
|
+
Queue/functions/__init__.py,sha256=R9_Rxkr1U-WX4AsTMrs--VTgCbmRHjOXK9Ky_LsOF9M,91
|
|
5
|
+
Queue/functions/function01.py,sha256=GYmV9DUxwp1fLUA20jP4gARtWKy0jvPFs-FBuGpJDZA,24
|
|
6
|
+
Queue/functions/function02.py,sha256=_sZQj3D7ImxX1LKUYJefagDMKEomyDy6wEG0jyEKJ9U,333
|
|
7
|
+
Queue/functions/function03.py,sha256=lvjBk5CDXyMGuA7-XY7se8XSruzti54K54PhBVCAnoI,927
|
|
8
|
+
Queue/functions/functions.py,sha256=8FKWCEpbYV54KdveNtF8dzJMkI_dcXt53CXAMD_-yi4,1639
|
|
9
|
+
Queue/scripts/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
10
|
+
Queue/scripts/script01.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
11
|
+
queus-0.0.3.dist-info/METADATA,sha256=SbLTsAKs2VINLMGsJDp6m-HTZeLSAyFaJ-XuVJtq6ew,2144
|
|
12
|
+
queus-0.0.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
13
|
+
queus-0.0.3.dist-info/top_level.txt,sha256=XAdzZwMRIIT6NjaczMWWceutZm5KjlUOpcIsBpZN7X8,6
|
|
14
|
+
queus-0.0.3.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Queue
|