nsarchive 0.0.9a0__py3-none-any.whl → 0.1b0__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 CHANGED
@@ -4,7 +4,7 @@ import deta
4
4
 
5
5
  from .cls.entities import *
6
6
  from .cls.archives import *
7
- from .cls.votes import *
7
+ from .cls.republic import *
8
8
  from .cls.bank import *
9
9
 
10
10
  from .cls.exceptions import *
@@ -15,6 +15,7 @@ class EntityInstance:
15
15
  self.base = self.db.Base('entities')
16
16
  self.electors = self.db.Base('electors')
17
17
  self.archives = self.db.Base('archives')
18
+ self.avatars = self.db.Drive('avatars')
18
19
 
19
20
  def get_entity(self, id: str) -> User | Organization | Entity:
20
21
  id = id.upper()
@@ -25,26 +26,27 @@ class EntityInstance:
25
26
 
26
27
  if _data['_type'] == 'user':
27
28
  entity = User(id)
29
+
30
+ entity.xp = _data['xp']
31
+ entity.boosts = _data['boosts']
28
32
  elif _data['_type'] == 'organization':
29
33
  entity = Organization(id)
30
- else:
31
- entity = Entity(id)
32
34
 
33
- entity.name = _data['name']
34
- entity.legalPosition = _data['legalPosition'] # Métier si c'est un utilisateur, domaine professionnel si c'est un collectif
35
- entity.registerDate = _data['registerDate']
36
- entity.xp = _data['xp']
37
-
38
- if type(entity) == Organization:
39
35
  entity.owner = self.get_entity(_data['owner_id'].upper())
40
36
  entity.members = [
41
37
  self.get_entity(_id) for _id in _data['members']
42
38
  ]
43
39
 
40
+ entity.avatar = self.avatars.get(id).read()
41
+
44
42
  entity.certifications = _data['certifications']
45
- elif type(entity) == User:
46
- entity.boosts = _data['boosts']
47
-
43
+ else:
44
+ entity = Entity(id)
45
+
46
+ entity.name = _data['name']
47
+ entity.legalPosition = _data['legalPosition'] # Métier si c'est un utilisateur, domaine professionnel si c'est un collectif
48
+ entity.registerDate = _data['registerDate']
49
+
48
50
  return entity
49
51
 
50
52
  def save_entity(self, entity: Entity) -> None:
@@ -53,15 +55,17 @@ class EntityInstance:
53
55
  '_type': 'user' if type(entity) == User else 'organization' if type(entity) == Organization else 'unknown',
54
56
  'name': entity.name,
55
57
  'legalPosition': entity.legalPosition,
56
- 'registerDate': entity.registerDate,
57
- 'xp': entity.xp
58
+ 'registerDate': entity.registerDate
58
59
  }
59
60
 
60
61
  if type(entity) == Organization:
61
62
  _data['owner_id'] = entity.owner.id.upper() if entity.owner else "0"
62
63
  _data['members'] = [ member.id.upper() for member in entity.members ] if entity.members else []
63
- _data['certifications'] = entity.certifications
64
+ _data['certifications'] = entity.certifications
65
+
66
+ self.avatars.put(name = entity.id, data = entity.avatar)
64
67
  elif type(entity) == User:
68
+ _data['xp'] = entity.xp
65
69
  _data['boosts'] = entity.boosts
66
70
 
67
71
  _base.put(_data, entity.id.upper(), expire_in = 3 * 31536000) # Données supprimées tous les trois ans
@@ -69,6 +73,9 @@ class EntityInstance:
69
73
  def delete_entity(self, entity: Entity) -> None:
70
74
  self.base.delete(entity.id.upper())
71
75
 
76
+ if type(entity) == Organization:
77
+ self.avatars.delete(entity.id.upper())
78
+
72
79
  def get_elector(self, id: str) -> Elector:
73
80
  id = id.upper()
74
81
  _data = self.electors.get(id)
@@ -88,8 +95,11 @@ class EntityInstance:
88
95
  }
89
96
 
