nsarchive 3.0.0a6__py3-none-any.whl → 3.0.0a8__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 +15 -10
- nsarchive/{instances → interfaces}/_economy.py +15 -30
- nsarchive/interfaces/_entities.py +206 -0
- nsarchive/interfaces/_justice.py +50 -0
- nsarchive/interfaces/_state.py +142 -0
- nsarchive/mandate.py +50 -0
- nsarchive/{cls → models}/base.py +23 -5
- nsarchive/{cls → models}/economy.py +34 -13
- nsarchive/{cls → models}/entities.py +139 -72
- nsarchive/models/justice.py +108 -0
- nsarchive/models/republic.py +125 -0
- nsarchive/models/scale.py +23 -0
- nsarchive/models/state.py +59 -0
- {nsarchive-3.0.0a6.dist-info → nsarchive-3.0.0a8.dist-info}/METADATA +3 -2
- nsarchive-3.0.0a8.dist-info/RECORD +19 -0
- {nsarchive-3.0.0a6.dist-info → nsarchive-3.0.0a8.dist-info}/WHEEL +1 -1
- nsarchive/cls/archives.py +0 -93
- nsarchive/cls/republic.py +0 -149
- nsarchive/instances/_entities.py +0 -269
- nsarchive/instances/_republic.py +0 -339
- nsarchive-3.0.0a6.dist-info/RECORD +0 -15
- {nsarchive-3.0.0a6.dist-info → nsarchive-3.0.0a8.dist-info}/LICENSE +0 -0
nsarchive/instances/_entities.py
DELETED
@@ -1,269 +0,0 @@
|
|
1
|
-
from ..cls.base import *
|
2
|
-
from ..cls.entities import *
|
3
|
-
|
4
|
-
from ..cls import entities # Pour les default_headers
|
5
|
-
|
6
|
-
class EntityInstance(Instance):
|
7
|
-
"""
|
8
|
-
Instance qui vous permettra d'interagir avec les profils des membres ainsi que les différents métiers et secteurs d'activité.
|
9
|
-
|
10
|
-
## Informations disponibles
|
11
|
-
- Profil des membres et des entreprises: `.User | .Organization | .Entity`
|
12
|
-
- Participation d'un membre à différent votes: `.User | .Organization | .Entity`
|
13
|
-
- Appartenance et permissions d'un membre dans un groupe: `.GroupMember.MemberPermissions`
|
14
|
-
- Position légale et permissions d'une entité: `.Position.Permissions`
|
15
|
-
- Sanctions et modifications d'une entité: `.Action[ .AdminAction | .Sanction ]`
|
16
|
-
"""
|
17
|
-
|
18
|
-
def __init__(self, url: str, token: str = None) -> None:
|
19
|
-
super().__init__(url, token)
|
20
|
-
|
21
|
-
entities.default_headers = self.default_headers
|
22
|
-
|
23
|
-
"""
|
24
|
-
---- ENTITÉS ----
|
25
|
-
"""
|
26
|
-
|
27
|
-
def get_entity(self, id: NSID, _class: str = None) -> User | Organization | Entity:
|
28
|
-
"""
|
29
|
-
Fonction permettant de récupérer le profil public d'une entité.\n
|
30
|
-
|
31
|
-
## Paramètres
|
32
|
-
id: `NSID`
|
33
|
-
ID héxadécimal de l'entité à récupérer
|
34
|
-
_class: `str`
|
35
|
-
Classe du modèle à prendre (`.User` ou `.Organization`)
|
36
|
-
|
37
|
-
## Renvoie
|
38
|
-
- `.User` dans le cas où l'entité choisie est un membre
|
39
|
-
- `.Organization` dans le cas où c'est un groupe
|
40
|
-
- `.Entity` dans le cas où c'est indéterminé
|
41
|
-
"""
|
42
|
-
|
43
|
-
id = NSID(id)
|
44
|
-
|
45
|
-
if _class == "user":
|
46
|
-
_data = self._get_by_ID('individuals', id)
|
47
|
-
elif _class == "group":
|
48
|
-
_data = self._get_by_ID('organizations', id)
|
49
|
-
else:
|
50
|
-
_data = self._get_by_ID('entities', id)
|
51
|
-
|
52
|
-
if _data is None: # ID inexistant chez les entités
|
53
|
-
return None
|
54
|
-
|
55
|
-
if _data['_class'] == 'individuals':
|
56
|
-
entity = User(id)
|
57
|
-
entity._url = f"{self.url}/model/individuals/{id}"
|
58
|
-
|
59
|
-
entity._load(_data)
|
60
|
-
elif _data['_class'] == 'organizations':
|
61
|
-
entity = Organization(id)
|
62
|
-
entity._url = f"{self.url}/model/organizations/{id}"
|
63
|
-
|
64
|
-
_owner = _data['owner']
|
65
|
-
|
66
|
-
if _owner['_class'] == 'individuals':
|
67
|
-
entity.owner = User(_owner['id'])
|
68
|
-
entity.owner._load(_owner)
|
69
|
-
elif _owner['class'] == 'organizations':
|
70
|
-
entity.owner = Organization(_owner['id'])
|
71
|
-
entity.owner._load(_owner)
|
72
|
-
else:
|
73
|
-
entity.owner = self.get_entity(0x0)
|
74
|
-
|
75
|
-
entity._load(_data)
|
76
|
-
else:
|
77
|
-
entity = Entity(id)
|
78
|
-
entity._url = f"{self.url}/model/entities/{id}"
|
79
|
-
|
80
|
-
entity.name = _data['name']
|
81
|
-
entity.position._load(_data['position']) # Métier si c'est un utilisateur, domaine professionnel si c'est un collectif
|
82
|
-
entity.registerDate = _data['register_date']
|
83
|
-
|
84
|
-
for key, value in _data.get('additional', {}).items():
|
85
|
-
if isinstance(value, str) and value.startswith('\n'):
|
86
|
-
entity.additional[key] = int(value[1:])
|
87
|
-
else:
|
88
|
-
entity.additional[key] = value
|
89
|
-
|
90
|
-
entity.position._url = f"{self.url}/positions/{id}"
|
91
|
-
|
92
|
-
return entity
|
93
|
-
|
94
|
-
def get_entity_groups(self, entity: User) -> list[Organization]:
|
95
|
-
print(entity._url)
|
96
|
-
res = requests.get(f"{entity._url}/groups", headers = self.default_headers)
|
97
|
-
|
98
|
-
if res.status_code == 200:
|
99
|
-
return res.json()
|
100
|
-
else:
|
101
|
-
res.raise_for_status()
|
102
|
-
return []
|
103
|
-
|
104
|
-
def save_entity(self, entity: Entity):
|
105
|
-
"""
|
106
|
-
Fonction permettant de créer ou modifier une entité.
|
107
|
-
|
108
|
-
## Paramètres
|
109
|
-
entity: `.Entity`\n
|
110
|
-
L'entité à sauvegarder
|
111
|
-
"""
|
112
|
-
|
113
|
-
entity.id = NSID(entity.id)
|
114
|
-
|
115
|
-
_data = {
|
116
|
-
'id': entity.id,
|
117
|
-
'name': entity.name,
|
118
|
-
'position': entity.position.id,
|
119
|
-
'register_date': entity.registerDate,
|
120
|
-
'additional': {},
|
121
|
-
}
|
122
|
-
|
123
|
-
for key, value in entity.additional.items():
|
124
|
-
if isinstance(value, int) and len(str(int)) >= 15:
|
125
|
-
_data['additional'][key] = '\n' + str(value)
|
126
|
-
elif type(value) in (str, int):
|
127
|
-
_data['additional'][key] = value
|
128
|
-
|
129
|
-
if type(entity) == Organization:
|
130
|
-
_data['owner_id'] = NSID(entity.owner.id) if entity.owner else NSID("0")
|
131
|
-
_data['members'] = []
|
132
|
-
_data['certifications'] = entity.certifications
|
133
|
-
|
134
|
-
for member in entity.members:
|
135
|
-
_member = {
|
136
|
-
'id': NSID(member.id),
|
137
|
-
'level': member.permission_level
|
138
|
-
}
|
139
|
-
|
140
|
-
_data['members'] += [_member]
|
141
|
-
|
142
|
-
entity.save_avatar()
|
143
|
-
elif type(entity) == User:
|
144
|
-
_data['xp'] = entity.xp
|
145
|
-
_data['boosts'] = entity.boosts
|
146
|
-
_data['votes'] = [ NSID(vote) for vote in entity.votes]
|
147
|
-
else:
|
148
|
-
return
|
149
|
-
|
150
|
-
self._put_in_db(
|
151
|
-
f"/new_model/{'individuals' if isinstance(entity, User) else 'organizations'}?id={urllib.parse.quote(entity.id)}&name={urllib.parse.quote(entity.name)}",
|
152
|
-
_data,
|
153
|
-
headers = self.default_headers,
|
154
|
-
use_PUT = True
|
155
|
-
)
|
156
|
-
|
157
|
-
entity._url = f"{self.url}/model/{'individuals' if isinstance(entity, User) else 'organizations'}/{entity.id}"
|
158
|
-
|
159
|
-
|
160
|
-
def delete_entity(self, entity: Entity):
|
161
|
-
"""
|
162
|
-
Fonction permettant de supprimer le profil d'une entité
|
163
|
-
|
164
|
-
## Paramètres
|
165
|
-
entity: `.Entity`\n
|
166
|
-
L'entité à supprimer
|
167
|
-
"""
|
168
|
-
|
169
|
-
res = requests.post(f"{entity._url}/delete", headers = self.default_headers,)
|
170
|
-
|
171
|
-
if res.status_code != 200:
|
172
|
-
res.raise_for_status()
|
173
|
-
|
174
|
-
def fetch_entities(self, **query: typing.Any) -> list[ Entity | User | Organization ]:
|
175
|
-
"""
|
176
|
-
Récupère une liste d'entités en fonction d'une requête.
|
177
|
-
|
178
|
-
## Paramètres
|
179
|
-
query: `**dict`\n
|
180
|
-
La requête pour filtrer les entités.
|
181
|
-
|
182
|
-
## Renvoie
|
183
|
-
- `list[.Entity | .User | .Organization]`
|
184
|
-
"""
|
185
|
-
|
186
|
-
if "_class" in query.keys():
|
187
|
-
if query["_class"] == "individuals":
|
188
|
-
del query["_class"]
|
189
|
-
_res = self.fetch('individuals', **query)
|
190
|
-
elif query["_class"] == "organizations":
|
191
|
-
del query["_class"]
|
192
|
-
_res = self.fetch('organizations', **query)
|
193
|
-
else:
|
194
|
-
del query["_class"]
|
195
|
-
_res = self.fetch('entities', **query)
|
196
|
-
else:
|
197
|
-
_res = self.fetch('entities', **query)
|
198
|
-
|
199
|
-
res = []
|
200
|
-
|
201
|
-
for _entity in _res:
|
202
|
-
if _entity is None: continue
|
203
|
-
|
204
|
-
if _entity['_class'] == 'individuals':
|
205
|
-
entity = User(_entity["id"])
|
206
|
-
entity._url = f"{self.url}/model/individuals/{_entity['id']}"
|
207
|
-
|
208
|
-
entity._load(_entity)
|
209
|
-
elif _entity['_class'] == 'organizations':
|
210
|
-
entity = Organization(_entity["id"])
|
211
|
-
entity._url = f"{self.url}/model/organizations/{_entity['id']}"
|
212
|
-
|
213
|
-
_owner = _entity['owner']
|
214
|
-
if _owner['_class'] == 'individuals':
|
215
|
-
entity.owner = User(_owner['id'])
|
216
|
-
entity.owner._load(_owner)
|
217
|
-
elif _owner['class'] == 'organizations':
|
218
|
-
entity.owner = Organization(_owner['id'])
|
219
|
-
entity.owner._load(_owner)
|
220
|
-
else:
|
221
|
-
entity.owner = self.get_entity(0x0)
|
222
|
-
|
223
|
-
entity._load(_entity)
|
224
|
-
else:
|
225
|
-
entity = Entity(_entity["id"])
|
226
|
-
entity._url = f"{self.url}/model/organizations/{_entity['id']}"
|
227
|
-
|
228
|
-
entity.name = _entity['name']
|
229
|
-
entity.position._load(_entity['position'])
|
230
|
-
entity.registerDate = _entity['register_date']
|
231
|
-
|
232
|
-
for key, value in _entity.get('additional', {}).items():
|
233
|
-
if isinstance(value, str) and value.startswith('\n'):
|
234
|
-
entity.additional[key] = int(value[1:])
|
235
|
-
else:
|
236
|
-
entity.additional[key] = value
|
237
|
-
|
238
|
-
entity.position._url = f"{self.url}/positions/{_entity['id']}"
|
239
|
-
|
240
|
-
res.append(entity)
|
241
|
-
|
242
|
-
return res
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
def get_position(self, id: str) -> Position:
|
247
|
-
"""
|
248
|
-
Récupère une position légale (métier, domaine professionnel).
|
249
|
-
|
250
|
-
## Paramètres
|
251
|
-
id: `str`\n
|
252
|
-
ID de la position (SENSIBLE À LA CASSE !)
|
253
|
-
|
254
|
-
## Renvoie
|
255
|
-
- `.Position`
|
256
|
-
"""
|
257
|
-
|
258
|
-
_data = self._get_by_ID('positions', id)
|
259
|
-
|
260
|
-
if _data is None:
|
261
|
-
return None
|
262
|
-
|
263
|
-
position = Position(id)
|
264
|
-
position._url = f"{self.url}/positions/{id}"
|
265
|
-
position.name = _data['name']
|
266
|
-
position.permissions.merge(_data['permissions'])
|
267
|
-
position.manager_permissions.merge(_data['manager_permissions'])
|
268
|
-
|
269
|
-
return position
|
nsarchive/instances/_republic.py
DELETED
@@ -1,339 +0,0 @@
|
|
1
|
-
import time
|
2
|
-
|
3
|
-
from ..cls.base import *
|
4
|
-
from ..cls.archives import *
|
5
|
-
from ..cls.republic import *
|
6
|
-
|
7
|
-
|
8
|
-
class RepublicInstance(Instance):
|
9
|
-
"""
|
10
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
11
|
-
Gère les interactions avec les votes, les archives de la république, et les fonctionnaires.
|
12
|
-
|
13
|
-
## Informations
|
14
|
-
- Résultats des votes et procès: `.Vote | .Referendum | .Lawsuit`
|
15
|
-
- Différentes institutions: `.State | .Administration | .Government | .Assembly | .Court | .PoliceForces`
|
16
|
-
- Occupants des différents rôles et historique de leurs actions: `.Official`
|
17
|
-
"""
|
18
|
-
|
19
|
-
def __init__(self, url: str, token: str) -> None:
|
20
|
-
super().__init__(url, token)
|
21
|
-
|
22
|
-
"""
|
23
|
-
---- VOTES & REFERENDUMS ----
|
24
|
-
"""
|
25
|
-
|
26
|
-
def get_vote(self, id: NSID) -> Vote | Referendum | Lawsuit:
|
27
|
-
"""
|
28
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
29
|
-
Récupère un vote spécifique.
|
30
|
-
|
31
|
-
## Paramètres
|
32
|
-
id: `NSID`\n
|
33
|
-
ID du vote.
|
34
|
-
|
35
|
-
## Renvoie
|
36
|
-
- `.Vote | .Referendum | .Lawsuit`
|
37
|
-
"""
|
38
|
-
|
39
|
-
return Vote(NSID(id), "Vote Inconnu") # Provisoire
|
40
|
-
|
41
|
-
id = NSID(id)
|
42
|
-
_data = self._get_by_ID('votes', id)
|
43
|
-
|
44
|
-
if not _data: # Pas dans les votes -> peut-être dans les procès
|
45
|
-
_data = self._get_by_ID('lawsuits', id)
|
46
|
-
|
47
|
-
if not _data: # Le vote n'existe juste pas
|
48
|
-
return None
|
49
|
-
elif '_type' not in _data.keys(): # Le vote est un procès
|
50
|
-
_data['_type'] = "lawsuit"
|
51
|
-
|
52
|
-
if _data['_type'] == 'vote':
|
53
|
-
vote = Vote(id, _data['title'])
|
54
|
-
elif _data['_type'] == 'referendum':
|
55
|
-
vote = Referendum(id, _data['title'])
|
56
|
-
vote.choices = []
|
57
|
-
elif _data['_type'] == 'lawsuit':
|
58
|
-
vote = Lawsuit(id, _data['title'])
|
59
|
-
vote.choices = []
|
60
|
-
else:
|
61
|
-
vote = Vote('0', 'Unknown Vote')
|
62
|
-
|
63
|
-
vote.author = _data['author_id']
|
64
|
-
vote.startDate = _data['start_date']
|
65
|
-
vote.endDate = _data['end_date']
|
66
|
-
|
67
|
-
for opt in _data['choices']:
|
68
|
-
option = VoteOption(opt["id"], opt["title"])
|
69
|
-
option.count = opt["count"]
|
70
|
-
|
71
|
-
vote.choices.append(option)
|
72
|
-
|
73
|
-
return vote
|
74
|
-
|
75
|
-
def save_vote(self, vote: Vote | Referendum | Lawsuit):
|
76
|
-
"""
|
77
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
78
|
-
Sauvegarde un vote dans la base de données.
|
79
|
-
|
80
|
-
## Paramètres
|
81
|
-
- vote: `.Vote`\n
|
82
|
-
Vote à sauvegarder
|
83
|
-
"""
|
84
|
-
|
85
|
-
return # Provisoire
|
86
|
-
|
87
|
-
vote.id = NSID(vote.id)
|
88
|
-
|
89
|
-
_data = {
|
90
|
-
'_type':'vote' if type(vote) == Vote else\
|
91
|
-
'referendum' if type(vote) == Referendum else\
|
92
|
-
'lawsuit' if type(vote) == Lawsuit else\
|
93
|
-
'unknown',
|
94
|
-
'id': NSID(vote.id),
|
95
|
-
'title': vote.title,
|
96
|
-
'author_id': NSID(vote.author),
|
97
|
-
'start_date': vote.startDate,
|
98
|
-
'end_date': vote.endDate,
|
99
|
-
'choices': [ opt.__dict__ for opt in vote.choices ]
|
100
|
-
}
|
101
|
-
|
102
|
-
if type(vote) == Lawsuit:
|
103
|
-
del _data['_type']
|
104
|
-
self._put_in_db('lawsuits', _data)
|
105
|
-
else:
|
106
|
-
self._put_in_db('votes', _data)
|
107
|
-
|
108
|
-
# Aucune possibilité de supprimer un vote
|
109
|
-
|
110
|
-
"""
|
111
|
-
---- INSTITUTION & MANDAT ----
|
112
|
-
"""
|
113
|
-
|
114
|
-
def get_official(self, id: NSID, current_mandate: bool = True) -> Official:
|
115
|
-
"""
|
116
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
117
|
-
Récupère les informations d'un fonctionnaire (mandats, contributions).
|
118
|
-
|
119
|
-
## Paramètres
|
120
|
-
id: `NSID`\n
|
121
|
-
ID du fonctionnaire.
|
122
|
-
current_mandate: `bool`\n
|
123
|
-
Indique si l'on doit récupérer le mandat actuel ou les anciens mandats.
|
124
|
-
|
125
|
-
## Renvoie
|
126
|
-
- `.Official`
|
127
|
-
"""
|
128
|
-
|
129
|
-
return Official(NSID(id)) # Provisoire
|
130
|
-
|
131
|
-
id = NSID(id)
|
132
|
-
|
133
|
-
base = 'mandate' if current_mandate else 'archives'
|
134
|
-
|
135
|
-
_contributions = self.fetch(base, author = id, _type = 'contrib')
|
136
|
-
_mandates = self.fetch(base, target = id, _type = 'election') +\
|
137
|
-
self.fetch(base, target = id, _type = 'promotion')
|
138
|
-
|
139
|
-
user = Official(id)
|
140
|
-
for mandate in _mandates:
|
141
|
-
if mandate['details']['position'].startswith('MIN'):
|
142
|
-
mandate['details']['position'] = 'MIN'
|
143
|
-
|
144
|
-
try:
|
145
|
-
user.mandates[mandate['details']['position']] += 1
|
146
|
-
except KeyError:
|
147
|
-
user.mandates[mandate['details']['position']] = 1
|
148
|
-
|
149
|
-
for contrib in _contributions:
|
150
|
-
try:
|
151
|
-
user.contributions[contrib['action']] += 1
|
152
|
-
except KeyError:
|
153
|
-
user.contributions[contrib['action']] = 1
|
154
|
-
|
155
|
-
return user
|
156
|
-
|
157
|
-
def get_institutions(self) -> State:
|
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()
|
164
|
-
|
165
|
-
admin = Administration()
|
166
|
-
gov = Government(Official('0'))
|
167
|
-
assembly = Assembly()
|
168
|
-
court = Court()
|
169
|
-
police_forces = PoliceForces()
|
170
|
-
|
171
|
-
_get_position: list[dict] = lambda pos : self._select_from_db('functions', 'id', pos)[0]['users']
|
172
|
-
|
173
|
-
admin.members = [ self.get_official(user) for user in _get_position('ADMIN') ]
|
174
|
-
admin.president = self.get_official(0xF7DB60DD1C4300A) # happex (remplace Kheops pour l'instant)
|
175
|
-
|
176
|
-
gov.president = self.get_official(0x0)
|
177
|
-
|
178
|
-
minister = lambda code : self.get_official(_get_position(f'MIN_{code}')[0])
|
179
|
-
gov.prime_minister = minister('PRIM')
|
180
|
-
gov.economy_minister = minister('ECO')
|
181
|
-
gov.inner_minister = minister('INN')
|
182
|
-
gov.press_minister = minister('AUD')
|
183
|
-
gov.justice_minister = minister('JUS')
|
184
|
-
gov.outer_minister = minister('OUT')
|
185
|
-
|
186
|
-
assembly.president = self.get_official(_get_position('PRE_AS')[0])
|
187
|
-
assembly.members = [ self.get_official(user) for user in _get_position('REPR') ]
|
188
|
-
|
189
|
-
court.president = gov.justice_minister
|
190
|
-
court.members = [ self.get_official(user) for user in _get_position('JUDGE') ]
|
191
|
-
|
192
|
-
police_forces.president = gov.inner_minister
|
193
|
-
police_forces.members = [ self.get_official(user) for user in _get_position('POLICE') ]
|
194
|
-
|
195
|
-
instits = State()
|
196
|
-
instits.administration = admin
|
197
|
-
instits.government = gov
|
198
|
-
instits.court = court
|
199
|
-
instits.assembly = assembly
|
200
|
-
instits.police = police_forces
|
201
|
-
|
202
|
-
return instits
|
203
|
-
|
204
|
-
def update_institutions(self, institutions: State):
|
205
|
-
"""
|
206
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
207
|
-
Fonction communément appelée après un vote législatif ou une nomination.\n
|
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
|
209
|
-
|
210
|
-
## Paramètres
|
211
|
-
institutions: `.State`\n
|
212
|
-
Le nouvel état des institutions, à sauvegarder.
|
213
|
-
"""
|
214
|
-
|
215
|
-
return # Provisoire
|
216
|
-
|
217
|
-
get_ids = lambda institution : [ member.id for member in institutions.__getattribute__(institution).members ]
|
218
|
-
|
219
|
-
self._put_in_db('functions', { 'id': 'ADMIN', 'users': get_ids('administration') })
|
220
|
-
self._put_in_db('functions', { 'id': 'REPR', 'users': get_ids('assembly') })
|
221
|
-
self._put_in_db('functions', { 'id': 'JUDGE', 'users': get_ids('court') })
|
222
|
-
self._put_in_db('functions', { 'id': 'POLICE', 'users': get_ids('police') })
|
223
|
-
|
224
|
-
self._put_in_db('functions', { 'id': 'PRE_AS', 'users': [ institutions.assembly.president.id ] })
|
225
|
-
self._put_in_db('functions', { 'id': 'PRE_REP', 'users': [ institutions.government.president.id ] })
|
226
|
-
|
227
|
-
self._put_in_db('functions', { 'id': 'MIN_PRIM', 'users': [ institutions.government.prime_minister.id ] })
|
228
|
-
self._put_in_db('functions', { 'id': 'MIN_INN', 'users': [ institutions.government.inner_minister.id ] })
|
229
|
-
self._put_in_db('functions', { 'id': 'MIN_JUS', 'users': [ institutions.government.justice_minister.id ] })
|
230
|
-
self._put_in_db('functions', { 'id': 'MIN_ECO', 'users': [ institutions.government.economy_minister.id ] })
|
231
|
-
self._put_in_db('functions', { 'id': 'MIN_AUD', 'users': [ institutions.government.press_minister.id ] })
|
232
|
-
self._put_in_db('functions', { 'id': 'MIN_OUT', 'users': [ institutions.government.outer_minister.id ] })
|
233
|
-
|
234
|
-
def new_mandate(self, institutions: State, weeks: int = 4):
|
235
|
-
"""
|
236
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
237
|
-
Fonction qui amène à supprimer toutes les archives du mandat précédent
|
238
|
-
|
239
|
-
## Paramètres
|
240
|
-
- institutions: `.State`\n
|
241
|
-
Nouvel État à sauvegarder
|
242
|
-
- weeks: `int`\n
|
243
|
-
Nombre de semaines du mandat
|
244
|
-
"""
|
245
|
-
|
246
|
-
return # Provisoire
|
247
|
-
|
248
|
-
for item in self.fetch('mandate'):
|
249
|
-
if item['date'] >= round(time.time()) - weeks * 604800: # On évite de supprimer les informations écrites lors de la période définie
|
250
|
-
self._delete_by_ID('mandate', item['id'])
|
251
|
-
|
252
|
-
self.update_institutions(institutions)
|
253
|
-
|
254
|
-
"""
|
255
|
-
---- ARCHIVES ----
|
256
|
-
"""
|
257
|
-
|
258
|
-
def _add_archive(self, archive: Archive):
|
259
|
-
"""
|
260
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
261
|
-
Ajoute une archive d'une action (élection, promotion, ou rétrogradation) dans la base de données.
|
262
|
-
|
263
|
-
## Paramètres
|
264
|
-
- archive: `.Archive`\n
|
265
|
-
Archive à ajouter
|
266
|
-
"""
|
267
|
-
|
268
|
-
return # Provisoire
|
269
|
-
|
270
|
-
archive.id = NSID(archive.id)
|
271
|
-
_data = archive.__dict__.copy()
|
272
|
-
|
273
|
-
if type(archive) == Election:
|
274
|
-
_data['_type'] = "election"
|
275
|
-
elif type(archive) == Promotion:
|
276
|
-
_data['_type'] = "promotion"
|
277
|
-
elif type(archive) == Demotion:
|
278
|
-
_data['_type'] = "demotion"
|
279
|
-
else:
|
280
|
-
_data['_type'] = "unknown"
|
281
|
-
|
282
|
-
self._put_in_db('archives', _data)
|
283
|
-
self._put_in_db('mandate', _data) # Ajouter les archives à celle du mandat actuel
|
284
|
-
|
285
|
-
def _get_archive(self, id: NSID) -> Archive | Election | Promotion | Demotion:
|
286
|
-
"""
|
287
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
288
|
-
Récupère une archive spécifique.
|
289
|
-
|
290
|
-
## Paramètres
|
291
|
-
id: `NSID`\n
|
292
|
-
ID de l'archive.
|
293
|
-
|
294
|
-
## Renvoie
|
295
|
-
- `.Archive | .Election | .Promotion | .Demotion`
|
296
|
-
"""
|
297
|
-
|
298
|
-
return Archive(NSID(id)) # Provisoire
|
299
|
-
|
300
|
-
id = NSID(id)
|
301
|
-
_data = self._get_by_ID('archives', id)
|
302
|
-
|
303
|
-
if _data is None:
|
304
|
-
return None
|
305
|
-
|
306
|
-
if _data['_type'] == "election":
|
307
|
-
archive = Election(_data['author'], _data['target'], _data['details']['position'])
|
308
|
-
elif _data['_type'] == "promotion":
|
309
|
-
archive = Promotion(_data['author'], _data['target'], _data['details']['position'])
|
310
|
-
elif _data['_type'] == "demotion":
|
311
|
-
archive = Demotion(_data['author'], _data['target'])
|
312
|
-
else:
|
313
|
-
archive = Archive(_data['author'], _data['target'])
|
314
|
-
|
315
|
-
archive.id = id
|
316
|
-
archive.action = _data['action']
|
317
|
-
archive.date = _data['date']
|
318
|
-
archive.details = _data['details']
|
319
|
-
|
320
|
-
return archive
|
321
|
-
|
322
|
-
def _fetch_archives(self, **query) -> list[ Archive | Election | Promotion | Demotion ]:
|
323
|
-
"""
|
324
|
-
*INDISPONIBLE DANS CETTE VERSION.*\n
|
325
|
-
Récupère une liste d'archives correspondant à la requête.
|
326
|
-
|
327
|
-
## Paramètres
|
328
|
-
query: `dict`\n
|
329
|
-
Requête pour filtrer les archives.
|
330
|
-
|
331
|
-
## Renvoie
|
332
|
-
- `list[.Archive | .Election | .Promotion | .Demotion]`
|
333
|
-
"""
|
334
|
-
|
335
|
-
return [] # Provisoire
|
336
|
-
|
337
|
-
_res = self.fetch('archives', **query)
|
338
|
-
|
339
|
-
return [ self._get_archive(archive['id']) for archive in _res ]
|
@@ -1,15 +0,0 @@
|
|
1
|
-
nsarchive/__init__.py,sha256=mGEv74tD1yb0EB42ZYXfiJWX_FxE6raf8LH0lJLDkNk,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=ley35D1i0RTfX_lmPoyC_PICG40UQtLj5zizRWjUwpM,8034
|
5
|
-
nsarchive/cls/economy.py,sha256=Ap6nhnArieHroHi9zTHUKQgYscLhByNcI74QQ1Fno9c,6992
|
6
|
-
nsarchive/cls/entities.py,sha256=HcfKydEMqmLkBvoIY2DRGK0PO_6ic5WK826VHaUwyjI,14428
|
7
|
-
nsarchive/cls/republic.py,sha256=16NFNCkJxOeVRd6BoJ68AlrTESQgRfZ5FSFlNWTEdK0,4103
|
8
|
-
nsarchive/instances/_economy.py,sha256=vMK8nRBHjLWmAmTu1f3XkWimFUk8tuV3P9KIuKRdNpw,9596
|
9
|
-
nsarchive/instances/_entities.py,sha256=pYNoGyYg-I6QDtY3swFb2_rNm2FemG2S5ouYkZLidLE,9327
|
10
|
-
nsarchive/instances/_republic.py,sha256=M8k2rZJvQGzOyZlmqRDiB-d615hZOqD3kuRrgYP4JqA,12004
|
11
|
-
nsarchive/utils.py,sha256=L37Dm8aO0Sm3FDLPf2tP6fo-1lodDq7JIz-WXttNuJg,684
|
12
|
-
nsarchive-3.0.0a6.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
13
|
-
nsarchive-3.0.0a6.dist-info/METADATA,sha256=XiRacmzL8zP5XMgUMTzWRG8nZoAF5mma6LGzmW6rrlI,695
|
14
|
-
nsarchive-3.0.0a6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
15
|
-
nsarchive-3.0.0a6.dist-info/RECORD,,
|
File without changes
|