logs-py 3.0.0__py3-none-any.whl → 3.0.2__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.
Potentially problematic release.
This version of logs-py might be problematic. Click here for more details.
- LOGS/Entities/PersonRequestParameter.py +1 -0
- LOGS/Entity/EntityIterator.py +14 -2
- LOGS/Entity/IdIterator.py +192 -0
- {logs_py-3.0.0.dist-info → logs_py-3.0.2.dist-info}/METADATA +1 -1
- {logs_py-3.0.0.dist-info → logs_py-3.0.2.dist-info}/RECORD +7 -6
- {logs_py-3.0.0.dist-info → logs_py-3.0.2.dist-info}/WHEEL +0 -0
- {logs_py-3.0.0.dist-info → logs_py-3.0.2.dist-info}/top_level.txt +0 -0
|
@@ -55,6 +55,7 @@ class PersonRequestParameter(
|
|
|
55
55
|
documentIds: Optional[List[int]] = None
|
|
56
56
|
hasAccount: Optional[bool] = None
|
|
57
57
|
isAccountEnabled: Optional[bool] = None
|
|
58
|
+
includeSystemUsers: Optional[bool] = None
|
|
58
59
|
logins: Optional[List[str]] = None
|
|
59
60
|
emails: Optional[List[str]] = None
|
|
60
61
|
firstNames: Optional[List[str]] = None
|
LOGS/Entity/EntityIterator.py
CHANGED
|
@@ -6,6 +6,7 @@ from LOGS.Auxiliary.Tools import Tools
|
|
|
6
6
|
from LOGS.Entity.Entity import Entity
|
|
7
7
|
from LOGS.Entity.EntityConnector import EntityConnector
|
|
8
8
|
from LOGS.Entity.EntityRequestParameter import EntityRequestParameter
|
|
9
|
+
from LOGS.Entity.IdIterator import IdIterator
|
|
9
10
|
from LOGS.LOGSConnection import RESPONSE_TYPES, LOGSConnection, ResponseTypes
|
|
10
11
|
|
|
11
12
|
# SELF = TypeVar("SELF", bound="EntityConnector")
|
|
@@ -189,8 +190,8 @@ class EntityIterator(Generic[ENTITY, REQUEST], EntityConnector[ENTITY]):
|
|
|
189
190
|
|
|
190
191
|
items = iter(self)
|
|
191
192
|
ids = []
|
|
192
|
-
for
|
|
193
|
-
ids.append(
|
|
193
|
+
for item in items:
|
|
194
|
+
ids.append(item.id)
|
|
194
195
|
if len(ids) >= size:
|
|
195
196
|
param = dataclasses.replace(self._parameters)
|
|
196
197
|
param.ids = ids
|
|
@@ -205,6 +206,17 @@ class EntityIterator(Generic[ENTITY, REQUEST], EntityConnector[ENTITY]):
|
|
|
205
206
|
iterator._parameters = param
|
|
206
207
|
yield iterator
|
|
207
208
|
|
|
209
|
+
def ids(self):
|
|
210
|
+
if not self._generatorType:
|
|
211
|
+
return
|
|
212
|
+
d = self._generatorType()
|
|
213
|
+
iterator = IdIterator[type(d.id), REQUEST](connection=self._connection)
|
|
214
|
+
iterator._endpoint = self._endpoint
|
|
215
|
+
iterator._parameters = self._parameters
|
|
216
|
+
iterator._parameterType = self._parameterType
|
|
217
|
+
iterator._generatorType = type(d.id)
|
|
218
|
+
return iterator
|
|
219
|
+
|
|
208
220
|
def first(self):
|
|
209
221
|
i = iter(self)
|
|
210
222
|
try:
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
from calendar import c
|
|
2
|
+
import dataclasses
|
|
3
|
+
from typing import Any, Generic, List, Optional, Type, TypeVar, Union, cast
|
|
4
|
+
|
|
5
|
+
from LOGS.Auxiliary.Exceptions import LOGSException
|
|
6
|
+
from LOGS.Auxiliary.Tools import Tools
|
|
7
|
+
from LOGS.Entity.Entity import Entity
|
|
8
|
+
from LOGS.Entity.EntityConnector import EntityConnector
|
|
9
|
+
from LOGS.Entity.EntityRequestParameter import EntityRequestParameter
|
|
10
|
+
from LOGS.LOGSConnection import RESPONSE_TYPES, LOGSConnection, ResponseTypes
|
|
11
|
+
|
|
12
|
+
# SELF = TypeVar("SELF", bound="EntityConnector")
|
|
13
|
+
|
|
14
|
+
_idType = TypeVar("_idType", bound=Union[int, str])
|
|
15
|
+
REQUEST = TypeVar("REQUEST", bound=EntityRequestParameter)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class IdIterator(Generic[_idType, REQUEST], EntityConnector[Entity]):
|
|
19
|
+
"""Represents a connected LOGS entity id iterator"""
|
|
20
|
+
|
|
21
|
+
_entityIterator: int
|
|
22
|
+
_currentResults: Optional[RESPONSE_TYPES]
|
|
23
|
+
_generatorType: Optional[Type[_idType]] = None
|
|
24
|
+
_parameterType: Optional[Type[REQUEST]] = None
|
|
25
|
+
|
|
26
|
+
_parametersInput: Optional[REQUEST]
|
|
27
|
+
_parameters: REQUEST
|
|
28
|
+
_responseType: ResponseTypes = ResponseTypes.JSON
|
|
29
|
+
_includeUrl: bool = True
|
|
30
|
+
_connection: Optional[LOGSConnection]
|
|
31
|
+
_count: Optional[int]
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self, connection: Optional[LOGSConnection], parameters: Optional[REQUEST] = None
|
|
35
|
+
):
|
|
36
|
+
super().__init__(connection=connection)
|
|
37
|
+
self._connection = connection
|
|
38
|
+
|
|
39
|
+
self._parametersInput = parameters
|
|
40
|
+
|
|
41
|
+
self._entityIterator = 0
|
|
42
|
+
self._currentResults = None
|
|
43
|
+
self._count = None
|
|
44
|
+
|
|
45
|
+
def __iter__(self):
|
|
46
|
+
self._initEntityIterator()
|
|
47
|
+
return self
|
|
48
|
+
|
|
49
|
+
def __next__(self) -> _idType:
|
|
50
|
+
if not self._generatorType:
|
|
51
|
+
raise NotImplementedError(
|
|
52
|
+
"Iterator cannot generate items without a specified 'generatorType' field in class %a"
|
|
53
|
+
% type(self).__name__
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
return self._getNextEntity()
|
|
57
|
+
|
|
58
|
+
def _getNextPage(self, result):
|
|
59
|
+
if not self._connection:
|
|
60
|
+
raise LOGSException("Connection of %a is not defined" % type(self).__name__)
|
|
61
|
+
|
|
62
|
+
if "hasNext" not in result or not result["hasNext"]:
|
|
63
|
+
return None, None
|
|
64
|
+
|
|
65
|
+
url = result["url"]
|
|
66
|
+
|
|
67
|
+
page = 1
|
|
68
|
+
if "page" in result:
|
|
69
|
+
page = int(result["page"])
|
|
70
|
+
elif self._parameters.page:
|
|
71
|
+
page = self._parameters.page
|
|
72
|
+
self._parameters.page = page + 1
|
|
73
|
+
return self._connection.postUrl(
|
|
74
|
+
url=url,
|
|
75
|
+
data=self._parameters.toDict(),
|
|
76
|
+
responseType=self._responseType,
|
|
77
|
+
includeUrl=self._includeUrl,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
def _checkParameterType(self):
|
|
81
|
+
if not self._parameterType:
|
|
82
|
+
raise NotImplementedError(
|
|
83
|
+
"Entity connection cannot be initialized without the request 'parameterType' field in class %a"
|
|
84
|
+
% type(self).__name__
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if not isinstance(self._parameterType, type):
|
|
88
|
+
raise NotImplementedError(
|
|
89
|
+
"The field 'parameterType' must be a 'type' got %a in class %a"
|
|
90
|
+
% (type(self._parameterType), type(self).__name__)
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
if self._parametersInput and not isinstance(
|
|
94
|
+
self._parametersInput, self._parameterType
|
|
95
|
+
):
|
|
96
|
+
raise LOGSException(
|
|
97
|
+
"Parameter for iterator %a must be of type %a. (Got %a)"
|
|
98
|
+
% (
|
|
99
|
+
type(self).__name__,
|
|
100
|
+
self._parameterType.__name__,
|
|
101
|
+
type(self._parametersInput).__name__,
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
self._parametersInput = Tools.checkAndConvert(
|
|
106
|
+
self._parametersInput, self._parameterType, "parameters", initOnNone=True
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
def _initEntityIterator(self):
|
|
110
|
+
self._checkParameterType()
|
|
111
|
+
|
|
112
|
+
url = self.getBaseUrl()
|
|
113
|
+
self._entityIterator = 0
|
|
114
|
+
|
|
115
|
+
if not self._connection:
|
|
116
|
+
raise LOGSException(
|
|
117
|
+
"Entity connector %a is not connected" % type(self).__name__
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
tmp = False
|
|
121
|
+
if hasattr(self._parameters, "includeCount"):
|
|
122
|
+
tmp = self._parameters.includeCount
|
|
123
|
+
self._parameters.includeCount = True
|
|
124
|
+
|
|
125
|
+
self._currentResults, responseError = self._connection.postUrl(
|
|
126
|
+
url=url + "/ids_only",
|
|
127
|
+
data=self._parameters.toDict(),
|
|
128
|
+
responseType=self._responseType,
|
|
129
|
+
includeUrl=self._includeUrl,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if hasattr(self._parameters, "includeCount"):
|
|
133
|
+
self._parameters.includeCount = tmp
|
|
134
|
+
|
|
135
|
+
if isinstance(self._currentResults, dict) and "count" in self._currentResults:
|
|
136
|
+
self._count = int(self._currentResults["count"])
|
|
137
|
+
|
|
138
|
+
if responseError:
|
|
139
|
+
raise LOGSException(responseError=responseError)
|
|
140
|
+
|
|
141
|
+
def _getNextEntity(self):
|
|
142
|
+
if not isinstance(self._currentResults, dict):
|
|
143
|
+
raise StopIteration
|
|
144
|
+
|
|
145
|
+
results = self._currentResults["results"]
|
|
146
|
+
if self._entityIterator < len(results):
|
|
147
|
+
result = results[self._entityIterator]
|
|
148
|
+
self._entityIterator += 1
|
|
149
|
+
return result
|
|
150
|
+
|
|
151
|
+
self._currentResults, error = self._getNextPage(self._currentResults)
|
|
152
|
+
if error:
|
|
153
|
+
raise Exception("Connection error: %a", error)
|
|
154
|
+
self._entityIterator = 0
|
|
155
|
+
|
|
156
|
+
if (
|
|
157
|
+
not self._currentResults
|
|
158
|
+
or not isinstance(self._currentResults, dict)
|
|
159
|
+
or len(self._currentResults["results"]) < 1
|
|
160
|
+
):
|
|
161
|
+
raise StopIteration
|
|
162
|
+
|
|
163
|
+
return self._getNextEntity()
|
|
164
|
+
|
|
165
|
+
def first(self):
|
|
166
|
+
i = iter(self)
|
|
167
|
+
try:
|
|
168
|
+
return cast(_idType, next(i))
|
|
169
|
+
except StopIteration:
|
|
170
|
+
return None
|
|
171
|
+
|
|
172
|
+
def toList(self, count: Optional[int] = None):
|
|
173
|
+
if count:
|
|
174
|
+
count = int(count)
|
|
175
|
+
if count < 0:
|
|
176
|
+
raise Exception("Invalid negative count %d" % count)
|
|
177
|
+
result = cast(List[_idType], [])
|
|
178
|
+
num = 0
|
|
179
|
+
for entity in self:
|
|
180
|
+
result.append(entity)
|
|
181
|
+
num += 1
|
|
182
|
+
if num >= count:
|
|
183
|
+
break
|
|
184
|
+
return result
|
|
185
|
+
|
|
186
|
+
return list(self)
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def count(self) -> int:
|
|
190
|
+
if self._count is None:
|
|
191
|
+
self._initEntityIterator()
|
|
192
|
+
return self._count if self._count else 0
|
|
@@ -150,7 +150,7 @@ LOGS/Entities/Person.py,sha256=Gt26dZIcdJ2QfrdDRfdua_Zv1EZ0rf1Wviy2mioidk0,5781
|
|
|
150
150
|
LOGS/Entities/PersonCategory.py,sha256=3JBVCmN5FNyriDqF2GtSRCbxrFyDSb-MZ079gqoEah0,352
|
|
151
151
|
LOGS/Entities/PersonMinimal.py,sha256=W5lhHvFtYi_Ln4B9g91pnZddrhyJGoOwiX81hszmKNs,241
|
|
152
152
|
LOGS/Entities/PersonRelations.py,sha256=kN8Rfkg5qP0QSLbmCcqonZjKW5VtDSDyCMJ5WoUDvHk,2701
|
|
153
|
-
LOGS/Entities/PersonRequestParameter.py,sha256=
|
|
153
|
+
LOGS/Entities/PersonRequestParameter.py,sha256=IxP0M_GXnaWg9-axol5ggn6ynw-5ygtfAG9zTIY3mvY,2266
|
|
154
154
|
LOGS/Entities/Persons.py,sha256=cj4SKaJZvitaIe7Fd1M9_qqNdAEEG38iuMPNiKPDPUA,413
|
|
155
155
|
LOGS/Entities/Project.py,sha256=DuZRZGKX5Ibm5LLKR9CH8Cl7j6zea2iLD9BYbOQcUy8,3139
|
|
156
156
|
LOGS/Entities/ProjectMinimal.py,sha256=Xw8wnA2iSixEkVaisY_b4Z3Ujudum3MG6tBUfbiAk0s,246
|
|
@@ -220,7 +220,7 @@ LOGS/Entities/LabNotebookEntryContent/__init__.py,sha256=03TqIEBq0R2B0pUcGplIP68
|
|
|
220
220
|
LOGS/Entity/ConnectedEntity.py,sha256=FP1jJoDOXoMBTozz6sur36IxjhlfqGI-1qUK-G001vc,2805
|
|
221
221
|
LOGS/Entity/Entity.py,sha256=WLCtVjRxyRg6nX8UzEMjKJ4MkLICrMmXSo5xrtRHaUE,6300
|
|
222
222
|
LOGS/Entity/EntityConnector.py,sha256=kjCoieYABujwX1hIaldJVHmg_Js2OdWdbkvNwgBLeNo,2109
|
|
223
|
-
LOGS/Entity/EntityIterator.py,sha256=
|
|
223
|
+
LOGS/Entity/EntityIterator.py,sha256=EF29TdSvC0rTMMnQgCe5X99mYAYNjZydtLaQc3n7-6k,8165
|
|
224
224
|
LOGS/Entity/EntityMinimal.py,sha256=GysThwk8YbT8xqbHvJqmYKgPf8ckALO5pG-J_SNT0vw,3237
|
|
225
225
|
LOGS/Entity/EntityMinimalWithIntId.py,sha256=6eVhFFbXKdH3LPj-fAzQLpnzbkWqh1AmV_uRksTi7Ho,1045
|
|
226
226
|
LOGS/Entity/EntityMinimalWithStrId.py,sha256=JmuY0Aah4YLngrgluzwMkhIyeExj2j6kiBZ6Y115hbA,1046
|
|
@@ -230,6 +230,7 @@ LOGS/Entity/EntityRelations.py,sha256=zaAASS5SVDwPVMUyNgUH8DcZhWdErRulrZjD6MAWlh
|
|
|
230
230
|
LOGS/Entity/EntityRequestParameter.py,sha256=RH6-Sh8ug3aeq_AOFHs0Lp2J94cKI9Ts3slAATZ1tNA,828
|
|
231
231
|
LOGS/Entity/EntityWithIntId.py,sha256=B79VqAQ9I0uEQwbf3DMHXoi064gCw4fv3vCKoXwrHQM,631
|
|
232
232
|
LOGS/Entity/EntityWithStrId.py,sha256=5hz8-F_t_X4kf85DMwW3DJ2NqH_RiRV1Io1WiMN11yk,631
|
|
233
|
+
LOGS/Entity/IdIterator.py,sha256=GwQj6XmDfEqeQFIGje2nOURLcl5OYuNXImDXGrzoBL8,6263
|
|
233
234
|
LOGS/Entity/SerializeableContent.py,sha256=iN_rW3zorXnvL1RBjyQvwxEJwvx5d3RqZKRtPSlScXk,22203
|
|
234
235
|
LOGS/Entity/__init__.py,sha256=8q6dB_AqlLGx-6PexFn8QH7LWOnSGRhgPfFVkYAghR0,749
|
|
235
236
|
LOGS/Interfaces/ICreationRecord.py,sha256=SpACPwz2zA60pkApErZelUOsPq40fHAfiFW3vm9qW9k,1461
|
|
@@ -257,7 +258,7 @@ LOGS/Parameters/ParameterElement.py,sha256=fr6AlO_flKRygZZFx1OILP4P-2lV2Tx4PAe6W
|
|
|
257
258
|
LOGS/Parameters/ParameterList.py,sha256=ijukB1__iKI5cefmOIIWz0wKaPz9Cx8KpD7Y7Gz2Pn0,1478
|
|
258
259
|
LOGS/Parameters/ParameterTable.py,sha256=7Lew4DPgWmKcpV1T-1Pvt00kEI05FB383QqO-LHAjds,1758
|
|
259
260
|
LOGS/Parameters/__init__.py,sha256=jNF_VnD9u6V7usDFymzvDx5kzvcYssnpASICiKW0wdU,341
|
|
260
|
-
logs_py-3.0.
|
|
261
|
-
logs_py-3.0.
|
|
262
|
-
logs_py-3.0.
|
|
263
|
-
logs_py-3.0.
|
|
261
|
+
logs_py-3.0.2.dist-info/METADATA,sha256=b2jgXrwXDx1KMAlz7IW0heyPHiWKzT1RBMZlvLd6WdI,2072
|
|
262
|
+
logs_py-3.0.2.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
263
|
+
logs_py-3.0.2.dist-info/top_level.txt,sha256=Ckn2LiAmGaR7k3tdEnKAc04z_uboMD4gLreYghRNdCs,5
|
|
264
|
+
logs_py-3.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|