90
97
  self.electors.put(_data, elector.id.upper())
98
+
99
+ # Les archives ne permettent pas de garder une trace des votes
100
+ # Donc je préfère aucune fonction permettant de les supprimer
91
101
 
92
- def fetch(self, query = None, listquery: dict | None = None) -> list:
102
+ def fetch_entities(self, query = None, listquery: dict | None = None) -> list[Entity | User | Organization]:
93
103
  _res = self.base.fetch(query).items
94
104
 
95
105
  if listquery is not None:
@@ -98,17 +108,17 @@ class EntityInstance:
98
108
  if value not in item[target]:
99
109
  _res.remove(item)
100
110
 
101
- return _res
111
+ return [ self.get_entity(entity['key']) for entity in _res ]
102
112
 
103
113
  def get_entity_groups(self, id: str) -> list[Organization]:
104
- groups = self.fetch({'_type': 'organization'}, {'members': id})
114
+ groups = self.fetch_entities({'_type': 'organization'}, {'members': id})
105
115
 
106
116
  return [ self.get_entity(group['key']) for group in groups ]
107
117
 
108
118
  def _add_archive(self, archive: Action):
109
119
  _data = archive.__dict__.copy()
110
120
 
111
- if type(archive) == ModAction:
121
+ if type(archive) == Sanction:
112
122
  _data['type'] = "sanction"
113
123
  elif type(archive) == AdminAction:
114
124
  _data['type'] = "adminaction"
@@ -119,37 +129,44 @@ class EntityInstance:
119
129
 
120
130
  self.archives.put(key = archive.id, data = _data)
121
131
 
122
- def _get_archive(self, id: str) -> Action | ModAction | AdminAction:
132
+ def _get_archive(self, id: str) -> Action | Sanction | AdminAction:
123
133
  _data = self.archives.get(id)
124
134
 
125
135
  if _data is None:
126
136
  return None
127
137
 
128
138
  if _data['type'] == "sanction": # Mute, ban, GAV, kick, détention, prune (xp seulement)
129
- archive = ModAction(id, _data['author'], _data['target'])
139
+ archive = Sanction(_data['author'], _data['target'])
130
140
 
131
141
  archive.details = _data['details']
132
142
  archive.major = _data['major']
133
143
  archive.duration = _data['duration']
134
- elif _data['type'] == "adminaction": # Renommage, promotion, démotion
135
- archive = AdminAction(id, _data['author'], _data['target'])
144
+ elif _data['type'] == "adminaction": # Renommage, promotion, démotion (au niveau de l'état)
145
+ archive = AdminAction(_data['author'], _data['target'])
136
146
 
137
147
  archive.details = _data['details']
138
148
  archive.new_state = _data['new_state']
139
149
  else:
140
- archive = Action(id, _data['author'], _data['target'])
150
+ archive = Action(_data['author'], _data['target'])
141
151
 
152
+ archive.id = id
142
153
  archive.action = _data['action']
143
154
  archive.date = _data['date']
144
155
 
145
156
  return archive
146
157
 
158
+ def _fetch_archives(self, **query) -> list[ Action | Sanction | AdminAction ]:
159
+ _res = self.archives.fetch(query).items
160
+
161
+ return [ self._get_archive(archive['key']) for archive in _res ]
162
+
147
163
  class RepublicInstance:
148
164
  def __init__(self, token: str) -> None:
149
165
  self.db = deta.Deta(token)
150
166
  self.votes = self.db.Base('votes')
151
167
  self.archives = self.db.Base('archives')
152
- self.functions = self.db.base('functions') # Liste des fonctionnaires
168
+ self.mandate = self.db.Base('mandate')
169
+ self.functions = self.db.Base('functions') # Liste des fonctionnaires
153
170
 
154
171
  def get_vote(self, id: str) -> Vote | ClosedVote:
155
172
  id = id.upper()
@@ -184,6 +201,94 @@ class RepublicInstance:
184
201
 
185
202
  self.votes.put(_data, vote.id.upper())
186
203
 
