nsarchive 2.0.0a3__tar.gz → 2.0.0a4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nsarchive
3
- Version: 2.0.0a3
3
+ Version: 2.0.0a4
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
@@ -37,7 +37,7 @@ class Instance:
37
37
  def __init__(self, client: Client):
38
38
  self.db = client
39
39
 
40
- def _select_from_db(self, table: str, key: str, value: str) -> dict:
40
+ def _select_from_db(self, table: str, key: str, value: str) -> list:
41
41
  """
42
42
  Récupère des données JSON d'une table Supabase en fonction de l'ID.
43
43
 
@@ -112,11 +112,12 @@ class Instance:
112
112
  matches = []
113
113
 
114
114
  for key, value in query.items():
115
- matches.append(self._select_from_db(table, key, value))
115
+ entity = self._select_from_db(table, key, value)
116
+ if entity is not None: matches.append(entity[0])
116
117
 
117
118
  _res = []
118
119
 
119
- for item in matches[0]:
120
+ for item in matches:
120
121
  if all(item in sublist for sublist in matches[1:]):
121
122
  _res.append(item)
122
123
 
@@ -29,7 +29,7 @@ class PositionPermissions:
29
29
  self.vote_representatives = False # Participer aux élections législatives
30
30
 
31
31
  def edit(self, **permissions: bool) -> None:
32
- for perm in permissions.values():
32
+ for perm in permissions.items():
33
33
  self.__setattr__(*perm)
34
34
 
35
35
  class Position:
@@ -167,7 +167,8 @@ class EntityInstance(Instance):
167
167
  - `list[Entity | User | Organization]`
168
168
  """
169
169
 
170
- _res = self.fetch('entities', **query)
170
+ _res = self.fetch('individuals', **query)
171
+ _res.extend(self.fetch('organizations', **query))
171
172
 
172
173
  return [ self.get_entity(NSID(entity['id'])) for entity in _res if entity is not None ]
173
174
 
@@ -221,8 +222,8 @@ class EntityInstance(Instance):
221
222
  return None
222
223
 
223
224
  position = Position(id)
224
- position.name = _data['name']
225
- position.permissions.edit(dict(zip(_data['permissions'], True)))
225
+ position.name = _data['title']
226
+ position.permissions.edit(**{ p: True for p in _data['permissions'] })
226
227
 
227
228
  return position
228
229
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nsarchive"
3
- version = "2.0.0-alpha.3"
3
+ version = "2.0.0-alpha.4"
4
4
  description = "API-wrapper pour récupérer des données liées à Nation"
5
5
  authors = ["happex <110610727+okayhappex@users.noreply.github.com>"]
6
6
  license = "GPL-3.0"
File without changes
File without changes