nsarchive 3.0.0b1__py3-none-any.whl → 3.0.0b2__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 +3 -1
- nsarchive/errors/__init__.py +1 -0
- nsarchive/errors/_globals.py +29 -0
- nsarchive/interfaces/_economy.py +0 -252
- nsarchive/interfaces/_entities.py +100 -14
- nsarchive/interfaces/_justice.py +173 -21
- nsarchive/interfaces/_state.py +177 -34
- nsarchive/mandate.py +21 -2
- nsarchive/models/base.py +108 -69
- nsarchive/models/economy.py +80 -151
- nsarchive/models/entities.py +305 -68
- nsarchive/models/justice.py +23 -2
- nsarchive/models/republic.py +44 -4
- nsarchive/models/state.py +43 -4
- nsarchive-3.0.0b2.dist-info/METADATA +90 -0
- nsarchive-3.0.0b2.dist-info/RECORD +21 -0
- nsarchive-3.0.0b1.dist-info/METADATA +0 -21
- nsarchive-3.0.0b1.dist-info/RECORD +0 -19
- {nsarchive-3.0.0b1.dist-info → nsarchive-3.0.0b2.dist-info}/LICENSE +0 -0
- {nsarchive-3.0.0b1.dist-info → nsarchive-3.0.0b2.dist-info}/WHEEL +0 -0
nsarchive/interfaces/_justice.py
CHANGED
@@ -22,11 +22,36 @@ class JusticeInterface(Interface):
|
|
22
22
|
headers = self.default_headers,
|
23
23
|
)
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
|
26
|
+
# ERREURS
|
27
|
+
|
28
|
+
if 500 <= res.status_code < 600:
|
29
|
+
raise errors.globals.ServerDownError()
|
30
|
+
|
31
|
+
_data = res.json()
|
32
|
+
|
33
|
+
if res.status_code == 400:
|
34
|
+
if _data['message'] == "MissingParam":
|
35
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
36
|
+
elif _data['message'] == "InvalidParam":
|
37
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
38
|
+
elif _data['message'] == "InvalidToken":
|
39
|
+
raise errors.globals.AuthError("Token is not valid.")
|
40
|
+
|
41
|
+
elif res.status_code == 401:
|
42
|
+
raise errors.globals.AuthError(_data['message'])
|
43
|
+
|
44
|
+
elif res.status_code == 403:
|
45
|
+
raise errors.globals.PermissionError(_data['message'])
|
46
|
+
|
47
|
+
elif res.status_code == 404:
|
48
|
+
return
|
49
|
+
|
50
|
+
|
51
|
+
# TRAITEMENT
|
27
52
|
|
28
53
|
report = Report(id)
|
29
|
-
report._load(
|
54
|
+
report._load(_data, f"{self.url}/justice/reports/{id}", self.default_headers)
|
30
55
|
|
31
56
|
return report
|
32
57
|
|
@@ -41,14 +66,40 @@ class JusticeInterface(Interface):
|
|
41
66
|
json = payload
|
42
67
|
)
|
43
68
|
|
44
|
-
if res.status_code != 200:
|
45
|
-
res.raise_for_status()
|
46
69
|
|
47
|
-
|
48
|
-
|
70
|
+
# ERREURS
|
71
|
+
|
72
|
+
if 500 <= res.status_code < 600:
|
73
|
+
raise errors.globals.ServerDownError()
|
74
|
+
|
75
|
+
_data = res.json()
|
76
|
+
|
77
|
+
if res.status_code == 400:
|
78
|
+
if _data['message'] == "MissingParam":
|
79
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
80
|
+
elif _data['message'] == "InvalidParam":
|
81
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
82
|
+
elif _data['message'] == "InvalidToken":
|
83
|
+
raise errors.globals.AuthError("Token is not valid.")
|
84
|
+
|
85
|
+
elif res.status_code == 401:
|
86
|
+
raise errors.globals.AuthError(_data['message'])
|
87
|
+
|
88
|
+
elif res.status_code == 403:
|
89
|
+
raise errors.globals.PermissionError(_data['message'])
|
90
|
+
|
91
|
+
elif res.status_code == 404:
|
92
|
+
return
|
93
|
+
|
94
|
+
|
95
|
+
# TRAITEMENT
|
96
|
+
|
97
|
+
report = Report(NSID(_data['id']))
|
98
|
+
report._load(_data, f"{self.url}/justice/reports/{report.id}", self.default_headers)
|
49
99
|
|
50
100
|
return report
|
51
101
|
|
102
|
+
|
52
103
|
"""
|
53
104
|
PROCÈS
|
54
105
|
"""
|
@@ -59,11 +110,36 @@ class JusticeInterface(Interface):
|
|
59
110
|
headers = self.default_headers,
|
60
111
|
)
|
61
112
|
|
62
|
-
|
63
|
-
|
113
|
+
|
114
|
+
# ERREURS
|
115
|
+
|
116
|
+
if 500 <= res.status_code < 600:
|
117
|
+
raise errors.globals.ServerDownError()
|
118
|
+
|
119
|
+
_data = res.json()
|
120
|
+
|
121
|
+
if res.status_code == 400:
|
122
|
+
if _data['message'] == "MissingParam":
|
123
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
124
|
+
elif _data['message'] == "InvalidParam":
|
125
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
126
|
+
elif _data['message'] == "InvalidToken":
|
127
|
+
raise errors.globals.AuthError("Token is not valid.")
|
128
|
+
|
129
|
+
elif res.status_code == 401:
|
130
|
+
raise errors.globals.AuthError(_data['message'])
|
131
|
+
|
132
|
+
elif res.status_code == 403:
|
133
|
+
raise errors.globals.PermissionError(_data['message'])
|
134
|
+
|
135
|
+
elif res.status_code == 404:
|
136
|
+
return
|
137
|
+
|
138
|
+
|
139
|
+
# TRAITEMENT
|
64
140
|
|
65
141
|
lawsuit = Lawsuit(id)
|
66
|
-
lawsuit._load(
|
142
|
+
lawsuit._load(_data, f"{self.url}/justice/lawsuits/{id}", self.default_headers)
|
67
143
|
|
68
144
|
return lawsuit
|
69
145
|
|
@@ -77,14 +153,40 @@ class JusticeInterface(Interface):
|
|
77
153
|
json = payload
|
78
154
|
)
|
79
155
|
|
80
|
-
if res.status_code != 200:
|
81
|
-
res.raise_for_status()
|
82
156
|
|
83
|
-
|
84
|
-
|
157
|
+
# ERREURS
|
158
|
+
|
159
|
+
if 500 <= res.status_code < 600:
|
160
|
+
raise errors.globals.ServerDownError()
|
161
|
+
|
162
|
+
_data = res.json()
|
163
|
+
|
164
|
+
if res.status_code == 400:
|
165
|
+
if _data['message'] == "MissingParam":
|
166
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
167
|
+
elif _data['message'] == "InvalidParam":
|
168
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
169
|
+
elif _data['message'] == "InvalidToken":
|
170
|
+
raise errors.globals.AuthError("Token is not valid.")
|
171
|
+
|
172
|
+
elif res.status_code == 401:
|
173
|
+
raise errors.globals.AuthError(_data['message'])
|
174
|
+
|
175
|
+
elif res.status_code == 403:
|
176
|
+
raise errors.globals.PermissionError(_data['message'])
|
177
|
+
|
178
|
+
elif res.status_code == 404:
|
179
|
+
return
|
180
|
+
|
181
|
+
|
182
|
+
# TRAITEMENT
|
183
|
+
|
184
|
+
lawsuit = Lawsuit(NSID(_data['id']))
|
185
|
+
lawsuit._load(_data, f"{self.url}/justice/lawsuits/{report.id}", self.default_headers)
|
85
186
|
|
86
187
|
return lawsuit
|
87
188
|
|
189
|
+
|
88
190
|
"""
|
89
191
|
SANCTIONS
|
90
192
|
"""
|
@@ -95,11 +197,36 @@ class JusticeInterface(Interface):
|
|
95
197
|
headers = self.default_headers,
|
96
198
|
)
|
97
199
|
|
98
|
-
|
99
|
-
|
200
|
+
|
201
|
+
# ERREURS
|
202
|
+
|
203
|
+
if 500 <= res.status_code < 600:
|
204
|
+
raise errors.globals.ServerDownError()
|
205
|
+
|
206
|
+
_data = res.json()
|
207
|
+
|
208
|
+
if res.status_code == 400:
|
209
|
+
if _data['message'] == "MissingParam":
|
210
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
211
|
+
elif _data['message'] == "InvalidParam":
|
212
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
213
|
+
elif _data['message'] == "InvalidToken":
|
214
|
+
raise errors.globals.AuthError("Token is not valid.")
|
215
|
+
|
216
|
+
elif res.status_code == 401:
|
217
|
+
raise errors.globals.AuthError(_data['message'])
|
218
|
+
|
219
|
+
elif res.status_code == 403:
|
220
|
+
raise errors.globals.PermissionError(_data['message'])
|
221
|
+
|
222
|
+
elif res.status_code == 404:
|
223
|
+
return
|
224
|
+
|
225
|
+
|
226
|
+
# TRAITEMENT
|
100
227
|
|
101
228
|
sanction = Sanction(id)
|
102
|
-
sanction._load(
|
229
|
+
sanction._load(_data, f"{self.url}/justice/sanctions/{id}", self.default_headers)
|
103
230
|
|
104
231
|
return sanction
|
105
232
|
|
@@ -113,10 +240,35 @@ class JusticeInterface(Interface):
|
|
113
240
|
json = payload
|
114
241
|
)
|
115
242
|
|
116
|
-
if res.status_code != 200:
|
117
|
-
res.raise_for_status()
|
118
243
|
|
119
|
-
|
120
|
-
|
244
|
+
# ERREURS
|
245
|
+
|
246
|
+
if 500 <= res.status_code < 600:
|
247
|
+
raise errors.globals.ServerDownError()
|
248
|
+
|
249
|
+
_data = res.json()
|
250
|
+
|
251
|
+
if res.status_code == 400:
|
252
|
+
if _data['message'] == "MissingParam":
|
253
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
254
|
+
elif _data['message'] == "InvalidParam":
|
255
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
256
|
+
elif _data['message'] == "InvalidToken":
|
257
|
+
raise errors.globals.AuthError("Token is not valid.")
|
258
|
+
|
259
|
+
elif res.status_code == 401:
|
260
|
+
raise errors.globals.AuthError(_data['message'])
|
261
|
+
|
262
|
+
elif res.status_code == 403:
|
263
|
+
raise errors.globals.PermissionError(_data['message'])
|
264
|
+
|
265
|
+
elif res.status_code == 404:
|
266
|
+
return
|
267
|
+
|
268
|
+
|
269
|
+
# TRAITEMENT
|
270
|
+
|
271
|
+
sanction = Sanction(NSID(_data['id']))
|
272
|
+
sanction._load(_data, f"{self.url}/justice/sanctions/{sanction.id}", self.default_headers)
|
121
273
|
|
122
274
|
return sanction
|
nsarchive/interfaces/_state.py
CHANGED
@@ -38,17 +38,40 @@ class StateInterface(Interface):
|
|
38
38
|
id = NSID(id)
|
39
39
|
res = requests.get(f"{self.url}/votes/{id}", headers = self.default_headers)
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
# ERREURS
|
43
|
+
|
44
|
+
if 500 <= res.status_code < 600:
|
45
|
+
raise errors.globals.ServerDownError()
|
43
46
|
|
44
47
|
_data = res.json()
|
45
48
|
|
49
|
+
if res.status_code == 400:
|
50
|
+
if _data['message'] == "MissingParam":
|
51
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
52
|
+
elif _data['message'] == "InvalidParam":
|
53
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
54
|
+
elif _data['message'] == "InvalidToken":
|
55
|
+
raise errors.globals.AuthError("Token is not valid.")
|
56
|
+
|
57
|
+
elif res.status_code == 401:
|
58
|
+
raise errors.globals.AuthError(_data['message'])
|
59
|
+
|
60
|
+
elif res.status_code == 403:
|
61
|
+
raise errors.globals.PermissionError(_data['message'])
|
62
|
+
|
63
|
+
elif res.status_code == 404:
|
64
|
+
return
|
65
|
+
|
66
|
+
|
67
|
+
# TRAITEMENT
|
68
|
+
|
46
69
|
vote = Vote(id)
|
47
70
|
vote._load(_data, url = f"{self.url}/votes/{id}", headers = self.default_headers)
|
48
71
|
|
49
72
|
return vote
|
50
73
|
|
51
|
-
def open_vote(self, title: str = None, options: list[dict] = [], end: int =
|
74
|
+
def open_vote(self, title: str = None, options: list[dict] = [], start: int = None, end: int = None) -> Vote:
|
52
75
|
"""
|
53
76
|
Déclenche un vote dans la base de données.
|
54
77
|
|
@@ -57,29 +80,53 @@ class StateInterface(Interface):
|
|
57
80
|
Titre du vote
|
58
81
|
- options: list[dict]\n
|
59
82
|
Liste des choix disponibles
|
60
|
-
-
|
83
|
+
- start: `int` (optionnel)\n
|
84
|
+
Début du vote (timestamp)
|
85
|
+
- end: `int` (optionnel)\n
|
61
86
|
Fin du vote (timestamp)
|
62
87
|
"""
|
63
88
|
|
64
89
|
payload = {
|
65
90
|
"options": options,
|
66
|
-
"end_date": end
|
67
91
|
}
|
68
92
|
|
69
93
|
if title:
|
70
94
|
payload['title'] = title
|
71
95
|
|
72
|
-
res = requests.put(f"{self.url}/open_vote", headers = self.default_headers, json = payload)
|
96
|
+
res = requests.put(f"{self.url}/open_vote?a=b{('&start=' + str(start)) if start else ''}{('&end=' + str(end)) if end else ''}", headers = self.default_headers, json = payload)
|
97
|
+
|
98
|
+
|
99
|
+
# ERREURS
|
100
|
+
|
101
|
+
if 500 <= res.status_code < 600:
|
102
|
+
raise errors.globals.ServerDownError()
|
103
|
+
|
104
|
+
_data = res.json()
|
105
|
+
|
106
|
+
if res.status_code == 400:
|
107
|
+
if _data['message'] == "MissingParam":
|
108
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
109
|
+
elif _data['message'] == "InvalidParam":
|
110
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
111
|
+
elif _data['message'] == "InvalidToken":
|
112
|
+
raise errors.globals.AuthError("Token is not valid.")
|
73
113
|
|
74
|
-
|
75
|
-
|
114
|
+
elif res.status_code == 401:
|
115
|
+
raise errors.globals.AuthError(_data['message'])
|
76
116
|
|
77
|
-
|
78
|
-
|
117
|
+
elif res.status_code == 403:
|
118
|
+
raise errors.globals.PermissionError(_data['message'])
|
79
119
|
|
80
|
-
|
81
|
-
|
82
|
-
|
120
|
+
elif res.status_code == 404:
|
121
|
+
return
|
122
|
+
|
123
|
+
|
124
|
+
# TRAITEMENT
|
125
|
+
|
126
|
+
vote = Vote(_data['id'])
|
127
|
+
vote._load(_data, url = f"{self.url}/votes/{_data['id']}", headers = self.default_headers)
|
128
|
+
|
129
|
+
return vote
|
83
130
|
|
84
131
|
# Aucune possibilité de supprimer un vote
|
85
132
|
|
@@ -98,11 +145,34 @@ class StateInterface(Interface):
|
|
98
145
|
id = NSID(id)
|
99
146
|
res = requests.get(f"{self.url}/elections/{id}", headers = self.default_headers)
|
100
147
|
|
101
|
-
|
102
|
-
|
148
|
+
|
149
|
+
# ERREURS
|
150
|
+
|
151
|
+
if 500 <= res.status_code < 600:
|
152
|
+
raise errors.globals.ServerDownError()
|
103
153
|
|
104
154
|
_data = res.json()
|
105
155
|
|
156
|
+
if res.status_code == 400:
|
157
|
+
if _data['message'] == "MissingParam":
|
158
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
159
|
+
elif _data['message'] == "InvalidParam":
|
160
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
161
|
+
elif _data['message'] == "InvalidToken":
|
162
|
+
raise errors.globals.AuthError("Token is not valid.")
|
163
|
+
|
164
|
+
elif res.status_code == 401:
|
165
|
+
raise errors.globals.AuthError(_data['message'])
|
166
|
+
|
167
|
+
elif res.status_code == 403:
|
168
|
+
raise errors.globals.PermissionError(_data['message'])
|
169
|
+
|
170
|
+
elif res.status_code == 404:
|
171
|
+
return
|
172
|
+
|
173
|
+
|
174
|
+
# TRAITEMENT
|
175
|
+
|
106
176
|
election = Election(id)
|
107
177
|
election._load(_data, url = f"{self.url}/elections/{id}", headers = self.default_headers)
|
108
178
|
|
@@ -123,15 +193,38 @@ class StateInterface(Interface):
|
|
123
193
|
|
124
194
|
res = requests.put(f"{self.url}/open_election?vote={vote.id}&type={'full' if full else 'partial'}{('&date=' + str(start)) if start else ''}", headers = self.default_headers, json = {})
|
125
195
|
|
126
|
-
if res.status_code == 200:
|
127
|
-
_data = res.json()
|
128
196
|
|
129
|
-
|
130
|
-
|
197
|
+
# ERREURS
|
198
|
+
|
199
|
+
if 500 <= res.status_code < 600:
|
200
|
+
raise errors.globals.ServerDownError()
|
131
201
|
|
132
|
-
|
133
|
-
|
134
|
-
|
202
|
+
_data = res.json()
|
203
|
+
|
204
|
+
if res.status_code == 400:
|
205
|
+
if _data['message'] == "MissingParam":
|
206
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
207
|
+
elif _data['message'] == "InvalidParam":
|
208
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
209
|
+
elif _data['message'] == "InvalidToken":
|
210
|
+
raise errors.globals.AuthError("Token is not valid.")
|
211
|
+
|
212
|
+
elif res.status_code == 401:
|
213
|
+
raise errors.globals.AuthError(_data['message'])
|
214
|
+
|
215
|
+
elif res.status_code == 403:
|
216
|
+
raise errors.globals.PermissionError(_data['message'])
|
217
|
+
|
218
|
+
elif res.status_code == 404:
|
219
|
+
return
|
220
|
+
|
221
|
+
|
222
|
+
# TRAITEMENT
|
223
|
+
|
224
|
+
election = Election(_data['id'])
|
225
|
+
election._load(_data, url = f"{self.url}/elections/{_data['id']}", headers = self.default_headers)
|
226
|
+
|
227
|
+
return election
|
135
228
|
|
136
229
|
"""
|
137
230
|
PARTIS
|
@@ -152,11 +245,34 @@ class StateInterface(Interface):
|
|
152
245
|
id = NSID(id)
|
153
246
|
res = requests.get(f"{self.url}/parties/{id}", headers = self.default_headers)
|
154
247
|
|
155
|
-
|
156
|
-
|
248
|
+
|
249
|
+
# ERREURS
|
250
|
+
|
251
|
+
if 500 <= res.status_code < 600:
|
252
|
+
raise errors.globals.ServerDownError()
|
157
253
|
|
158
254
|
_data = res.json()
|
159
255
|
|
256
|
+
if res.status_code == 400:
|
257
|
+
if _data['message'] == "MissingParam":
|
258
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
259
|
+
elif _data['message'] == "InvalidParam":
|
260
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
261
|
+
elif _data['message'] == "InvalidToken":
|
262
|
+
raise errors.globals.AuthError("Token is not valid.")
|
263
|
+
|
264
|
+
elif res.status_code == 401:
|
265
|
+
raise errors.globals.AuthError(_data['message'])
|
266
|
+
|
267
|
+
elif res.status_code == 403:
|
268
|
+
raise errors.globals.PermissionError(_data['message'])
|
269
|
+
|
270
|
+
elif res.status_code == 404:
|
271
|
+
return
|
272
|
+
|
273
|
+
|
274
|
+
# TRAITEMENT
|
275
|
+
|
160
276
|
party = Party(id)
|
161
277
|
party._load(_data, url = f"{self.url}/parties/{id}", headers = self.default_headers)
|
162
278
|
|
@@ -173,24 +289,51 @@ class StateInterface(Interface):
|
|
173
289
|
Couleur du parti
|
174
290
|
- motto: `str, optional`\n
|
175
291
|
Devise du parti
|
176
|
-
-
|
292
|
+
- scale: `.Scale`\n
|
177
293
|
Résultats du parti au test Politiscales
|
178
294
|
"""
|
179
295
|
|
180
296
|
payload = {
|
181
297
|
"color": color,
|
182
298
|
"motto": motto,
|
183
|
-
"scale":
|
299
|
+
"scale": {}
|
300
|
+
}
|
301
|
+
|
302
|
+
params = {
|
303
|
+
"candidate": id
|
184
304
|
}
|
185
305
|
|
186
|
-
res = requests.put(f"{self.url}/register_party
|
306
|
+
res = requests.put(f"{self.url}/register_party", headers = self.default_headers, params = params, json = payload)
|
307
|
+
|
308
|
+
|
309
|
+
# ERREURS
|
310
|
+
|
311
|
+
if 500 <= res.status_code < 600:
|
312
|
+
raise errors.globals.ServerDownError()
|
313
|
+
|
314
|
+
_data = res.json()
|
315
|
+
|
316
|
+
if res.status_code == 400:
|
317
|
+
if _data['message'] == "MissingParam":
|
318
|
+
raise errors.globals.MissingParamError(f"Missing parameter '{_data['param']}'.")
|
319
|
+
elif _data['message'] == "InvalidParam":
|
320
|
+
raise errors.globals.InvalidParamError(f"Invalid parameter '{_data['param']}'.")
|
321
|
+
elif _data['message'] == "InvalidToken":
|
322
|
+
raise errors.globals.AuthError("Token is not valid.")
|
323
|
+
|
324
|
+
elif res.status_code == 401:
|
325
|
+
raise errors.globals.AuthError(_data['message'])
|
326
|
+
|
327
|
+
elif res.status_code == 403:
|
328
|
+
raise errors.globals.PermissionError(_data['message'])
|
329
|
+
|
330
|
+
elif res.status_code == 404:
|
331
|
+
return
|
332
|
+
|
187
333
|
|
188
|
-
|
189
|
-
_data = res.json()
|
334
|
+
# TRAITEMENT
|
190
335
|
|
191
|
-
|
192
|
-
|
336
|
+
party = Party(_data['org_id'])
|
337
|
+
party._load(_data, url = f"{self.url}/parties/{_data['org_id']}", headers = self.default_headers)
|
193
338
|
|
194
|
-
|
195
|
-
else:
|
196
|
-
res.raise_for_status()
|
339
|
+
return party
|
nsarchive/mandate.py
CHANGED
@@ -5,7 +5,7 @@ EPOCH = 1577833200 # 1er Janvier 2020
|
|
5
5
|
PATIENTAGE_DATE = 1725141600 # 1er Septembre 2024
|
6
6
|
OPEN_DATE = 1756677600 # 1er Septembre 2025
|
7
7
|
|
8
|
-
MANDATE_DURATION = 2419200
|
8
|
+
MANDATE_DURATION = 2419200 # 28 jours
|
9
9
|
|
10
10
|
def get_cycle(ts: int = round(time.time())):
|
11
11
|
if EPOCH <= ts < PATIENTAGE_DATE:
|
@@ -47,4 +47,23 @@ def get_phase(ts: int = round(time.time())) -> str:
|
|
47
47
|
return 'elections' # Élections législatives et présidentielles
|
48
48
|
|
49
49
|
else:
|
50
|
-
raise ValueError(f"Idk what happened but it seems that {day} is greater than 55...")
|
50
|
+
raise ValueError(f"Idk what happened but it seems that {day} is greater than 55...")
|
51
|
+
|
52
|
+
|
53
|
+
def next_election(type: str = 'partial') -> int:
|
54
|
+
if get_cycle() == 1:
|
55
|
+
return PATIENTAGE_DATE
|
56
|
+
elif get_cycle() == 2:
|
57
|
+
return OPEN_DATE
|
58
|
+
else:
|
59
|
+
if type == 'partial':
|
60
|
+
ts = OPEN_DATE + get_cycle() * MANDATE_DURATION
|
61
|
+
elif type == 'full':
|
62
|
+
ts = OPEN_DATE + get_cycle() * MANDATE_DURATION
|
63
|
+
|
64
|
+
if get_cycle() % 2 == 1:
|
65
|
+
ts += 28 * 86400
|
66
|
+
|
67
|
+
ts = round(ts / 86400) * 86400
|
68
|
+
|
69
|
+
return ts
|