204
+ def get_official(self, id: str, current_mandate: bool = True) -> FunctionalUser:
205
+ archives = self.mandate if current_mandate else self.archives
206
+
207
+ _contributions = archives.fetch({'author': id, 'type': 'contrib'}).items
208
+ _mandates = archives.fetch({'target': id, 'type': 'election'}).items()\
209
+ + archives.fetch({'target': id, 'type': 'promotion'}).items()
210
+
211
+ user = FunctionalUser(id)
212
+ for mandate in _mandates:
213
+ if mandate['position'].startswith('MIN'): mandate['position'] = 'MIN'
214
+
215
+ try:
216
+ user.mandates[mandate['position']] += 1
217
+ except KeyError:
218
+ user.mandates[mandate['position']] = 1
219
+
220
+ for contrib in _contributions:
221
+ try:
222
+ user.contributions[contrib['action']] += 1
223
+ except KeyError:
224
+ user.contributions[contrib['action']] = 1
225
+
226
+ return user
227
+
228
+ def get_institutions(self) -> Organization:
229
+ admin = Administration()
230
+ gov = Government(FunctionalUser('0'))
231
+ assembly = Assembly()
232
+ court = Court()
233
+ police_forces = PoliceForces()
234
+
235
+ _admins = self.functions.get('ADMIN')
236
+ admin.members = [ self.get_official(user) for user in _admins['users'] ]
237
+ admin.president = self.get_official('F7DB60DD1C4300A') # happex (remplace Kheops pour l'instant)
238
+
239
+ gov.president = self.get_official(self.functions.get('PRE_REP')['users'][0])
240
+
241
+ minister = lambda code : self.get_official(self.functions.get(f'MIN_{code}')['users'][0])
242
+ gov.prime_minister = minister('PRIM')
243
+ gov.economy_minister = minister('ECO')
244
+ gov.inner_minister = minister('INN')
245
+ gov.press_minister = minister('AUD')
246
+ gov.justice_minister = minister('JUS')
247
+ gov.outer_minister = minister('OUT')
248
+
249
+ assembly.president = self.get_official(self.functions.get('PRE_AS')['users'][0])
250
+ assembly.members = [ self.get_official(id) for id in self.functions.get('REPR')['users'] ]
251
+
252
+ court.president = gov.justice_minister
253
+ court.members = [ self.get_official(id) for id in self.functions.get('JUDGE')['users'] ]
254
+
255
+ police_forces.president = gov.inner_minister
256
+ police_forces.members = [ self.get_official(id) for id in self.functions.get('POLICE')['users'] ]
257
+
258
+ instits = Institutions()
259
+ instits.administration = admin
260
+ instits.government = gov
261
+ instits.court = court
262
+ instits.assembly = assembly
263
+ instits.police = police_forces
264
+
265
+ return instits
266
+
267
+ def update_institutions(self, institutions: Institutions):
268
+ get_ids = lambda institution : [ member.id for member in institutions.__getattribute__(institution).members ]
269
+
270
+ self.functions.put(key = 'ADMIN', data = { 'users': get_ids('administration') })
271
+ self.functions.put(key = 'REPR', data = { 'users': get_ids('assembly') })
272
+ self.functions.put(key = 'JUDGE', data = { 'users': get_ids('court') })
273
+ self.functions.put(key = 'POLICE', data = { 'users': get_ids('police') })
274
+
275
+ self.functions.put(key = 'PRE_AS', data = { 'users': [ institutions.assembly.president.id ] })
276
+ self.functions.put(key = 'PRE_REP', data = { 'users': [ institutions.government.president.id ] })
277
+
278
+ self.functions.put(key = 'MIN_PRIM', data = { 'users': [ institutions.government.prime_minister.id ] })
279
+ self.functions.put(key = 'MIN_INN', data = { 'users': [ institutions.government.inner_minister.id ] })
280
+ self.functions.put(key = 'MIN_JUS', data = { 'users': [ institutions.government.justice_minister.id ] })
281
+ self.functions.put(key = 'MIN_ECO', data = { 'users': [ institutions.government.economy_minister.id ] })
282
+ self.functions.put(key = 'MIN_AUD', data = { 'users': [ institutions.government.press_minister.id ] })
283
+ self.functions.put(key = 'MIN_OUT', data = { 'users': [ institutions.government.outer_minister.id ] })
284
+
285
+ def new_mandate(self, institutions: Institutions, weeks: int = 4):
286
+ for item in self.mandate.fetch().items():
287
+ if item['date'] >= round(time.time()) - weeks * 604800:
288
+ self.mandate.delete(item['id'])
289
+
290
+ self.update_institutions(institutions)
291
+
187
292
  def _add_archive(self, archive: Action):
