morelists 0.1.0__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.
morelists/__init__.py
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
import time
|
2
|
+
|
3
|
+
class GameList():
|
4
|
+
def __init__(self):
|
5
|
+
self.list = {}
|
6
|
+
self.flippedList = {}
|
7
|
+
|
8
|
+
self.addValue = 0
|
9
|
+
self.subtractValue = 0
|
10
|
+
self.multiplyValue = 1
|
11
|
+
self.divideValue = 1
|
12
|
+
self.sum = 0
|
13
|
+
|
14
|
+
def add(self, item, expires = -1):
|
15
|
+
expires += time.time()
|
16
|
+
self.list[expires] = {"name":item.get("name", ""), "type":item.get("type", "add"), "value":item.get("value", 0)}
|
17
|
+
if self.list[expires]["type"] not in ["add", "subtract", "multiply", "divide"]:
|
18
|
+
self.list[expires]["type"] = "add"
|
19
|
+
self.flippedList[str(self.list[expires])] = expires
|
20
|
+
|
21
|
+
if item["type"] == "add":
|
22
|
+
self.addValue += item["value"]
|
23
|
+
elif item["type"] == "subtract":
|
24
|
+
self.subtractValue += item["value"]
|
25
|
+
elif item["type"] == "multiply":
|
26
|
+
self.multiplyValue += (item["value"] - 1)
|
27
|
+
elif item["type"] == "divide":
|
28
|
+
self.divideValue += (item["value"] - 1)
|
29
|
+
|
30
|
+
def unsafeAdd(self, item, expires = -1):
|
31
|
+
expiration = expires + time.time()
|
32
|
+
self.list[expiration] = item
|
33
|
+
self.flippedList[str(item)] = expiration
|
34
|
+
|
35
|
+
if item["type"] == "add":
|
36
|
+
self.addValue += item["value"]
|
37
|
+
elif item["type"] == "subtract":
|
38
|
+
self.subtractValue += item["value"]
|
39
|
+
elif item["type"] == "multiply":
|
40
|
+
self.multiplyValue += (item["value"] - 1)
|
41
|
+
elif item["type"] == "divide":
|
42
|
+
self.divideValue += (item["value"] - 1)
|
43
|
+
|
44
|
+
|
45
|
+
def update(self):
|
46
|
+
try:
|
47
|
+
expiration = min(self.list.keys())
|
48
|
+
while expiration < time.time():
|
49
|
+
if self.list[expiration]["type"] == "add":
|
50
|
+
self.addValue -= self.list[expiration]["value"]
|
51
|
+
elif self.list[expiration]["type"] == "subtract":
|
52
|
+
self.subtractValue -= self.list[expiration]["value"]
|
53
|
+
elif self.list[expiration]["type"] == "multiply":
|
54
|
+
self.multiplyValue -= (self.list[expiration]["value"] - 1)
|
55
|
+
else:
|
56
|
+
self.divideValue -= (self.list[expiration]["value"] - 1)
|
57
|
+
del self.list[expiration]
|
58
|
+
|
59
|
+
expiration = min(self.list.keys())
|
60
|
+
except ValueError:
|
61
|
+
pass
|
62
|
+
|
63
|
+
def pop(self, name):
|
64
|
+
pops = [value for value in self.list.values() if value["name"] == name]
|
65
|
+
pops.sort(key=lambda a: a["expires"])
|
66
|
+
if pops:
|
67
|
+
del self.list[self.flippedList[str(pops[0])]]
|
68
|
+
del self.flippedList[str(pops[0])]
|
69
|
+
|
70
|
+
def popAny(self, name):
|
71
|
+
pops = [value for value in self.list.values() if value["name"] == name]
|
72
|
+
if pops:
|
73
|
+
del self.list[self.flippedList[str(pops[0])]]
|
74
|
+
del self.flippedList[str(pops[0])]
|
75
|
+
|
76
|
+
def popAll(self, name):
|
77
|
+
pops = [value for value in self.list.values() if value["name"] == name]
|
78
|
+
if pops:
|
79
|
+
for x in range(len(pops)):
|
80
|
+
del self.list[self.flippedList[str(pops[x])]]
|
81
|
+
del self.flippedList[str(pops[x])]
|
82
|
+
|
83
|
+
def remove(self, item):
|
84
|
+
if self.flippedList.get(str(item), None):
|
85
|
+
del self.list[self.flippedList[str(item)]]
|
86
|
+
del self.flippedList[str(item)]
|
87
|
+
|
88
|
+
if item["type"] == "add":
|
89
|
+
self.addValue -= item["value"]
|
90
|
+
elif item["type"] == "subtract":
|
91
|
+
self.subtractValue -= item["value"]
|
92
|
+
elif item["type"] == "multiply":
|
93
|
+
self.multiplyValue -= (item["value"] - 1)
|
94
|
+
else:
|
95
|
+
self.divideValue -= (item["value"] - 1)
|
96
|
+
|
97
|
+
def unsafeRemove(self, item):
|
98
|
+
if item in self.list.values():
|
99
|
+
del self.list[dict(self.flippedList[str(item)])]
|
100
|
+
del self.flippedList[str(item)]
|
101
|
+
|
102
|
+
if item["type"] == "add":
|
103
|
+
self.addValue -= item["value"]
|
104
|
+
elif item["type"] == "subtract":
|
105
|
+
self.subtractValue -= item["value"]
|
106
|
+
elif item["type"] == "multiply":
|
107
|
+
self.multiplyValue -= (item["value"] - 1)
|
108
|
+
else:
|
109
|
+
self.divideValue -= (item["value"] - 1)
|
110
|
+
|
111
|
+
def __getattribute__(self, name):
|
112
|
+
if name == "sum":
|
113
|
+
self.update()
|
114
|
+
return (object.__getattribute__(self, "addValue") -
|
115
|
+
object.__getattribute__(self, "subtractValue")) * \
|
116
|
+
object.__getattribute__(self, "multiplyValue") / \
|
117
|
+
object.__getattribute__(self, "divideValue")
|
118
|
+
return object.__getattribute__(self, name)
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Made 3/22/2025. Pls don't judge.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: morelists
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: A small and easy list you can add together like a math equation and has a expiration date for items. Mostly useful for games with stats from multiple sources. More lists will come soon.
|
5
|
+
Home-page: https://github.com/EmanuelNorsk/enlist
|
6
|
+
Author: Emanuel Odén Hesselroth
|
7
|
+
Author-email: Emanuel Odén Hesselroth <emanuelodenhesselroth@gmail.com>
|
8
|
+
License: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: OS Independent
|
12
|
+
Requires-Python: >=3.6
|
13
|
+
License-File: LICENSE
|
14
|
+
Dynamic: author
|
15
|
+
Dynamic: home-page
|
@@ -0,0 +1,6 @@
|
|
1
|
+
morelists/__init__.py,sha256=MCofk70SKqV9lkk01iBpyYAIFl29vB09RXX4WnOM0UA,4718
|
2
|
+
morelists-0.1.0.dist-info/LICENSE,sha256=-ASFHlrne1rk8zV57Qj01X2JB-D67ZHPMv1PtQhrbN8,32
|
3
|
+
morelists-0.1.0.dist-info/METADATA,sha256=jq8smAfeCnSeI0uDBOOBJt-44Xa4oI-AY2GWO-H517Q,658
|
4
|
+
morelists-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
5
|
+
morelists-0.1.0.dist-info/top_level.txt,sha256=Zd7NosYzor-RcH_aD86FXJa3fQzWunYA4_FQS3Yodqo,10
|
6
|
+
morelists-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
morelists
|