nsarchive 3.0.0a1__py3-none-any.whl → 3.0.0a2__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 +2 -5
- nsarchive/cls/base.py +131 -81
- nsarchive/cls/entities.py +157 -64
- nsarchive/instances/_economy.py +51 -8
- nsarchive/instances/_entities.py +59 -150
- nsarchive/instances/_republic.py +33 -7
- {nsarchive-3.0.0a1.dist-info → nsarchive-3.0.0a2.dist-info}/METADATA +1 -2
- nsarchive-3.0.0a2.dist-info/RECORD +15 -0
- nsarchive/cls/exceptions.py +0 -25
- nsarchive-3.0.0a1.dist-info/RECORD +0 -16
- {nsarchive-3.0.0a1.dist-info → nsarchive-3.0.0a2.dist-info}/LICENSE +0 -0
- {nsarchive-3.0.0a1.dist-info → nsarchive-3.0.0a2.dist-info}/WHEEL +0 -0
nsarchive/instances/_republic.py
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
import time
|
2
2
|
|
3
|
-
from supabase import create_client
|
4
|
-
|
5
3
|
from ..cls.base import *
|
6
4
|
from ..cls.archives import *
|
7
5
|
from ..cls.republic import *
|
8
6
|
|
9
|
-
from ..cls.exceptions import *
|
10
|
-
|
11
7
|
|
12
8
|
class RepublicInstance(Instance):
|
13
9
|
"""
|
10
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
14
11
|
Gère les interactions avec les votes, les archives de la république, et les fonctionnaires.
|
15
12
|
|
16
13
|
## Informations
|
@@ -19,8 +16,8 @@ class RepublicInstance(Instance):
|
|
19
16
|
- Occupants des différents rôles et historique de leurs actions: `.Official`
|
20
17
|
"""
|
21
18
|
|
22
|
-
def __init__(self,
|
23
|
-
super().__init__(
|
19
|
+
def __init__(self, url: str, token: str) -> None:
|
20
|
+
super().__init__(url, token)
|
24
21
|
|
25
22
|
"""
|
26
23
|
---- VOTES & REFERENDUMS ----
|
@@ -28,6 +25,7 @@ class RepublicInstance(Instance):
|
|
28
25
|
|
29
26
|
def get_vote(self, id: NSID) -> Vote | Referendum | Lawsuit:
|
30
27
|
"""
|
28
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
31
29
|
Récupère un vote spécifique.
|
32
30
|
|
33
31
|
## Paramètres
|
@@ -38,6 +36,8 @@ class RepublicInstance(Instance):
|
|
38
36
|
- `.Vote | .Referendum | .Lawsuit`
|
39
37
|
"""
|
40
38
|
|
39
|
+
return Vote(NSID(id), "Vote Inconnu") # Provisoire
|
40
|
+
|
41
41
|
id = NSID(id)
|
42
42
|
_data = self._get_by_ID('votes', id)
|
43
43
|
|
@@ -74,6 +74,7 @@ class RepublicInstance(Instance):
|
|
74
74
|
|
75
75
|
def save_vote(self, vote: Vote | Referendum | Lawsuit):
|
76
76
|
"""
|
77
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
77
78
|
Sauvegarde un vote dans la base de données.
|
78
79
|
|
79
80
|
## Paramètres
|
@@ -81,6 +82,8 @@ class RepublicInstance(Instance):
|
|
81
82
|
Vote à sauvegarder
|
82
83
|
"""
|
83
84
|
|
85
|
+
return # Provisoire
|
86
|
+
|
84
87
|
vote.id = NSID(vote.id)
|
85
88
|
|
86
89
|
_data = {
|
@@ -110,6 +113,7 @@ class RepublicInstance(Instance):
|
|
110
113
|
|
111
114
|
def get_official(self, id: NSID, current_mandate: bool = True) -> Official:
|
112
115
|
"""
|
116
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
113
117
|
Récupère les informations d'un fonctionnaire (mandats, contributions).
|
114
118
|
|
115
119
|
## Paramètres
|
@@ -122,6 +126,8 @@ class RepublicInstance(Instance):
|
|
122
126
|
- `.Official`
|
123
127
|
"""
|
124
128
|
|
129
|
+
return Official(NSID(id)) # Provisoire
|
130
|
+
|
125
131
|
id = NSID(id)
|
126
132
|
|
127
133
|
base = 'mandate' if current_mandate else 'archives'
|
@@ -149,7 +155,12 @@ class RepublicInstance(Instance):
|
|
149
155
|
return user
|
150
156
|
|
151
157
|
def get_institutions(self) -> State:
|
152
|
-
"""
|
158
|
+
"""
|
159
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
160
|
+
Récupère l'état actuel des institutions de la république.
|
161
|
+
"""
|
162
|
+
|
163
|
+
return State()
|
153
164
|
|
154
165
|
admin = Administration()
|
155
166
|
gov = Government(Official('0'))
|
@@ -192,6 +203,7 @@ class RepublicInstance(Instance):
|
|
192
203
|
|
193
204
|
def update_institutions(self, institutions: State):
|
194
205
|
"""
|
206
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
195
207
|
Fonction communément appelée après un vote législatif ou une nomination.\n
|
196
208
|
Celle-ci met à jour: Le gouvernement (président, ministres), les différents députés et leur président, les différents juges, les différents policiers.\n
|
197
209
|
|
@@ -200,6 +212,8 @@ class RepublicInstance(Instance):
|
|
200
212
|
Le nouvel état des institutions, à sauvegarder.
|
201
213
|
"""
|
202
214
|
|
215
|
+
return # Provisoire
|
216
|
+
|
203
217
|
get_ids = lambda institution : [ member.id for member in institutions.__getattribute__(institution).members ]
|
204
218
|
|
205
219
|
self._put_in_db('functions', { 'id': 'ADMIN', 'users': get_ids('administration') })
|
@@ -219,6 +233,7 @@ class RepublicInstance(Instance):
|
|
219
233
|
|
220
234
|
def new_mandate(self, institutions: State, weeks: int = 4):
|
221
235
|
"""
|
236
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
222
237
|
Fonction qui amène à supprimer toutes les archives du mandat précédent
|
223
238
|
|
224
239
|
## Paramètres
|
@@ -228,6 +243,8 @@ class RepublicInstance(Instance):
|
|
228
243
|
Nombre de semaines du mandat
|
229
244
|
"""
|
230
245
|
|
246
|
+
return # Provisoire
|
247
|
+
|
231
248
|
for item in self.fetch('mandate'):
|
232
249
|
if item['date'] >= round(time.time()) - weeks * 604800: # On évite de supprimer les informations écrites lors de la période définie
|
233
250
|
self._delete_by_ID('mandate', item['id'])
|
@@ -240,6 +257,7 @@ class RepublicInstance(Instance):
|
|
240
257
|
|
241
258
|
def _add_archive(self, archive: Archive):
|
242
259
|
"""
|
260
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
243
261
|
Ajoute une archive d'une action (élection, promotion, ou rétrogradation) dans la base de données.
|
244
262
|
|
245
263
|
## Paramètres
|
@@ -247,6 +265,8 @@ class RepublicInstance(Instance):
|
|
247
265
|
Archive à ajouter
|
248
266
|
"""
|
249
267
|
|
268
|
+
return # Provisoire
|
269
|
+
|
250
270
|
archive.id = NSID(archive.id)
|
251
271
|
_data = archive.__dict__.copy()
|
252
272
|
|
@@ -264,6 +284,7 @@ class RepublicInstance(Instance):
|
|
264
284
|
|
265
285
|
def _get_archive(self, id: NSID) -> Archive | Election | Promotion | Demotion:
|
266
286
|
"""
|
287
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
267
288
|
Récupère une archive spécifique.
|
268
289
|
|
269
290
|
## Paramètres
|
@@ -274,6 +295,8 @@ class RepublicInstance(Instance):
|
|
274
295
|
- `.Archive | .Election | .Promotion | .Demotion`
|
275
296
|
"""
|
276
297
|
|
298
|
+
return Archive(NSID(id)) # Provisoire
|
299
|
+
|
277
300
|
id = NSID(id)
|
278
301
|
_data = self._get_by_ID('archives', id)
|
279
302
|
|
@@ -298,6 +321,7 @@ class RepublicInstance(Instance):
|
|
298
321
|
|
299
322
|
def _fetch_archives(self, **query) -> list[ Archive | Election | Promotion | Demotion ]:
|
300
323
|
"""
|
324
|
+
*INDISPONIBLE DANS CETTE VERSION.*\n
|
301
325
|
Récupère une liste d'archives correspondant à la requête.
|
302
326
|
|
303
327
|
## Paramètres
|
@@ -308,6 +332,8 @@ class RepublicInstance(Instance):
|
|
308
332
|
- `list[.Archive | .Election | .Promotion | .Demotion]`
|
309
333
|
"""
|
310
334
|
|
335
|
+
return [] # Provisoire
|
336
|
+
|
311
337
|
_res = self.fetch('archives', **query)
|
312
338
|
|
313
339
|
return [ self._get_archive(archive['id']) for archive in _res ]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nsarchive
|
3
|
-
Version: 3.0.
|
3
|
+
Version: 3.0.0a2
|
4
4
|
Summary: API-wrapper pour récupérer des données liées à Nation
|
5
5
|
License: GPL-3.0
|
6
6
|
Author: happex
|
@@ -12,7 +12,6 @@ Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
14
14
|
Requires-Dist: pillow (>=10.4,<11.0)
|
15
|
-
Requires-Dist: supabase (>=2.9.1,<3.0.0)
|
16
15
|
Description-Content-Type: text/markdown
|
17
16
|
|
18
17
|
# NSArchive
|
@@ -0,0 +1,15 @@
|
|
1
|
+
nsarchive/__init__.py,sha256=01mYNtrFbmeU_GUIfDd21iWBJSGF650KAUvYphaXc6k,656
|
2
|
+
nsarchive/assets/default_avatar.png,sha256=n-4vG_WPke8LvbY3ZU6oA-H-OtRoIu7woKnRq9DCIlI,51764
|
3
|
+
nsarchive/cls/archives.py,sha256=3vyGOBZUE-B-G_QMJXRIPD0d-1O5z4wqv-2MRf5AQdA,2506
|
4
|
+
nsarchive/cls/base.py,sha256=R6ZD2_DVOvjTO6VZ0HteFWVmdW9fieyIpGF9P0PqYk4,7424
|
5
|
+
nsarchive/cls/economy.py,sha256=soe3ATrtQem-u80vz8nXfsn_3TqMdhpolyTxRenH2C0,2742
|
6
|
+
nsarchive/cls/entities.py,sha256=M2R55pP7j9_dl1RFMR9DouRabl9VzEVGmq4uIOcojPg,14303
|
7
|
+
nsarchive/cls/republic.py,sha256=16NFNCkJxOeVRd6BoJ68AlrTESQgRfZ5FSFlNWTEdK0,4103
|
8
|
+
nsarchive/instances/_economy.py,sha256=kVIbsCIrctV5yA3nlnSEYkJ8Cuh74YnQKtntIXTqOY0,8892
|
9
|
+
nsarchive/instances/_entities.py,sha256=3AYJAARXYhxsEEQaahBvJyT0iOsR1KhUDXOBeAvax4w,7923
|
10
|
+
nsarchive/instances/_republic.py,sha256=M8k2rZJvQGzOyZlmqRDiB-d615hZOqD3kuRrgYP4JqA,12004
|
11
|
+
nsarchive/utils.py,sha256=qpQCZLlbVApOLtCI2ml54QwUld6K8fDxyBfwzofqXzw,610
|
12
|
+
nsarchive-3.0.0a2.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
13
|
+
nsarchive-3.0.0a2.dist-info/METADATA,sha256=N5tE2JUA7T-612kyRTjfKeLwZmz3Cd6i6fO98M9UXPQ,657
|
14
|
+
nsarchive-3.0.0a2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
15
|
+
nsarchive-3.0.0a2.dist-info/RECORD,,
|
nsarchive/cls/exceptions.py
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Exceptions liées aux entités
|
2
|
-
|
3
|
-
class NameTooLongError(Exception):
|
4
|
-
def __init__(self, *args: object) -> None:
|
5
|
-
super().__init__(*args)
|
6
|
-
|
7
|
-
class EntityTypeError(Exception):
|
8
|
-
def __init__(self, *args: object) -> None:
|
9
|
-
super().__init__(*args)
|
10
|
-
|
11
|
-
class AvatarTooLongError(Exception):
|
12
|
-
def __init__(self, *args: object) -> None:
|
13
|
-
super().__init__(*args)
|
14
|
-
|
15
|
-
# Exceptions pour le vote
|
16
|
-
|
17
|
-
class AlreadyVotedError(Exception):
|
18
|
-
def __init__(self, *args: object) -> None:
|
19
|
-
super().__init__(*args)
|
20
|
-
|
21
|
-
# Ressource pas trouvée
|
22
|
-
|
23
|
-
class RessourceNotFoundError(Exception):
|
24
|
-
def __init__(self, *args: object) -> None:
|
25
|
-
super().__init__(*args)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
nsarchive/__init__.py,sha256=_hwIocDyD7R-4rS7ypca8jZex93H6mK-b9NpTpt-Rvo,724
|
2
|
-
nsarchive/assets/default_avatar.png,sha256=n-4vG_WPke8LvbY3ZU6oA-H-OtRoIu7woKnRq9DCIlI,51764
|
3
|
-
nsarchive/cls/archives.py,sha256=3vyGOBZUE-B-G_QMJXRIPD0d-1O5z4wqv-2MRf5AQdA,2506
|
4
|
-
nsarchive/cls/base.py,sha256=7gbXtKZaqkr8NWf-0oZaZ0alR9JSx_G1Qf7Sbn-MbF0,5611
|
5
|
-
nsarchive/cls/economy.py,sha256=soe3ATrtQem-u80vz8nXfsn_3TqMdhpolyTxRenH2C0,2742
|
6
|
-
nsarchive/cls/entities.py,sha256=fAxn4V64dqoB1wq7t-kByARlrr_jKzPzqpvFO_ECXnI,10144
|
7
|
-
nsarchive/cls/exceptions.py,sha256=QN6Qn7cxTkGoC4lO50hBAq4gZCgo7scQvCkb-xKl6Xs,692
|
8
|
-
nsarchive/cls/republic.py,sha256=16NFNCkJxOeVRd6BoJ68AlrTESQgRfZ5FSFlNWTEdK0,4103
|
9
|
-
nsarchive/instances/_economy.py,sha256=trReX8u5QrgcYm6RElV-gNjVyFbZWO783XTDMm9JJj4,7777
|
10
|
-
nsarchive/instances/_entities.py,sha256=AmpnXz1penQz09bhnErK8QKU6WnVwGwc3txkHc-OFfY,10635
|
11
|
-
nsarchive/instances/_republic.py,sha256=5cOihYch6n2dyYAqiNYMdwerwcyZ9Y80f5cRtvkiH-o,11289
|
12
|
-
nsarchive/utils.py,sha256=qpQCZLlbVApOLtCI2ml54QwUld6K8fDxyBfwzofqXzw,610
|
13
|
-
nsarchive-3.0.0a1.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
14
|
-
nsarchive-3.0.0a1.dist-info/METADATA,sha256=SYHycWCpFIu2_B6EuFSoaNSyziz6__EwF9dxWWVSQhg,698
|
15
|
-
nsarchive-3.0.0a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
16
|
-
nsarchive-3.0.0a1.dist-info/RECORD,,
|
File without changes
|
File without changes
|