188
293
  _data = archive.__dict__.copy()
189
294
 
@@ -207,22 +312,29 @@ class RepublicInstance:
207
312
  return None
208
313
 
209
314
  if _data['type'] == "election":
210
- archive = Election(id, _data['author'], _data['target'], _data['position'])
315
+ archive = Election(_data['author'], _data['target'], _data['position'])
211
316
 
212
317
  archive.positive_votes = _data['positive_votes']
213
318
  archive.total_votes = _data['total_votes']
214
- elif _data['type'] == "adminaction": # Renommage, promotion, démotion
215
- archive = AdminAction(id, _data['author'], _data['target'])
319
+ elif _data['type'] == "promotion":
320
+ archive = Promotion(_data['author'], _data['target'], _data['position'])
321
+ elif _data['type'] == "demotion":
322
+ archive = Demotion(_data['author'], _data['target'])
216
323
 
217
- archive.details = _data['details']
218
- archive.new_state = _data['new_state']
324
+ archive.reason = _data['reason']
219
325
  else:
220
- archive = Action(id, _data['author'], _data['target'])
326
+ archive = Action(_data['author'], _data['target'])
221
327
 
328
+ archive.id = id
222
329
  archive.action = _data['action']
223
330
  archive.date = _data['date']
224
331
 
225
332
  return archive
333
+
334
+ def _fetch_archives(self, **query) -> list[ Action | Election | Promotion | Demotion ]:
335
+ _res = self.archives.fetch(query).items
336
+
337
+ return [ self._get_archive(archive['key']) for archive in _res ]
226
338
 
227
339
  class BankInstance:
228
340
  def __init__(self, token: str) -> None:
@@ -255,6 +367,11 @@ class BankInstance:
255
367
  }
256
368
 
257
369
  self.accounts.put(_data, acc.id.upper())
370
+
371
+ def lock_account(self, acc: BankAccount):
372
+ acc.locked = True
373
+
374
+ self.save_account(acc)
258
375
 
259
376
  def _add_archive(self, _archive: Action):
260
377
  _data = _archive.__dict__.copy()
@@ -275,14 +392,20 @@ class BankInstance:
275
392
  return None
276
393
 
277
394
  if _data['type'] == "transaction":
278
- archive = Transaction(id, _data['author'], _data['target'], _data['amount'])
395
+ archive = Transaction(_data['author'], _data['target'], _data['amount'])
279
396
 
280
397
  archive.reason = _data['reason']
281
398
  archive.currency = _data['currency']
282
399
  else:
283
- archive = Action(id, _data['author'], _data['target'])
400
+ archive = Action(_data['author'], _data['target'])
284
401
 
402
+ archive.id = id
285
403
  archive.action = _data['action']
286
404
  archive.date = _data['date']
287
405
 
288
- return archive
406
+ return archive
407
+
408
+ def _fetch_archives(self, **query) -> list[ Action | Transaction ]:
409
+ _res = self.archives.fetch(query).items
410
+
411
+ return [ self._get_archive(archive['key']) for archive in _res ]
Binary file
nsarchive/cls/archives.py CHANGED
@@ -1,23 +1,28 @@
1
+ import time
2
+
1
3
  class Action:
