nsarchive 1.3.0__py3-none-any.whl → 1.4.0__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 +14 -1
- nsarchive/cls/entities.py +16 -2
- {nsarchive-1.3.0.dist-info → nsarchive-1.4.0.dist-info}/METADATA +1 -1
- {nsarchive-1.3.0.dist-info → nsarchive-1.4.0.dist-info}/RECORD +6 -6
- {nsarchive-1.3.0.dist-info → nsarchive-1.4.0.dist-info}/LICENSE +0 -0
- {nsarchive-1.3.0.dist-info → nsarchive-1.4.0.dist-info}/WHEEL +0 -0
nsarchive/__init__.py
CHANGED
@@ -97,6 +97,12 @@ class EntityInstance:
|
|
97
97
|
entity.legalPosition = _data['legalPosition'] # Métier si c'est un utilisateur, domaine professionnel si c'est un collectif
|
98
98
|
entity.registerDate = _data['registerDate']
|
99
99
|
|
100
|
+
for key, value in _data.get('additional', {}):
|
101
|
+
if isinstance(value, str) and value.startswith('\n'):
|
102
|
+
entity.add_link(key, int(value[1:]))
|
103
|
+
else:
|
104
|
+
entity.add_link(key, value)
|
105
|
+
|
100
106
|
return entity
|
101
107
|
|
102
108
|
def save_entity(self, entity: Entity) -> None:
|
@@ -115,9 +121,16 @@ class EntityInstance:
|
|
115
121
|
'_type': 'user' if type(entity) == User else 'organization' if type(entity) == Organization else 'unknown',
|
116
122
|
'name': entity.name,
|
117
123
|
'legalPosition': entity.legalPosition,
|
118
|
-
'registerDate': entity.registerDate
|
124
|
+
'registerDate': entity.registerDate,
|
125
|
+
'additional': {}
|
119
126
|
}
|
120
127
|
|
128
|
+
for key, value in entity.additional.items():
|
129
|
+
if isinstance(value, int) and len(str(int)) >= 15:
|
130
|
+
_data['additional'][key] = '\n' + str(value)
|
131
|
+
elif type(value) in (str, int):
|
132
|
+
_data['additional'][key] = value
|
133
|
+
|
121
134
|
if type(entity) == Organization:
|
122
135
|
_data['owner_id'] = NSID(entity.owner.id) if entity.owner else NSID("0")
|
123
136
|
_data['members'] = []
|
nsarchive/cls/entities.py
CHANGED
@@ -45,6 +45,7 @@ class Entity:
|
|
45
45
|
self.name: str = "Entité Inconnue"
|
46
46
|
self.registerDate: int = 0
|
47
47
|
self.legalPosition: Position = Position()
|
48
|
+
self.additional: dict = {}
|
48
49
|
|
49
50
|
def set_name(self, new_name: str) -> None:
|
50
51
|
if len(new_name) > 32:
|
@@ -55,6 +56,13 @@ class Entity:
|
|
55
56
|
def set_position(self, position: str) -> None:
|
56
57
|
self.legalPosition = position
|
57
58
|
|
59
|
+
def add_link(self, key: str, value: str | int) -> None:
|
60
|
+
if isinstance(value, str) or isinstance(value, int):
|
61
|
+
self.additional[key] = value
|
62
|
+
|
63
|
+
def unlink(self, key: str) -> None:
|
64
|
+
del self.additional[key]
|
65
|
+
|
58
66
|
class User(Entity):
|
59
67
|
def __init__(self, id: str | NSID) -> None:
|
60
68
|
super().__init__(NSID(id))
|
@@ -134,8 +142,14 @@ class Organization(Entity):
|
|
134
142
|
self.members: list[GroupMember] = []
|
135
143
|
self.avatar: bytes = assets.open('default_avatar.png')
|
136
144
|
|
137
|
-
def add_certification(self,
|
138
|
-
self.certifications[
|
145
|
+
def add_certification(self, certification: str) -> None:
|
146
|
+
self.certifications[certification] = round(time.time())
|
147
|
+
|
148
|
+
def has_certification(self, certification: str) -> bool:
|
149
|
+
return certification in self.certifications.keys()
|
150
|
+
|
151
|
+
def remove_certification(self, certification: str) -> None:
|
152
|
+
del self.certifications[certification]
|
139
153
|
|
140
154
|
def add_member(self, member: GroupMember) -> None:
|
141
155
|
if not isinstance(member, GroupMember):
|
@@ -1,13 +1,13 @@
|
|
1
|
-
nsarchive/__init__.py,sha256=
|
1
|
+
nsarchive/__init__.py,sha256=85kvYTT-TSJgTX1AX-nVNI9GJANJS4S6UXCE3SpyUjE,27563
|
2
2
|
nsarchive/assets/default_avatar.png,sha256=n-4vG_WPke8LvbY3ZU6oA-H-OtRoIu7woKnRq9DCIlI,51764
|
3
3
|
nsarchive/cls/archives.py,sha256=i4R7NPYXX_1oi0oLAvL_4SqyjqPutXSXKysUetE6hME,2001
|
4
4
|
nsarchive/cls/base.py,sha256=DGDm0uD96M00-qvdKsltU9kAfAOBr85Ov0b18gTnoIM,714
|
5
5
|
nsarchive/cls/economy.py,sha256=JpNB06JHek4uUapdk89-SR3DEoSyxXPn8OqZJkOZH_E,1252
|
6
|
-
nsarchive/cls/entities.py,sha256=
|
6
|
+
nsarchive/cls/entities.py,sha256=7vhD6r6DuvTlyGyPmm1scpWFsqPGMUw7JQ9Ks8sHWpQ,6712
|
7
7
|
nsarchive/cls/exceptions.py,sha256=QN6Qn7cxTkGoC4lO50hBAq4gZCgo7scQvCkb-xKl6Xs,692
|
8
8
|
nsarchive/cls/republic.py,sha256=6eut6OsFoOm9TVhA41fM3NlMEA3Uhg9TCuXgl46vFko,1985
|
9
9
|
nsarchive/utils/assets.py,sha256=hd0STSpa0yT-OJlUyI_wCYXJqcBiUMQds2pZTXNNg9c,382
|
10
|
-
nsarchive-1.
|
11
|
-
nsarchive-1.
|
12
|
-
nsarchive-1.
|
13
|
-
nsarchive-1.
|
10
|
+
nsarchive-1.4.0.dist-info/LICENSE,sha256=aFLFZg6LEJFpTlNQ8su3__jw4GfV-xWBmC1cePkKZVw,35802
|
11
|
+
nsarchive-1.4.0.dist-info/METADATA,sha256=MK4hOKyqSERSJtko967gMBPPdnzyqY-GFfx5pzaimts,5629
|
12
|
+
nsarchive-1.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
13
|
+
nsarchive-1.4.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|