nsarchive 2.0.0a4__py3-none-any.whl → 2.0.0a6__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 +1 -0
- nsarchive/cls/base.py +7 -6
- nsarchive/cls/economy.py +10 -7
- nsarchive/cls/entities.py +2 -2
- nsarchive/cls/republic.py +1 -1
- nsarchive/instances/_economy.py +61 -14
- nsarchive/instances/_entities.py +3 -3
- nsarchive/instances/_republic.py +7 -7
- {nsarchive-2.0.0a4.dist-info → nsarchive-2.0.0a6.dist-info}/METADATA +1 -1
- nsarchive-2.0.0a6.dist-info/RECORD +16 -0
- nsarchive-2.0.0a4.dist-info/RECORD +0 -16
- {nsarchive-2.0.0a4.dist-info → nsarchive-2.0.0a6.dist-info}/LICENSE +0 -0
- {nsarchive-2.0.0a4.dist-info → nsarchive-2.0.0a6.dist-info}/WHEEL +0 -0
nsarchive/__init__.py
CHANGED
nsarchive/cls/base.py
CHANGED
@@ -113,12 +113,13 @@ class Instance:
|
|
113
113
|
|
114
114
|
for key, value in query.items():
|
115
115
|
entity = self._select_from_db(table, key, value)
|
116
|
-
if entity is not None: matches.append(entity[0])
|
117
116
|
|
118
|
-
|
117
|
+
if entity is not None:
|
118
|
+
matches.append(entity)
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
_res.append(item)
|
120
|
+
if not matches or len(matches) != len(query):
|
121
|
+
return []
|
123
122
|
|
124
|
-
|
123
|
+
_res = [ item for item in matches[0] if all(item in match for match in matches[1:]) ]
|
124
|
+
|
125
|
+
return _res
|
nsarchive/cls/economy.py
CHANGED
@@ -19,17 +19,20 @@ class Item:
|
|
19
19
|
class Inventory:
|
20
20
|
def __init__(self, owner_id: NSID) -> None:
|
21
21
|
self.owner_id: NSID = NSID(owner_id)
|
22
|
-
self.objects:
|
22
|
+
self.objects: dict[str, NSID] = {}
|
23
23
|
|
24
24
|
def append(self, item: Item, quantity: int = 1):
|
25
|
-
self.objects.
|
25
|
+
if item.id in self.objects.keys():
|
26
|
+
self.objects[item.id] += quantity
|
27
|
+
else:
|
28
|
+
self.objects[item.id] = quantity
|
26
29
|
|
27
30
|
def throw(self, item: Item, quantity: int = 1):
|
28
|
-
if
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
if item.id in self.objects.keys():
|
32
|
+
if self.objects[item.id] > quantity:
|
33
|
+
self.objects[item.id] -= quantity
|
34
|
+
else:
|
35
|
+
self.objects[item.id] = 0
|
33
36
|
|
34
37
|
class Sale:
|
35
38
|
def __init__(self, id: NSID, item: Item) -> None:
|
nsarchive/cls/entities.py
CHANGED
@@ -43,7 +43,7 @@ class Entity:
|
|
43
43
|
self.id: NSID = NSID(id) # ID hexadécimal de l'entité (ou nom dans le cas de l'entreprise)
|
44
44
|
self.name: str = "Entité Inconnue"
|
45
45
|
self.registerDate: int = 0
|
46
|
-
self.
|
46
|
+
self.position: Position = Position()
|
47
47
|
self.additional: dict = {}
|
48
48
|
|
49
49
|
def set_name(self, new_name: str) -> None:
|
@@ -53,7 +53,7 @@ class Entity:
|
|
53
53
|
self.name = new_name
|
54
54
|
|
55
55
|
def set_position(self, position: str) -> None:
|
56
|
-
self.
|
56
|
+
self.position = position
|
57
57
|
|
58
58
|
def add_link(self, key: str, value: str | int) -> None:
|
59
59
|
if isinstance(value, str) or isinstance(value, int):
|
nsarchive/cls/republic.py
CHANGED
@@ -11,7 +11,7 @@ class Vote:
|
|
11
11
|
self.startDate: int = 0
|
12
12
|
self.endDate: int = 0
|
13
13
|
|
14
|
-
class
|
14
|
+
class Referendum(Vote):
|
15
15
|
def __init__(self, id: str | NSID, title: str) -> None:
|
16
16
|
super().__init__(id, title, ('yes', 'no', 'blank'))
|
17
17
|
|
nsarchive/instances/_economy.py
CHANGED
@@ -39,8 +39,9 @@ class EconomyInstance(Instance):
|
|
39
39
|
account = BankAccount(id)
|
40
40
|
account.amount = _data['amount']
|
41
41
|
account.frozen = _data['frozen']
|
42
|
-
account.owner = _data['owner_id']
|
42
|
+
account.owner = NSID(_data['owner_id'])
|
43
43
|
account.bank = _data['bank']
|
44
|
+
account.income = _data['income']
|
44
45
|
|
45
46
|
return account
|
46
47
|
|
@@ -52,7 +53,8 @@ class EconomyInstance(Instance):
|
|
52
53
|
'amount': account.amount,
|
53
54
|
'frozen': account.frozen,
|
54
55
|
'owner_id': account.owner,
|
55
|
-
'bank': account.bank
|
56
|
+
'bank': account.bank,
|
57
|
+
'income': account.income
|
56
58
|
}
|
57
59
|
|
58
60
|
self._put_in_db('accounts', _data)
|
@@ -66,19 +68,66 @@ class EconomyInstance(Instance):
|
|
66
68
|
self.save_account(account)
|
67
69
|
|
68
70
|
"""
|
69
|
-
---- VENTES ----
|
71
|
+
---- OBJETS & VENTES ----
|
70
72
|
"""
|
71
73
|
|
72
|
-
def
|
74
|
+
def save_item(self, item: Item) -> None:
|
75
|
+
"""
|
76
|
+
Sauvegarde des infos à propos d'un item.
|
77
|
+
|
78
|
+
## Paramètres
|
79
|
+
item: `.Item`\n
|
80
|
+
Article à sauvegarder
|
81
|
+
"""
|
82
|
+
|
83
|
+
_item = item.__dict__
|
84
|
+
self._put_in_db('items', _item)
|
85
|
+
|
86
|
+
def get_item(self, id: NSID) -> Item | None:
|
87
|
+
"""
|
88
|
+
Récupère des informations à propos d'un item.
|
89
|
+
|
90
|
+
## Paramètres
|
91
|
+
id: `NSID`\n
|
92
|
+
ID de l'item
|
93
|
+
|
94
|
+
## Retourne
|
95
|
+
- `.Item` si quelque chose est trouvé, sinon
|
96
|
+
- `None`
|
97
|
+
"""
|
98
|
+
|
99
|
+
_item = self._get_by_ID('items', id)
|
100
|
+
|
101
|
+
if _item is None:
|
102
|
+
return
|
103
|
+
|
104
|
+
item = Item(id)
|
105
|
+
item.title = _item['title']
|
106
|
+
item.emoji = _item['emoji']
|
107
|
+
|
108
|
+
return item
|
109
|
+
|
110
|
+
def delete_item(self, item: Item) -> None:
|
111
|
+
"""
|
112
|
+
Annule le référencement d'un item.
|
113
|
+
|
114
|
+
## Paramètres
|
115
|
+
item: `.Item`\n
|
116
|
+
Item à vendre
|
117
|
+
"""
|
118
|
+
|
119
|
+
self._delete_by_ID('items', item.id)
|
120
|
+
|
121
|
+
def get_sale(self, id: NSID) -> Sale | None:
|
73
122
|
"""
|
74
123
|
Récupère une vente disponible sur le marketplace.
|
75
124
|
|
76
125
|
## Paramètres
|
77
|
-
id: `
|
78
|
-
ID de
|
126
|
+
id: `NSID`\n
|
127
|
+
ID de la vente.
|
79
128
|
|
80
129
|
## Renvoie
|
81
|
-
- `.
|
130
|
+
- `.Sale | None`
|
82
131
|
"""
|
83
132
|
|
84
133
|
id = NSID(id)
|
@@ -87,8 +136,10 @@ class EconomyInstance(Instance):
|
|
87
136
|
|
88
137
|
if _data is None:
|
89
138
|
return None
|
139
|
+
|
140
|
+
item = self.get_item(_data['id'])
|
90
141
|
|
91
|
-
sale = Sale(NSID(id))
|
142
|
+
sale = Sale(NSID(id), Item(_data['id']) if item is None else item)
|
92
143
|
sale.__dict__ = _data
|
93
144
|
|
94
145
|
return sale
|
@@ -147,8 +198,7 @@ class EconomyInstance(Instance):
|
|
147
198
|
inventory = Inventory(id)
|
148
199
|
|
149
200
|
for _item in _data['objects']:
|
150
|
-
item =
|
151
|
-
item.__dict__ = _item
|
201
|
+
item = self.get_item(_item)
|
152
202
|
|
153
203
|
inventory.objects.append(item)
|
154
204
|
|
@@ -163,10 +213,7 @@ class EconomyInstance(Instance):
|
|
163
213
|
Inventaire à sauvegarder
|
164
214
|
"""
|
165
215
|
|
166
|
-
_data =
|
167
|
-
"owner_id": inventory.owner_id,
|
168
|
-
"objects": [ object.__dict__ for object in inventory.objects ]
|
169
|
-
}
|
216
|
+
_data = inventory.__dict__
|
170
217
|
|
171
218
|
self._put_in_db('inventories', _data)
|
172
219
|
|
nsarchive/instances/_entities.py
CHANGED
@@ -72,7 +72,7 @@ class EntityInstance(Instance):
|
|
72
72
|
_member_profile = self.get_entity(member.id)
|
73
73
|
|
74
74
|
member.set_name(_member_profile.name)
|
75
|
-
member.
|
75
|
+
member.position = _member_profile.position
|
76
76
|
member.registerDate = _member_profile.registerDate
|
77
77
|
|
78
78
|
member.xp = _member_profile.xp
|
@@ -89,7 +89,7 @@ class EntityInstance(Instance):
|
|
89
89
|
entity = Entity(id)
|
90
90
|
|
91
91
|
entity.name = _data['name']
|
92
|
-
entity.
|
92
|
+
entity.position = _data['position'] # Métier si c'est un utilisateur, domaine professionnel si c'est un collectif
|
93
93
|
entity.registerDate = _data['register_date']
|
94
94
|
|
95
95
|
for key, value in _data.get('additional', {}).items():
|
@@ -114,7 +114,7 @@ class EntityInstance(Instance):
|
|
114
114
|
_data = {
|
115
115
|
'id': entity.id,
|
116
116
|
'name': entity.name,
|
117
|
-
'position': entity.
|
117
|
+
'position': entity.position,
|
118
118
|
'register_date': entity.registerDate,
|
119
119
|
'additional': {},
|
120
120
|
}
|
nsarchive/instances/_republic.py
CHANGED
@@ -26,7 +26,7 @@ class RepublicInstance(Instance):
|
|
26
26
|
---- VOTES & REFERENDUMS ----
|
27
27
|
"""
|
28
28
|
|
29
|
-
def get_vote(self, id: str | NSID) -> Vote |
|
29
|
+
def get_vote(self, id: str | NSID) -> Vote | Referendum | Lawsuit:
|
30
30
|
"""
|
31
31
|
Récupère un vote spécifique.
|
32
32
|
|
@@ -44,10 +44,10 @@ class RepublicInstance(Instance):
|
|
44
44
|
if _data is None:
|
45
45
|
return None
|
46
46
|
|
47
|
-
if _data['_type'] == '
|
47
|
+
if _data['_type'] == 'vote':
|
48
48
|
vote = Vote(id, _data['title'], tuple(_data['choices'].keys()))
|
49
|
-
elif _data['_type'] == '
|
50
|
-
vote =
|
49
|
+
elif _data['_type'] == 'referendum':
|
50
|
+
vote = Referendum(id, _data['title'])
|
51
51
|
elif _data['_type'] == 'lawsuit':
|
52
52
|
vote = Lawsuit(id, _data['title'])
|
53
53
|
else:
|
@@ -60,14 +60,14 @@ class RepublicInstance(Instance):
|
|
60
60
|
|
61
61
|
return vote
|
62
62
|
|
63
|
-
def save_vote(self, vote: Vote |
|
63
|
+
def save_vote(self, vote: Vote | Referendum) -> None:
|
64
64
|
"""Sauvegarde un vote dans la base de données."""
|
65
65
|
|
66
66
|
vote.id = NSID(vote.id)
|
67
67
|
|
68
68
|
_data = {
|
69
|
-
'_type':'
|
70
|
-
'
|
69
|
+
'_type':'vote' if type(vote) == Vote else\
|
70
|
+
'referendum' if type(vote) == Referendum else\
|
71
71
|
'lawsuit' if type(vote) == Lawsuit else\
|
72
72
|
'unknown',
|
73
73
|
'title': vote.title,
|
@@ -0,0 +1,16 @@
|
|
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=HHQhGKdnl7vD5zC8-bbXeQLhp8A98bBlneJTkztOmMg,2007
|
4
|
+
nsarchive/cls/base.py,sha256=RWcpUDfo96BjsUR_G49c9mR80qZKGKD82RoZB2do1p8,3606
|
5
|
+
nsarchive/cls/economy.py,sha256=fnzmliHsUBEdu5RrrSkimpcgou_HFnivP_lmzLKCaDI,1360
|
6
|
+
nsarchive/cls/entities.py,sha256=hjqCtsQHQZrLFwR57d_n4FssJ53-jdniQMHUAJGuDPY,6612
|
7
|
+
nsarchive/cls/exceptions.py,sha256=QN6Qn7cxTkGoC4lO50hBAq4gZCgo7scQvCkb-xKl6Xs,692
|
8
|
+
nsarchive/cls/republic.py,sha256=4amjvCS5BnrvEgbjjDx_tOit3TbOSCMTsns6ifceL_8,2464
|
9
|
+
nsarchive/instances/_economy.py,sha256=PjdqVJspZIuge5oqeJ_7fWrddfogH2yCEu0EgOhJv90,7445
|
10
|
+
nsarchive/instances/_entities.py,sha256=VckXexRhsZRq4qLZuMWp74sB5gLeuR4sj8yXxijFI94,9814
|
11
|
+
nsarchive/instances/_republic.py,sha256=sIaqz2lhmmjz3Y8l4iwY737JVCVt077OwP0-1dPsEaw,10071
|
12
|
+
nsarchive/utils/assets.py,sha256=WGC03K1VZ5LwGzcVXbqphtGBZ_Vjso-1hmbIkpgL_X8,382
|
13
|
+
nsarchive-2.0.0a6.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
14
|
+
nsarchive-2.0.0a6.dist-info/METADATA,sha256=i4aiTtyC5fc5kr8PD7TOCtAfxJwfATw60Gim-t5xY9k,5697
|
15
|
+
nsarchive-2.0.0a6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
16
|
+
nsarchive-2.0.0a6.dist-info/RECORD,,
|
@@ -1,16 +0,0 @@
|
|
1
|
-
nsarchive/__init__.py,sha256=-yXGGJBOkoQo-6Vg6hJVIqr-C7sQyL_LaYcQ3yx9aFs,696
|
2
|
-
nsarchive/assets/default_avatar.png,sha256=n-4vG_WPke8LvbY3ZU6oA-H-OtRoIu7woKnRq9DCIlI,51764
|
3
|
-
nsarchive/cls/archives.py,sha256=HHQhGKdnl7vD5zC8-bbXeQLhp8A98bBlneJTkztOmMg,2007
|
4
|
-
nsarchive/cls/base.py,sha256=7DRehwuUETaelrVDCQiOx3lZC00XhX5iVIIjTqnlM4s,3564
|
5
|
-
nsarchive/cls/economy.py,sha256=-eV8R5KMXSeXcKEu2G8OP1UgYgb0X6uks0aD2XhlbcU,1220
|
6
|
-
nsarchive/cls/entities.py,sha256=-88-mfd58PjuTHuOLH9COoa447Dp0e7d70Naa9TS_Ow,6622
|
7
|
-
nsarchive/cls/exceptions.py,sha256=QN6Qn7cxTkGoC4lO50hBAq4gZCgo7scQvCkb-xKl6Xs,692
|
8
|
-
nsarchive/cls/republic.py,sha256=F6il2FrvCoutHxQlW3xM36GaFfIqdorg2jicMAlPdUo,2503
|
9
|
-
nsarchive/instances/_economy.py,sha256=kaFRm6SpWCgvkv-PTVicGztL3e34gSy6WZQDiLZLaT4,6346
|
10
|
-
nsarchive/instances/_entities.py,sha256=HX1yDqIC5gr0XOx9PpwHbZ42f3WI9P4z9NWhBxNUQFk,9834
|
11
|
-
nsarchive/instances/_republic.py,sha256=TBfgILDJujbp5tiEgbHGnP_uuW1tdAzGUtkwJmuMogE,10063
|
12
|
-
nsarchive/utils/assets.py,sha256=WGC03K1VZ5LwGzcVXbqphtGBZ_Vjso-1hmbIkpgL_X8,382
|
13
|
-
nsarchive-2.0.0a4.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
14
|
-
nsarchive-2.0.0a4.dist-info/METADATA,sha256=C3k5PaWIG3o1gMHFosXOUwGWHytHufq291hxEKqdVQo,5697
|
15
|
-
nsarchive-2.0.0a4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
16
|
-
nsarchive-2.0.0a4.dist-info/RECORD,,
|
File without changes
|
File without changes
|