2
- def __init__(self, id: str, author: str = '11625D9061021010', target: str = '0') -> None:
3
- self.id: str = id
4
- self.date: int = 0
4
+ def __init__(self, author: str = '11625D9061021010', target: str = '0') -> None:
5
+ self.id: str = hex(round(time.time()))[2:].upper()
6
+ self.date: int = int(self.id, 16)
5
7
  self.action: str = ""
6
8
  self.author: str = author
7
9
  self.target: str = target
8
10
 
11
+
9
12
  # Entities
10
13
 
11
- class ModAction(Action):
12
- def __init__(self, id: str, author: str, target: str) -> None:
13
- super().__init__(id, author, target)
14
+ class Sanction(Action):
15
+ def __init__(self, author: str, target: str) -> None:
16
+ super().__init__(author, target)
17
+
14
18
  self.details: str = ""
15
19
  self.major: bool = False # Sanction majeure ou non
16
20
  self.duration: int = 0 # Durée en secondes, 0 = définitif
17
21
 
18
22
  class AdminAction(Action):
19
- def __init__(self, id: str, author: str, target: str) -> None:
20
- super().__init__(id, author, target)
23
+ def __init__(self, author: str, target: str) -> None:
24
+ super().__init__(author, target)
25
+
21
26
  self.details: str = ""
22
27
  self.new_state: str | int | bool = None
23
28
 
@@ -25,28 +30,31 @@ class AdminAction(Action):
25
30
  # Community
26
31
 
27
32
  class Election(Action):
28
- def __init__(self, id: str, author: str, target: str, position: str) -> None:
29
- super().__init__(id, author, target)
33
+ def __init__(self, author: str, target: str, position: str) -> None:
34
+ super().__init__(author, target)
35
+
30
36
  self.position: str = position
31
37
  self.positive_votes: int = 0
32
38
  self.total_votes: int = 0
33
39
 
34
40
  class Promotion(Action):
35
- def __init__(self, id: str, author: str, target: str, position: str) -> None:
36
- super().__init__(id, author, target)
41
+ def __init__(self, author: str, target: str, position: str) -> None:
42
+ super().__init__(author, target)
43
+
37
44
  self.position: str = position
38
45
 
39
46
  class Demotion(Action):
40
- def __init__(self, id: str, author: str, target: str) -> None:
41
- super().__init__(id, author, target)
47
+ def __init__(self, author: str, target: str) -> None:
48
+ super().__init__(author, target)
49
+
42
50
  self.reason: str = None
43
51
 
44
52
  # Bank
45
53
 
46
54
  class Transaction(Action):
47
- def __init__(self, id: str, author: str, target: str, amount: int) -> None:
48
- super().__init__(id, author, target)
55
+ def __init__(self, author: str, target: str, amount: int) -> None:
56
+ super().__init__(author, target)
49
57
 
50
58
  self.amount: int = amount
51
- self.currency: str = 'XC'
52
- self.reason: str = None
59
+ self.currency: str = 'HC'
60
+ self.reason: str = None
nsarchive/cls/entities.py CHANGED
@@ -1,23 +1,18 @@
1
+ import io
1
2
  import time
2
3
 
3
4
  from .exceptions import *
4
5
 
6
+ from ..utils import assets
7
+
5
8
  class Entity:
6
- def __init__(self, id: str):
7
- self.id: str = id # ID hexadécimal de l'entité
9
+ def __init__(self, id: str) -> None:
10
+ self.id: str = id # ID hexadécimal de l'entité (ou nom dans le cas de l'entreprise)
8
11
  self.name: str = "Entité Inconnue"
9
12
  self.registerDate: int = 0
10
- self.legalPosition: int = 'Normal'
11
- self.xp: int = 0
12
-
13
- def get_level(self) -> None:
14
- i = 0
15
- while self.xp > int(round(25 * (i * 2.5) ** 2, -2)):
16
- i += 1
17
-
18
- return i
13
+ self.legalPosition: str = 'Membre'
19
14
 
20
- def rename(self, new_name: str) -> None:
15
+ def set_name(self, new_name: str) -> None:
21
16
  if len(new_name) > 32:
22
17
  raise NameTooLongError(f"Name length mustn't exceed 32 characters.")
