nsarchive 3.0.0a5__tar.gz → 3.0.0a7__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: 3.0.0a5
3
+ Version: 3.0.0a7
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
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Requires-Dist: pillow (>=10.4,<11.0)
15
+ Requires-Dist: requests (>=2.31,<3.0)
15
16
  Description-Content-Type: text/markdown
16
17
 
17
18
  # NSArchive
@@ -1,7 +1,7 @@
1
1
  """
2
2
  nsarchive - API-wrapper pour récupérer des données liées à Nation.
3
3
 
4
- Version: 3.0.0a5
4
+ Version: 3.0.0a7
5
5
  License: GPL-3.0
6
6
  Auteur : happex <110610727+okayhappex@users.noreply.github.com>
7
7
 
@@ -92,6 +92,7 @@ class Position:
92
92
  res.raise_for_status()
93
93
 
94
94
  def _load(self, _data: dict):
95
+ self.id = _data['id']
95
96
  self.name = _data['name']
96
97
  self.permissions.merge(_data['permissions'])
97
98
  self.manager_permissions.merge(_data['manager_permissions'])
@@ -52,12 +52,12 @@ class EntityInstance(Instance):
52
52
  if _data is None: # ID inexistant chez les entités
53
53
  return None
54
54
 
55
- if _data['_class'] == 'user':
55
+ if _data['_class'] == 'individuals':
56
56
  entity = User(id)
57
57
  entity._url = f"{self.url}/model/individuals/{id}"
58
58
 
59
59
  entity._load(_data)
60
- elif _data['_class'] == 'organization':
60
+ elif _data['_class'] == 'organizations':
61
61
  entity = Organization(id)
62
62
  entity._url = f"{self.url}/model/organizations/{id}"
63
63
 
@@ -92,11 +92,23 @@ class EntityInstance(Instance):
92
92
  return entity
93
93
 
94
94
  def get_entity_groups(self, entity: User) -> list[Organization]:
95
- print(entity._url)
96
95
  res = requests.get(f"{entity._url}/groups", headers = self.default_headers)
97
96
 
98
97
  if res.status_code == 200:
99
- return res.json()
98
+ data = res.json()
99
+ groups = []
100
+
101
+ for grp in data:
102
+ if grp is None: continue
103
+
104
+ group = Organization(grp["id"])
105
+ group._url = f"{self.url}/model/organizations/{grp['id']}"
106
+
107
+ group._load(grp)
108
+
109
+ groups.append(group)
110
+
111
+ return groups
100
112
  else:
101
113
  res.raise_for_status()
102
114
  return []
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nsarchive"
3
- version = "3.0.0a5"
3
+ version = "3.0.0a7"
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"
@@ -9,6 +9,7 @@ readme = "README.md"
9
9
  [tool.poetry.dependencies]
10
10
  python = "^3.10"
11
11
  pillow = "^10.4"
12
+ requests = "^2.31"
12
13
 
13
14
  [build-system]
14
15
  requires = ["poetry-core"]
File without changes
File without changes