nsarchive 0.0.6a0__py3-none-any.whl → 0.0.8a0__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.
- nsarchive/__init__.py +39 -6
- nsarchive/cls/archives.py +8 -0
- nsarchive/cls/bank.py +7 -0
- {nsarchive-0.0.6a0.dist-info → nsarchive-0.0.8a0.dist-info}/METADATA +1 -1
- nsarchive-0.0.8a0.dist-info/RECORD +10 -0
- nsarchive-0.0.6a0.dist-info/RECORD +0 -8
- {nsarchive-0.0.6a0.dist-info → nsarchive-0.0.8a0.dist-info}/LICENSE +0 -0
- {nsarchive-0.0.6a0.dist-info → nsarchive-0.0.8a0.dist-info}/WHEEL +0 -0
nsarchive/__init__.py
CHANGED
@@ -4,6 +4,7 @@ import deta
|
|
4
4
|
|
5
5
|
from .cls.entities import *
|
6
6
|
from .cls.votes import *
|
7
|
+
from .cls.bank import *
|
7
8
|
|
8
9
|
from .cls.exceptions import *
|
9
10
|
|
@@ -57,7 +58,7 @@ class EntityInstance:
|
|
57
58
|
if type(entity) == Organization:
|
58
59
|
_data['owner_id'] = entity.owner.id.upper() if entity.owner else "0"
|
59
60
|
_data['members'] = [ member.id.upper() for member in entity.members ] if entity.members else []
|
60
|
-
_data['certifications']
|
61
|
+
_data['certifications'] = entity.certifications
|
61
62
|
elif type(entity) == User:
|
62
63
|
_data['boosts'] = entity.boosts
|
63
64
|
|
@@ -88,21 +89,22 @@ class EntityInstance:
|
|
88
89
|
|
89
90
|
if listquery is not None:
|
90
91
|
for item in _res:
|
91
|
-
for target, value in listquery:
|
92
|
+
for target, value in listquery.items():
|
92
93
|
if value not in item[target]:
|
93
94
|
_res.remove(item)
|
94
95
|
|
95
96
|
return _res
|
96
97
|
|
97
|
-
def get_entity_groups(self, id:
|
98
|
-
groups = self.fetch({'_type': 'organization'}, {'members':
|
98
|
+
def get_entity_groups(self, id: str) -> list[Organization]:
|
99
|
+
groups = self.fetch({'_type': 'organization'}, {'members': id})
|
99
100
|
|
100
|
-
return [ self.get_entity(
|
101
|
+
return [ self.get_entity(group['key']) for group in groups ]
|
101
102
|
|
102
103
|
class RepublicInstance:
|
103
104
|
def __init__(self, token: str) -> None:
|
104
105
|
self.db = deta.Deta(token)
|
105
106
|
self.votes = self.db.Base('votes')
|
107
|
+
self.archives = self.db.Base('archives')
|
106
108
|
|
107
109
|
def get_vote(self, id: str) -> Vote | ClosedVote:
|
108
110
|
id = id.upper()
|
@@ -135,4 +137,35 @@ class RepublicInstance:
|
|
135
137
|
'choices': vote.choices
|
136
138
|
}
|
137
139
|
|
138
|
-
self.votes.put(_data, vote.id.upper())
|
140
|
+
self.votes.put(_data, vote.id.upper())
|
141
|
+
|
142
|
+
class BankInstance:
|
143
|
+
def __init__(self, token: str) -> None:
|
144
|
+
self.db = deta.Deta(token)
|
145
|
+
self.accounts = self.db.Base('accounts')
|
146
|
+
self.registry = self.db.Base('banks')
|
147
|
+
|
148
|
+
def get_account(self, id: str) -> BankAccount:
|
149
|
+
id = id.upper()
|
150
|
+
_data = self.accounts.get(id)
|
151
|
+
|
152
|
+
if _data is None:
|
153
|
+
return None
|
154
|
+
|
155
|
+
acc = BankAccount(id)
|
156
|
+
acc.amount = _data['amount']
|
157
|
+
acc.locked = _data['locked']
|
158
|
+
acc.owner = _data['owner_id']
|
159
|
+
acc.bank = _data['bank']
|
160
|
+
|
161
|
+
return acc
|
162
|
+
|
163
|
+
def save_account(self, acc: BankAccount):
|
164
|
+
_data = {
|
165
|
+
'amount': acc.amount,
|
166
|
+
'locked': acc.locked,
|
167
|
+
'owner_id': acc.owner,
|
168
|
+
'bank': acc.bank
|
169
|
+
}
|
170
|
+
|
171
|
+
self.accounts.put(_data, acc.id.upper())
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class Action:
|
2
|
+
def __init__(self, author: str = '11625D9061021010', target: str = '123') -> None:
|
3
|
+
self.author: str = author
|
4
|
+
self.target: str = target
|
5
|
+
|
6
|
+
class Sanction(Action):
|
7
|
+
def __init__(self, author: str, target: str) -> None:
|
8
|
+
super().__init__(author, target)
|
nsarchive/cls/bank.py
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
nsarchive/__init__.py,sha256=VQPxaG4KMatlSWZa8A_UbYmnBVIdMuqrsGFsvrIcmE4,5538
|
2
|
+
nsarchive/cls/archives.py,sha256=RroqiA85YCCbj48IYDqX4PBYKxnT43jL9NWlqxSlllc,299
|
3
|
+
nsarchive/cls/bank.py,sha256=OactEpRn8PGv7BwnBUbMpzgHqrvv4yx526AMzh9uBO8,220
|
4
|
+
nsarchive/cls/entities.py,sha256=mhBHZBtYK1E2dfTDoFHNdw1uu5QsnOc-Utuu5EjtV7c,2556
|
5
|
+
nsarchive/cls/exceptions.py,sha256=TrH9PvHhVZi7wap9ZfBLGRWJY3OBCYgWAMnco5uadYY,420
|
6
|
+
nsarchive/cls/votes.py,sha256=qaWVgfhk5GBccilFSwoZ0E9qE--IX_3HuOBoQAHD2jA,502
|
7
|
+
nsarchive-0.0.8a0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
8
|
+
nsarchive-0.0.8a0.dist-info/METADATA,sha256=J3sYVVCdRQLp1jxP3Ak2kfxoNbQ-sDBYPQcvWH7bB0c,5554
|
9
|
+
nsarchive-0.0.8a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
10
|
+
nsarchive-0.0.8a0.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
nsarchive/__init__.py,sha256=cJodmN9NJHLSgID2H02Bxo0Ma8NjQ5SJslcFp_DI8B0,4613
|
2
|
-
nsarchive/cls/entities.py,sha256=mhBHZBtYK1E2dfTDoFHNdw1uu5QsnOc-Utuu5EjtV7c,2556
|
3
|
-
nsarchive/cls/exceptions.py,sha256=TrH9PvHhVZi7wap9ZfBLGRWJY3OBCYgWAMnco5uadYY,420
|
4
|
-
nsarchive/cls/votes.py,sha256=qaWVgfhk5GBccilFSwoZ0E9qE--IX_3HuOBoQAHD2jA,502
|
5
|
-
nsarchive-0.0.6a0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
6
|
-
nsarchive-0.0.6a0.dist-info/METADATA,sha256=uhyW-Ya7iuqSMy4okCivdZjzURsr-QTVIReKZsYKGYw,5554
|
7
|
-
nsarchive-0.0.6a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
8
|
-
nsarchive-0.0.6a0.dist-info/RECORD,,
|
File without changes
|
File without changes
|