23
18
 
@@ -25,36 +20,80 @@ class Entity:
25
20
 
26
21
  def set_position(self, position: str) -> None:
27
22
  self.legalPosition = position
28
-
29
- def add_xp(self, amount: int) -> None:
30
- boost = 0 if 0 in self.boosts.values() else max(list(self.boosts.values()) + [ 1 ])
31
23
 
32
- self.xp += amount * boost
33
-
34
24
  class User(Entity):
35
- def __init__(self, id: str):
25
+ def __init__(self, id: str) -> None:
36
26
  super().__init__(id)
37
27
 
28
+ self.xp: int = 0
38
29
  self.boosts: dict[str, int] = {}
30
+
31
+ def get_level(self) -> None:
32
+ i = 0
33
+ while self.xp > int(round(25 * (i * 2.5) ** 2, -2)):
34
+ i += 1
35
+
36
+ return i
39
37
 
38
+ def add_xp(self, amount: int) -> None:
39
+ boost = 0 if 0 in self.boosts.values() else max(list(self.boosts.values()) + [ 1 ])
40
+
41
+ self.xp += amount * boost
42
+
40
43
  def edit_boost(self, name: str, multiplier: int = -1) -> None:
41
44
  if multiplier >= 0:
42
45
  self.boosts[name] = multiplier
43
46
  else:
44
47
  del self.boosts[name]
45
48
 
49
+ class MemberPermissions:
50
+ def __init__(self) -> None:
51
+ self.manage_organization = False # Renommer ou changer le logo
52
+ self.manage_members = False # Virer quelqu'un d'une entreprise, l'y inviter, changer ses rôles
53
+ self.manage_roles = False # Promouvoir ou rétrograder les membres
54
+
55
+ def edit(self, **permissions: bool) -> None:
56
+ for perm in permissions.values():
57
+ self.__setattr__(*perm)
58
+
59
+ class GroupMember(User):
60
+ def __init__(self, id: str) -> None:
61
+ super().__init__(id)
62
+
63
+ self.permissions: MemberPermissions = MemberPermissions()
64
+
65
+ class FunctionalUser:
66
+ def __init__(self, id: str) -> None:
67
+ self.id: str = id
68
+
69
+ self.mandates: int = {
70
+ 'PRE_REP': 0, # Président de la République
71
+ 'MIN': 0, # Différents ministres
72
+ 'PRE_AS': 0, # Président de l'Assemblée Nationale
73
+ 'JUDGE': 0, # Juge
74
+ 'REPR': 0 # Député
75
+ }
76
+
77
+ self.contributions: dict = {
78
+ 'project': 0,
79
+ 'approved_project': 0,
80
+ 'admin_action': 0,
81
+ 'law_vote': 0
82
+ }
83
+
46
84
  class Organization(Entity):
47
- def __init__(self, id: str):
85
+ def __init__(self, id: str) -> None:
48
86
  super().__init__(id)
49
87
 
50
88
  self.owner: Entity
51
89
  self.certifications: dict = {}
52
- self.members: list = []
53
-
90
+ self.members: list[GroupMember] = []
91
+ self.avatar: bytes = assets.open('default_avatar.png')
92
+
54
93
  def add_certification(self, certif: str) -> None:
55
94
  self.certifications[certif] = round(time.time())
56
95
 
57
- def add_member(self, member: User) -> None:
96
+ def add_member(self, member: GroupMember) -> None:
58
97
  self.members.append(member)
59
98
 
60
99
  def remove_member(self, member: User) -> None:
@@ -64,27 +103,10 @@ class Organization(Entity):
64
103
  def set_owner(self, member: User) -> None:
65
104
  self.owner = member
66
105
 
106
+ def get_member_id(self) -> list[str]:
107
+ return [ member.id for member in self.members ]
108
+
67
109
  class Elector(User):
68
110
  def __init__(self, id: str) -> None:
69
- self.id: str = id
70
- self.votes: list[str] = []
71
-
72
- class FunctionalUser(User):
73
- def __init__(self, id: str):
74
111
  super().__init__(id)
75
-
76
- self.permissions: dict = {
77
- 'approve_project': False,
78
- 'create_org': False,
79
- 'destroy_gov': False,
80
- 'destroy_org': False,
81
- 'propose_projects': False
82
- }
83
-
84
- self.mandates: int = 0
85
- self.contribs: dict = {
86
- 'projects': 0,
87
- 'approved_projects': 0,
88
- 'admin_actions': 0,
89
- 'law_votes': 0
90
- }
112
+ self.votes: list[str] = []
@@ -8,6 +8,9 @@ class EntityTypeError(Exception):
8
8
  def __init__(self, *args: object) -> None:
9
9
  super().__init__(*args)
10
10
 
11
+ class AvatarTooLongError(Exception):
12
+ def __init__(self, *args: object) -> None:
13
+ super().__init__(*args)
11
14
 
12
15
  # Exceptions pour le vote
13
16
 
@@ -0,0 +1,59 @@
1
+ from .entities import *
2
+
3
+ # Votes
4
+
5
+ class Vote:
6
+ def __init__(self, id: str, title: str, choices: tuple[str]) -> None:
7
+ self.id: str = id
8
+ self.title: str = title
9
+ self.choices = { choice : 0 for choice in choices }
10
+ self.author: str = '0'
11
+ self.startDate: int = 0
12
+ self.endDate: int = 0
13
+
14
+ class ClosedVote(Vote):
15
+ def __init__(self, id: str, title: str) -> None:
16
+ super().__init__(id, title, ('yes', 'no', 'blank'))
17
+
18
+
19
+ # Institutions (defs)
20
+
21
+ class Administration:
22
+ def __init__(self) -> None:
23
+ self.president: FunctionalUser
24
+ self.members: list[FunctionalUser]
25
+
26
+ class Government:
27
+ def __init__(self, president: FunctionalUser) -> None:
28
+ self.president: FunctionalUser = president
29
+ self.prime_minister: FunctionalUser
30
+
31
+ self.inner_minister: FunctionalUser
32
+ self.economy_minister: FunctionalUser
33
+ self.justice_minister: FunctionalUser
34
+ self.press_minister: FunctionalUser
35
+ self.outer_minister: FunctionalUser
36
+
37
+ class Assembly:
38
+ def __init__(self) -> None:
39
+ self.president: FunctionalUser
40
+ self.members: list[FunctionalUser]
41
+
42
+ class Court:
43
+ def __init__(self) -> None:
44
+ self.president: FunctionalUser
45
+ # On discutera de la mise en place d'un potentiel président. Pour l'instant c'est le Ministre de la Justice
46
+ self.members: list[FunctionalUser]
47
+
48
+ class PoliceForces:
49
+ def __init__(self) -> None:
50
+ self.president: FunctionalUser
51
+ self.members: list[FunctionalUser]
52
+
53
+ class Institutions:
54
+ def __init__(self) -> None:
55
+ self.administration: Administration
56
+ self.government: Government
57
+ self.court: Court
58
+ self.assembly: Assembly
59
+ self.police: PoliceForces
@@ -0,0 +1,15 @@
1
+ import io
2
+ import os
3
+ from PIL import Image
4
+
5
+ def open(path: str) -> Image:
6
+ curr_dir = os.path.dirname(os.path.abspath(os.path.join(__file__)))
7
+ parent_dir = os.path.dirname(curr_dir)
8
+ asset_path = os.path.join(parent_dir, 'assets', path)
9
+
10
+ image = Image.open(asset_path)
11
+ val = io.BytesIO()
12
+
13
+ image.save(val, format = 'PNG')
14
+
15
+ return val.getvalue()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nsarchive
3
- Version: 0.0.9a0
3
+ Version: 0.1b0
4
4
  Summary:
5
5
  License: GPL-3.0
6
6
  Author: happex
@@ -76,7 +76,7 @@ entity_instance.save_entity(entity)
76
76
  Vous pouvez rechercher des entités avec des critères spécifiques.
77
77
 
78
78
  ```python
79
- entities = entity_instance.fetch(query = {'name': 'Alice'})
79
+ entities = entity_instance.fetch_entity(query = {'name': 'Alice'})
80
80
  for entity in entities:
81
81
  print(entity['name'])
82
82
  ```
@@ -0,0 +1,12 @@
1
+ nsarchive/__init__.py,sha256=Y-I47MuPc8FIHIhvt8RZ-t5TXAi7APD0XlfEjqevfjk,15273
2
+ nsarchive/assets/default_avatar.png,sha256=n-4vG_WPke8LvbY3ZU6oA-H-OtRoIu7woKnRq9DCIlI,51764
3
+ nsarchive/cls/archives.py,sha256=5C66pXuXAANRXNDqNTvIepRtUrXIWOL7ymmYiBHsHAY,1720
4
+ nsarchive/cls/bank.py,sha256=OactEpRn8PGv7BwnBUbMpzgHqrvv4yx526AMzh9uBO8,220
5
+ nsarchive/cls/entities.py,sha256=u5u46HzHJp2H_DngLALLgedHaLXlJpjhmxU_Ggozp3Q,3474
6
+ nsarchive/cls/exceptions.py,sha256=UZ7G7AFUN5OkKAGpNl1OT7jauF1jC7WW8wWXVFt5sMs,539
7
+ nsarchive/cls/republic.py,sha256=aY79B5PZF5IErwzEjn9ito6T8gXA4trm6LmIeYu6XLM,1821
8
+ nsarchive/utils/assets.py,sha256=hd0STSpa0yT-OJlUyI_wCYXJqcBiUMQds2pZTXNNg9c,382
9
+ nsarchive-0.1b0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
10
+ nsarchive-0.1b0.dist-info/METADATA,sha256=rvpiq-iES71BGQ2r4pUmSPeItUkt0KW6u-XqZExWNXk,5559
11
+ nsarchive-0.1b0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ nsarchive-0.1b0.dist-info/RECORD,,
nsarchive/cls/votes.py DELETED
@@ -1,16 +0,0 @@
1
- import time
2
-
3
- from .entities import FunctionalUser
4
-
5
- class Vote:
6
- def __init__(self, id: str, title: str, choices: tuple[str]) -> None:
7
- self.id: str = id
8
- self.title: str = title
9
- self.choices = { choice : 0 for choice in choices }
10
- self.author: str = '0'
11
- self.startDate: int = 0
12
- self.endDate: int = 0
13
-
14
- class ClosedVote(Vote):
15
- def __init__(self, id: str, title: str) -> None:
16
- super().__init__(id, title, ('yes', 'no', 'blank'))
@@ -1,10 +0,0 @@
1
- nsarchive/__init__.py,sha256=uno-FOUWDtdaMVeufH4C7FuRq8l_dp46EgoJokI-Sm0,9516
2
- nsarchive/cls/archives.py,sha256=FNE8U3IVgjYCUZkBoDqeyQJSHKmRjP2UAzBfmg8nK0M,1735
3
- nsarchive/cls/bank.py,sha256=OactEpRn8PGv7BwnBUbMpzgHqrvv4yx526AMzh9uBO8,220
4
- nsarchive/cls/entities.py,sha256=eY5Fjxt5iixvJCxDnCNbD_lIMq9ojbCLDduPqe52oWM,2556
5
- nsarchive/cls/exceptions.py,sha256=TrH9PvHhVZi7wap9ZfBLGRWJY3OBCYgWAMnco5uadYY,420
6
- nsarchive/cls/votes.py,sha256=q_Y_KcFoqoXWzh_FSWz-1tJH7fGdGJDCORYUOWCtdS8,502
7
- nsarchive-0.0.9a0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
8
- nsarchive-0.0.9a0.dist-info/METADATA,sha256=7piU3_JrfSVGMC12pC02kwbio2JPRqLxyKlRk47bvnE,5554
9
- nsarchive-0.0.9a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
- nsarchive-0.0.9a0.dist-info/RECORD,,