layrz-sdk 3.0.7__py3-none-any.whl → 3.0.8__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 layrz-sdk might be problematic. Click here for more details.
- layrz_sdk/entities/__init__.py +55 -9
- layrz_sdk/entities/broadcasts/request.py +5 -4
- layrz_sdk/entities/broadcasts/response.py +5 -4
- layrz_sdk/entities/broadcasts/result.py +6 -5
- layrz_sdk/entities/broadcasts/service.py +5 -4
- layrz_sdk/entities/broadcasts/status.py +4 -3
- layrz_sdk/entities/cases/case.py +13 -12
- layrz_sdk/entities/cases/comment.py +5 -4
- layrz_sdk/entities/cases/trigger.py +5 -4
- layrz_sdk/entities/charts/__init__.py +1 -1
- layrz_sdk/entities/charts/alignment.py +4 -3
- layrz_sdk/entities/charts/bar.py +9 -7
- layrz_sdk/entities/charts/color.py +5 -4
- layrz_sdk/entities/charts/column.py +9 -7
- layrz_sdk/entities/charts/configuration.py +9 -7
- layrz_sdk/entities/charts/data_type.py +4 -3
- layrz_sdk/entities/charts/exceptions.py +6 -5
- layrz_sdk/entities/charts/html.py +5 -3
- layrz_sdk/entities/charts/line.py +9 -8
- layrz_sdk/entities/charts/map.py +13 -13
- layrz_sdk/entities/charts/number.py +5 -3
- layrz_sdk/entities/charts/pie.py +9 -7
- layrz_sdk/entities/charts/radar.py +6 -4
- layrz_sdk/entities/charts/radial_bar.py +9 -7
- layrz_sdk/entities/charts/render_technology.py +4 -3
- layrz_sdk/entities/charts/scatter.py +12 -10
- layrz_sdk/entities/charts/serie.py +5 -3
- layrz_sdk/entities/charts/serie_type.py +4 -3
- layrz_sdk/entities/charts/table.py +15 -17
- layrz_sdk/entities/charts/timeline.py +7 -6
- layrz_sdk/entities/checkpoints/checkpoint.py +6 -5
- layrz_sdk/entities/checkpoints/geofence.py +5 -4
- layrz_sdk/entities/checkpoints/waypoint.py +5 -4
- layrz_sdk/entities/events/event.py +5 -4
- layrz_sdk/entities/formatting/text_align.py +4 -3
- layrz_sdk/entities/general/asset.py +11 -9
- layrz_sdk/entities/general/asset_operation_mode.py +4 -3
- layrz_sdk/entities/general/custom_field.py +5 -4
- layrz_sdk/entities/general/device.py +5 -4
- layrz_sdk/entities/general/sensor.py +5 -4
- layrz_sdk/entities/general/user.py +5 -4
- layrz_sdk/entities/repcom/transaction.py +3 -2
- layrz_sdk/entities/reports/col.py +9 -9
- layrz_sdk/entities/reports/format.py +11 -7
- layrz_sdk/entities/reports/header.py +12 -10
- layrz_sdk/entities/reports/page.py +10 -8
- layrz_sdk/entities/reports/report.py +126 -66
- layrz_sdk/entities/reports/row.py +7 -5
- layrz_sdk/entities/telemetry/message.py +6 -5
- layrz_sdk/entities/telemetry/position.py +5 -4
- layrz_sdk/helpers/color.py +6 -5
- layrz_sdk/lcl/core.py +131 -120
- {layrz_sdk-3.0.7.dist-info → layrz_sdk-3.0.8.dist-info}/METADATA +6 -1
- layrz_sdk-3.0.8.dist-info/RECORD +69 -0
- {layrz_sdk-3.0.7.dist-info → layrz_sdk-3.0.8.dist-info}/WHEEL +1 -1
- layrz_sdk-3.0.7.dist-info/RECORD +0 -69
- {layrz_sdk-3.0.7.dist-info → layrz_sdk-3.0.8.dist-info}/LICENSE +0 -0
- {layrz_sdk-3.0.7.dist-info → layrz_sdk-3.0.8.dist-info}/top_level.txt +0 -0
layrz_sdk/lcl/core.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Layrz Compute Language SDK"""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ruff: noqa: ANN401
|
|
4
|
+
from typing import Any, Dict, List, Self
|
|
4
5
|
|
|
5
6
|
PATTERN_INVALID = 'Pattern should be string, received {received}'
|
|
6
7
|
INVALID_NUMBER_OF_PARAMS = 'Invalid number of arguments - Expected {expected} - Given {received}'
|
|
@@ -10,16 +11,16 @@ INVALID_ARGUMENTS = 'Invalid arguments - {e}'
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class LclCore:
|
|
13
|
-
"""
|
|
14
|
+
"""Layrz Compute Language SDK"""
|
|
14
15
|
|
|
15
16
|
def __init__( # pylint: disable=dangerous-default-value
|
|
16
|
-
self,
|
|
17
|
+
self: Self,
|
|
17
18
|
script: str = '',
|
|
18
|
-
sensors:
|
|
19
|
-
previous_sensors:
|
|
20
|
-
payload:
|
|
21
|
-
asset_constants:
|
|
22
|
-
custom_fields:
|
|
19
|
+
sensors: Dict = None,
|
|
20
|
+
previous_sensors: Dict = None,
|
|
21
|
+
payload: Dict = None,
|
|
22
|
+
asset_constants: Dict = None,
|
|
23
|
+
custom_fields: Dict = None,
|
|
23
24
|
) -> None:
|
|
24
25
|
"""
|
|
25
26
|
Creates a new instance of LclCore
|
|
@@ -40,9 +41,9 @@ class LclCore:
|
|
|
40
41
|
self._script = script
|
|
41
42
|
|
|
42
43
|
def perform( # pylint: disable=dangerous-default-value, invalid-name
|
|
43
|
-
self,
|
|
44
|
-
additional_globals:
|
|
45
|
-
additional_locals:
|
|
44
|
+
self: Self,
|
|
45
|
+
additional_globals: Dict = None,
|
|
46
|
+
additional_locals: Dict = None,
|
|
46
47
|
) -> str:
|
|
47
48
|
"""
|
|
48
49
|
Perform script using Layrz Compute Language
|
|
@@ -59,7 +60,8 @@ class LclCore:
|
|
|
59
60
|
'previous_sensors': self._previous_sensors,
|
|
60
61
|
'asset_constants': self._asset_constants,
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
if additional_locals:
|
|
64
|
+
local_variables.update(additional_locals)
|
|
63
65
|
|
|
64
66
|
## Define global variables and functions
|
|
65
67
|
global_functions = {
|
|
@@ -114,18 +116,22 @@ class LclCore:
|
|
|
114
116
|
'UNIX_TO_STR': self.UNIX_TO_STR,
|
|
115
117
|
'VERSION': self.VERSION,
|
|
116
118
|
}
|
|
117
|
-
|
|
119
|
+
|
|
120
|
+
if additional_globals:
|
|
121
|
+
global_functions.update(additional_globals)
|
|
118
122
|
|
|
119
123
|
import json
|
|
124
|
+
|
|
120
125
|
result = json.dumps(eval(self._script, global_functions, local_variables)) # pylint: disable=eval-used
|
|
121
126
|
|
|
122
127
|
return result
|
|
123
128
|
except Exception as err: # pylint: disable=broad-except
|
|
124
129
|
import json
|
|
130
|
+
|
|
125
131
|
return json.dumps(INVALID_ARGUMENTS.format(e=err))
|
|
126
132
|
|
|
127
|
-
def GET_PARAM(self, *args:
|
|
128
|
-
"""
|
|
133
|
+
def GET_PARAM(self: Self, *args: List[Any]) -> Any:
|
|
134
|
+
"""GET_PARAM Function"""
|
|
129
135
|
if len(args) > 2:
|
|
130
136
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
131
137
|
|
|
@@ -136,14 +142,14 @@ class LclCore:
|
|
|
136
142
|
return self._payload.get(args[0], args[1])
|
|
137
143
|
return self._payload.get(args[0], None)
|
|
138
144
|
|
|
139
|
-
def GET_DISTANCE_TRAVELED(self, *args:
|
|
140
|
-
"""
|
|
145
|
+
def GET_DISTANCE_TRAVELED(self: Self, *args: List[Any]) -> str | float:
|
|
146
|
+
"""GET_DISTANCE_TRAVELED Function"""
|
|
141
147
|
if len(args) > 0:
|
|
142
148
|
return INVALID_NUMBER_OF_PARAMS.format(expected=0, received=len(args))
|
|
143
149
|
return self._asset_constants.get('distanceTraveled', 0)
|
|
144
150
|
|
|
145
|
-
def GET_PREVIOUS_SENSOR(self, *args:
|
|
146
|
-
"""
|
|
151
|
+
def GET_PREVIOUS_SENSOR(self: Self, *args: List[Any]) -> Any:
|
|
152
|
+
"""GET_PREVIOUS_SENSOR Function"""
|
|
147
153
|
if len(args) < 1:
|
|
148
154
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
149
155
|
|
|
@@ -157,8 +163,8 @@ class LclCore:
|
|
|
157
163
|
return self._previous_sensors.get(args[0], args[1])
|
|
158
164
|
return self._previous_sensors.get(args[0], None)
|
|
159
165
|
|
|
160
|
-
def GET_SENSOR(self, *args:
|
|
161
|
-
"""
|
|
166
|
+
def GET_SENSOR(self: Self, *args: List[Any]) -> Any:
|
|
167
|
+
"""GET_SENSOR Function"""
|
|
162
168
|
if len(args) < 1:
|
|
163
169
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
164
170
|
|
|
@@ -172,20 +178,20 @@ class LclCore:
|
|
|
172
178
|
return self._sensors.get(args[0], args[1])
|
|
173
179
|
return self._sensors.get(args[0], None)
|
|
174
180
|
|
|
175
|
-
def CONSTANT(self, *args:
|
|
176
|
-
"""
|
|
181
|
+
def CONSTANT(self: Self, *args: List[Any]) -> Any:
|
|
182
|
+
"""CONSTANT Function"""
|
|
177
183
|
if len(args) > 1:
|
|
178
184
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
179
185
|
return args[0]
|
|
180
186
|
|
|
181
|
-
def GET_CUSTOM_FIELD(self, *args:
|
|
182
|
-
"""
|
|
187
|
+
def GET_CUSTOM_FIELD(self: Self, *args: List[Any]) -> str:
|
|
188
|
+
"""GET_CUSTOM_FIELD Function"""
|
|
183
189
|
if len(args) > 1:
|
|
184
190
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
185
191
|
return self._custom_fields.get(args[0], '')
|
|
186
192
|
|
|
187
|
-
def COMPARE(self, *args:
|
|
188
|
-
"""
|
|
193
|
+
def COMPARE(self: Self, *args: List[Any]) -> str | None | bool:
|
|
194
|
+
"""COMPARE Function"""
|
|
189
195
|
if len(args) != 2:
|
|
190
196
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
191
197
|
|
|
@@ -196,8 +202,8 @@ class LclCore:
|
|
|
196
202
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
197
203
|
return args[0] == args[1]
|
|
198
204
|
|
|
199
|
-
def OR_OPERATOR(self, *args:
|
|
200
|
-
"""
|
|
205
|
+
def OR_OPERATOR(self: Self, *args: List[Any]) -> bool:
|
|
206
|
+
"""OR_OPERATOR Function"""
|
|
201
207
|
result = False
|
|
202
208
|
|
|
203
209
|
for val in args:
|
|
@@ -208,8 +214,8 @@ class LclCore:
|
|
|
208
214
|
|
|
209
215
|
return result
|
|
210
216
|
|
|
211
|
-
def AND_OPERATOR(self, *args:
|
|
212
|
-
"""
|
|
217
|
+
def AND_OPERATOR(self: Self, *args: List[Any]) -> bool:
|
|
218
|
+
"""AND_OPERATOR Function"""
|
|
213
219
|
result = False
|
|
214
220
|
is_first = True
|
|
215
221
|
|
|
@@ -225,8 +231,8 @@ class LclCore:
|
|
|
225
231
|
|
|
226
232
|
return result
|
|
227
233
|
|
|
228
|
-
def SUM(self, *args:
|
|
229
|
-
"""
|
|
234
|
+
def SUM(self: Self, *args: List[Any]) -> float:
|
|
235
|
+
"""SUM Function"""
|
|
230
236
|
result = 0
|
|
231
237
|
|
|
232
238
|
for num in args:
|
|
@@ -240,8 +246,8 @@ class LclCore:
|
|
|
240
246
|
|
|
241
247
|
return result
|
|
242
248
|
|
|
243
|
-
def SUBSTRACT(self, *args:
|
|
244
|
-
"""
|
|
249
|
+
def SUBSTRACT(self: Self, *args: List[Any]) -> float:
|
|
250
|
+
"""SUBSTRACT Function"""
|
|
245
251
|
result = 0
|
|
246
252
|
is_first = True
|
|
247
253
|
|
|
@@ -260,8 +266,8 @@ class LclCore:
|
|
|
260
266
|
|
|
261
267
|
return result
|
|
262
268
|
|
|
263
|
-
def MULTIPLY(self, *args:
|
|
264
|
-
"""
|
|
269
|
+
def MULTIPLY(self: Self, *args: List[Any]) -> float:
|
|
270
|
+
"""MULTIPLY Function"""
|
|
265
271
|
result = 0
|
|
266
272
|
is_first = True
|
|
267
273
|
|
|
@@ -280,8 +286,8 @@ class LclCore:
|
|
|
280
286
|
|
|
281
287
|
return result
|
|
282
288
|
|
|
283
|
-
def DIVIDE(self, *args:
|
|
284
|
-
"""
|
|
289
|
+
def DIVIDE(self: Self, *args: List[Any]) -> float:
|
|
290
|
+
"""DIVIDE Function"""
|
|
285
291
|
result = 0
|
|
286
292
|
is_first = True
|
|
287
293
|
|
|
@@ -300,8 +306,8 @@ class LclCore:
|
|
|
300
306
|
|
|
301
307
|
return result
|
|
302
308
|
|
|
303
|
-
def TO_BOOL(self, *args:
|
|
304
|
-
"""
|
|
309
|
+
def TO_BOOL(self: Self, *args: List[Any]) -> str | None | bool:
|
|
310
|
+
"""TO_BOOL Function"""
|
|
305
311
|
if len(args) > 1:
|
|
306
312
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
307
313
|
|
|
@@ -310,8 +316,8 @@ class LclCore:
|
|
|
310
316
|
|
|
311
317
|
return bool(args[0])
|
|
312
318
|
|
|
313
|
-
def TO_STR(self, *args:
|
|
314
|
-
"""
|
|
319
|
+
def TO_STR(self: Self, *args: List[Any]) -> str | None:
|
|
320
|
+
"""TO_STR Function"""
|
|
315
321
|
if len(args) > 1:
|
|
316
322
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
317
323
|
|
|
@@ -320,8 +326,8 @@ class LclCore:
|
|
|
320
326
|
|
|
321
327
|
return str(args[0])
|
|
322
328
|
|
|
323
|
-
def TO_INT(self, *args:
|
|
324
|
-
"""
|
|
329
|
+
def TO_INT(self: Self, *args: List[Any]) -> str | None | int:
|
|
330
|
+
"""TO_INT Function"""
|
|
325
331
|
if len(args) > 1:
|
|
326
332
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
327
333
|
|
|
@@ -330,8 +336,8 @@ class LclCore:
|
|
|
330
336
|
|
|
331
337
|
return int(args[0])
|
|
332
338
|
|
|
333
|
-
def CEIL(self, *args:
|
|
334
|
-
"""
|
|
339
|
+
def CEIL(self: Self, *args: List[Any]) -> str | None | int:
|
|
340
|
+
"""CEIL Function"""
|
|
335
341
|
if len(args) > 1:
|
|
336
342
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
337
343
|
|
|
@@ -342,10 +348,11 @@ class LclCore:
|
|
|
342
348
|
return f'Invalid arguments - must be real number, not {type(args[0]).__name__}'
|
|
343
349
|
|
|
344
350
|
import math
|
|
351
|
+
|
|
345
352
|
return math.ceil(args[0])
|
|
346
353
|
|
|
347
|
-
def FLOOR(self, *args:
|
|
348
|
-
"""
|
|
354
|
+
def FLOOR(self: Self, *args: List[Any]) -> str | None | int:
|
|
355
|
+
"""FLOOR Function"""
|
|
349
356
|
if len(args) > 1:
|
|
350
357
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
351
358
|
|
|
@@ -356,10 +363,11 @@ class LclCore:
|
|
|
356
363
|
return f'Invalid arguments - must be real number, not {type(args[0]).__name__}'
|
|
357
364
|
|
|
358
365
|
import math
|
|
366
|
+
|
|
359
367
|
return math.floor(args[0])
|
|
360
368
|
|
|
361
|
-
def ROUND(self, *args:
|
|
362
|
-
"""
|
|
369
|
+
def ROUND(self: Self, *args: List[Any]) -> str | None | int:
|
|
370
|
+
"""ROUND Function"""
|
|
363
371
|
if len(args) > 1:
|
|
364
372
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
365
373
|
|
|
@@ -371,8 +379,8 @@ class LclCore:
|
|
|
371
379
|
|
|
372
380
|
return round(args[0])
|
|
373
381
|
|
|
374
|
-
def SQRT(self, *args:
|
|
375
|
-
"""
|
|
382
|
+
def SQRT(self: Self, *args: List[Any]) -> str | None | float:
|
|
383
|
+
"""SQRT Function"""
|
|
376
384
|
if len(args) > 1:
|
|
377
385
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
378
386
|
|
|
@@ -380,18 +388,19 @@ class LclCore:
|
|
|
380
388
|
return None
|
|
381
389
|
|
|
382
390
|
import math
|
|
391
|
+
|
|
383
392
|
return math.sqrt(args[0])
|
|
384
393
|
|
|
385
|
-
def CONCAT(self, *args:
|
|
386
|
-
"""
|
|
394
|
+
def CONCAT(self: Self, *args: List[Any]) -> str | None:
|
|
395
|
+
"""CONCAT Function"""
|
|
387
396
|
for val in args:
|
|
388
397
|
if val is None:
|
|
389
398
|
return None
|
|
390
399
|
|
|
391
400
|
return ''.join([str(val) for val in args])
|
|
392
401
|
|
|
393
|
-
def RANDOM(self, *args:
|
|
394
|
-
"""
|
|
402
|
+
def RANDOM(self: Self, *args: List[Any]) -> float | str:
|
|
403
|
+
"""RANDOM Function"""
|
|
395
404
|
if len(args) > 2:
|
|
396
405
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
397
406
|
if len(args) < 2:
|
|
@@ -401,10 +410,11 @@ class LclCore:
|
|
|
401
410
|
return None
|
|
402
411
|
|
|
403
412
|
import random
|
|
413
|
+
|
|
404
414
|
return random.random() * (float(args[1]) - float(args[0])) + float(args[0])
|
|
405
415
|
|
|
406
|
-
def RANDOM_INT(self, *args:
|
|
407
|
-
"""
|
|
416
|
+
def RANDOM_INT(self: Self, *args: List[Any]) -> int | str:
|
|
417
|
+
"""RANDOM_INT Function"""
|
|
408
418
|
if len(args) != 2:
|
|
409
419
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
410
420
|
|
|
@@ -412,10 +422,11 @@ class LclCore:
|
|
|
412
422
|
return None
|
|
413
423
|
|
|
414
424
|
import random
|
|
425
|
+
|
|
415
426
|
return random.randint(int(args[0]), int(args[1]))
|
|
416
427
|
|
|
417
|
-
def GREATER_THAN_OR_EQUALS_TO(self, *args:
|
|
418
|
-
"""
|
|
428
|
+
def GREATER_THAN_OR_EQUALS_TO(self: Self, *args: List[Any]) -> str | None | bool:
|
|
429
|
+
"""GREATER_THAN_OR_EQUALS_TO Function"""
|
|
419
430
|
if len(args) > 2:
|
|
420
431
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
421
432
|
if len(args) < 2:
|
|
@@ -428,8 +439,8 @@ class LclCore:
|
|
|
428
439
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
429
440
|
return args[0] >= args[1]
|
|
430
441
|
|
|
431
|
-
def GREATER_THAN(self, *args:
|
|
432
|
-
"""
|
|
442
|
+
def GREATER_THAN(self: Self, *args: List[Any]) -> str | None | bool:
|
|
443
|
+
"""GREATER_THAN Function"""
|
|
433
444
|
if len(args) > 2:
|
|
434
445
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
435
446
|
if len(args) < 2:
|
|
@@ -442,8 +453,8 @@ class LclCore:
|
|
|
442
453
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
443
454
|
return args[0] > args[1]
|
|
444
455
|
|
|
445
|
-
def LESS_THAN_OR_EQUALS_TO(self, *args:
|
|
446
|
-
"""
|
|
456
|
+
def LESS_THAN_OR_EQUALS_TO(self: Self, *args: List[Any]) -> str | None | bool:
|
|
457
|
+
"""LESS_THAN_OR_EQUALS_TO Function"""
|
|
447
458
|
if len(args) > 2:
|
|
448
459
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
449
460
|
if len(args) < 2:
|
|
@@ -456,8 +467,8 @@ class LclCore:
|
|
|
456
467
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
457
468
|
return args[0] <= args[1]
|
|
458
469
|
|
|
459
|
-
def LESS_THAN(self, *args:
|
|
460
|
-
"""
|
|
470
|
+
def LESS_THAN(self: Self, *args: List[Any]) -> str | None | bool:
|
|
471
|
+
"""LESS_THAN Function"""
|
|
461
472
|
if len(args) > 2:
|
|
462
473
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
463
474
|
if len(args) < 2:
|
|
@@ -470,8 +481,8 @@ class LclCore:
|
|
|
470
481
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
471
482
|
return args[0] < args[1]
|
|
472
483
|
|
|
473
|
-
def DIFFERENT(self, *args:
|
|
474
|
-
"""
|
|
484
|
+
def DIFFERENT(self: Self, *args: List[Any]) -> str | None | bool:
|
|
485
|
+
"""DIFFERENT Function"""
|
|
475
486
|
if len(args) > 2:
|
|
476
487
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
477
488
|
if len(args) < 2:
|
|
@@ -484,8 +495,8 @@ class LclCore:
|
|
|
484
495
|
return DIFFERENT_TYPES.format(arg1=type(args[0]).__name__, arg2=type(args[1]).__name__)
|
|
485
496
|
return args[0] != args[1]
|
|
486
497
|
|
|
487
|
-
def HEX_TO_STR(self, *args:
|
|
488
|
-
"""
|
|
498
|
+
def HEX_TO_STR(self: Self, *args: List[Any]) -> str | None:
|
|
499
|
+
"""HEX_TO_STR Function"""
|
|
489
500
|
if len(args) > 1:
|
|
490
501
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
491
502
|
|
|
@@ -502,8 +513,8 @@ class LclCore:
|
|
|
502
513
|
except Exception: # pylint: disable=broad-except
|
|
503
514
|
return 'Invalid hex string'
|
|
504
515
|
|
|
505
|
-
def STR_TO_HEX(self, *args:
|
|
506
|
-
"""
|
|
516
|
+
def STR_TO_HEX(self: Self, *args: List[Any]) -> str | None:
|
|
517
|
+
"""STR_TO_HEX Function"""
|
|
507
518
|
if len(args) > 1:
|
|
508
519
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
509
520
|
|
|
@@ -512,8 +523,8 @@ class LclCore:
|
|
|
512
523
|
|
|
513
524
|
return str(args[0]).encode('ASCII').hex()
|
|
514
525
|
|
|
515
|
-
def HEX_TO_INT(self, *args:
|
|
516
|
-
"""
|
|
526
|
+
def HEX_TO_INT(self: Self, *args: List[Any]) -> str | None | int:
|
|
527
|
+
"""HEX_TO_INT Function"""
|
|
517
528
|
if len(args) > 1:
|
|
518
529
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
519
530
|
|
|
@@ -525,8 +536,8 @@ class LclCore:
|
|
|
525
536
|
except Exception: # pylint: disable=broad-except
|
|
526
537
|
return 'Invalid hex string'
|
|
527
538
|
|
|
528
|
-
def INT_TO_HEX(self, *args:
|
|
529
|
-
"""
|
|
539
|
+
def INT_TO_HEX(self: Self, *args: List[Any]) -> str | None:
|
|
540
|
+
"""INT_TO_HEX Function"""
|
|
530
541
|
if len(args) > 1:
|
|
531
542
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
532
543
|
|
|
@@ -538,8 +549,8 @@ class LclCore:
|
|
|
538
549
|
except Exception: # pylint: disable=broad-except
|
|
539
550
|
return 'Invalid int value'
|
|
540
551
|
|
|
541
|
-
def TO_FLOAT(self, *args:
|
|
542
|
-
"""
|
|
552
|
+
def TO_FLOAT(self: Self, *args: List[Any]) -> str | None | float:
|
|
553
|
+
"""TO_FLOAT Function"""
|
|
543
554
|
if len(args) > 1:
|
|
544
555
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
545
556
|
|
|
@@ -551,8 +562,8 @@ class LclCore:
|
|
|
551
562
|
except Exception: # pylint: disable=broad-except
|
|
552
563
|
return f'Invalid arguments - must be real number, not {type(args[0]).__name__}'
|
|
553
564
|
|
|
554
|
-
def IS_PARAMETER_PRESENT(self, *args:
|
|
555
|
-
"""
|
|
565
|
+
def IS_PARAMETER_PRESENT(self: Self, *args: List[Any]) -> str | bool:
|
|
566
|
+
"""IS_PARAMETER_PRESENT Function"""
|
|
556
567
|
if len(args) > 1:
|
|
557
568
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
558
569
|
|
|
@@ -561,8 +572,8 @@ class LclCore:
|
|
|
561
572
|
|
|
562
573
|
return args[0] in self._payload
|
|
563
574
|
|
|
564
|
-
def IS_SENSOR_PRESENT(self, *args:
|
|
565
|
-
"""
|
|
575
|
+
def IS_SENSOR_PRESENT(self: Self, *args: List[Any]) -> str | bool:
|
|
576
|
+
"""IS_SENSOR_PRESENT Function"""
|
|
566
577
|
if len(args) > 1:
|
|
567
578
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
568
579
|
|
|
@@ -571,8 +582,8 @@ class LclCore:
|
|
|
571
582
|
|
|
572
583
|
return args[0] in self._sensors
|
|
573
584
|
|
|
574
|
-
def INSIDE_RANGE(self, *args:
|
|
575
|
-
"""
|
|
585
|
+
def INSIDE_RANGE(self: Self, *args: List[Any]) -> str | None | bool:
|
|
586
|
+
"""INSIDE_RANGE Function"""
|
|
576
587
|
if len(args) != 3:
|
|
577
588
|
return INVALID_NUMBER_OF_PARAMS.format(expected=3, received=len(args))
|
|
578
589
|
|
|
@@ -588,8 +599,8 @@ class LclCore:
|
|
|
588
599
|
|
|
589
600
|
return args[1] <= args[0] <= args[2]
|
|
590
601
|
|
|
591
|
-
def OUTSIDE_RANGE(self, *args:
|
|
592
|
-
"""
|
|
602
|
+
def OUTSIDE_RANGE(self: Self, *args: List[Any]) -> str | None | bool:
|
|
603
|
+
"""OUTSIDE_RANGE Function"""
|
|
593
604
|
if len(args) != 3:
|
|
594
605
|
return INVALID_NUMBER_OF_PARAMS.format(expected=3, received=len(args))
|
|
595
606
|
|
|
@@ -605,15 +616,15 @@ class LclCore:
|
|
|
605
616
|
|
|
606
617
|
return not args[1] <= args[0] <= args[2]
|
|
607
618
|
|
|
608
|
-
def GET_TIME_DIFFERENCE(self, *args:
|
|
609
|
-
"""
|
|
619
|
+
def GET_TIME_DIFFERENCE(self: Self, *args: List[Any]) -> str | float:
|
|
620
|
+
"""GET_TIME_DIFFERENCE Function"""
|
|
610
621
|
if len(args) > 0:
|
|
611
622
|
return INVALID_NUMBER_OF_PARAMS.format(expected=0, received=len(args))
|
|
612
623
|
|
|
613
624
|
return self._asset_constants.get('timeElapsed', 0)
|
|
614
625
|
|
|
615
|
-
def IF(self, *args: list[Any]) -> Any:
|
|
616
|
-
"""
|
|
626
|
+
def IF(self: Self, *args: list[Any]) -> Any:
|
|
627
|
+
"""IF Function"""
|
|
617
628
|
if len(args) != 3:
|
|
618
629
|
return INVALID_NUMBER_OF_PARAMS.format(expected=3, received=len(args))
|
|
619
630
|
|
|
@@ -622,14 +633,15 @@ class LclCore:
|
|
|
622
633
|
|
|
623
634
|
return args[1] if args[0] else args[2]
|
|
624
635
|
|
|
625
|
-
def NOW(self, *args:
|
|
626
|
-
"""
|
|
636
|
+
def NOW(self: Self, *args: List[Any]) -> float:
|
|
637
|
+
"""NOW Function"""
|
|
627
638
|
import zoneinfo
|
|
628
639
|
from datetime import datetime
|
|
640
|
+
|
|
629
641
|
return datetime.now(tz=zoneinfo.ZoneInfo('UTC')).timestamp()
|
|
630
642
|
|
|
631
|
-
def REGEX(self, *args:
|
|
632
|
-
"""
|
|
643
|
+
def REGEX(self: Self, *args: List[Any]) -> str | None | bool:
|
|
644
|
+
"""REGEX Function"""
|
|
633
645
|
if len(args) != 2:
|
|
634
646
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
635
647
|
|
|
@@ -640,18 +652,19 @@ class LclCore:
|
|
|
640
652
|
return PATTERN_INVALID.format(received=type(args[0]))
|
|
641
653
|
|
|
642
654
|
import re
|
|
655
|
+
|
|
643
656
|
pattern = re.compile(args[1])
|
|
644
657
|
return bool(pattern.match(args[0]))
|
|
645
658
|
|
|
646
|
-
def IS_NONE(self, *args:
|
|
647
|
-
"""
|
|
659
|
+
def IS_NONE(self: Self, *args: List[Any]) -> str | bool:
|
|
660
|
+
"""IS_NONE Function"""
|
|
648
661
|
if len(args) != 1:
|
|
649
662
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
650
663
|
|
|
651
664
|
return args[0] is None
|
|
652
665
|
|
|
653
|
-
def NOT(self, *args:
|
|
654
|
-
"""
|
|
666
|
+
def NOT(self: Self, *args: List[Any]) -> str | bool:
|
|
667
|
+
"""NOT Function"""
|
|
655
668
|
if len(args) != 1:
|
|
656
669
|
return INVALID_NUMBER_OF_PARAMS.format(expected=1, received=len(args))
|
|
657
670
|
|
|
@@ -660,8 +673,8 @@ class LclCore:
|
|
|
660
673
|
|
|
661
674
|
return not args[0]
|
|
662
675
|
|
|
663
|
-
def CONTAINS(self, *args:
|
|
664
|
-
"""
|
|
676
|
+
def CONTAINS(self: Self, *args: List[Any]) -> str | bool:
|
|
677
|
+
"""CONTAINS function"""
|
|
665
678
|
if len(args) != 2:
|
|
666
679
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
667
680
|
|
|
@@ -670,8 +683,8 @@ class LclCore:
|
|
|
670
683
|
|
|
671
684
|
return str(args[0]) in str(args[1])
|
|
672
685
|
|
|
673
|
-
def STARTS_WITH(self, *args:
|
|
674
|
-
"""
|
|
686
|
+
def STARTS_WITH(self: Self, *args: List[Any]) -> str | bool:
|
|
687
|
+
"""STARTS_WITH function"""
|
|
675
688
|
if len(args) != 2:
|
|
676
689
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
677
690
|
|
|
@@ -680,8 +693,8 @@ class LclCore:
|
|
|
680
693
|
|
|
681
694
|
return str(args[1]).startswith(str(args[0]))
|
|
682
695
|
|
|
683
|
-
def ENDS_WITH(self, *args:
|
|
684
|
-
"""
|
|
696
|
+
def ENDS_WITH(self: Self, *args: List[Any]) -> str | bool:
|
|
697
|
+
"""ENDS_WITH function"""
|
|
685
698
|
if len(args) != 2:
|
|
686
699
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
687
700
|
|
|
@@ -690,15 +703,15 @@ class LclCore:
|
|
|
690
703
|
|
|
691
704
|
return str(args[1]).endswith(str(args[0]))
|
|
692
705
|
|
|
693
|
-
def PRIMARY_DEVICE(self, *args:
|
|
694
|
-
"""
|
|
706
|
+
def PRIMARY_DEVICE(self: Self, *args: List[Any]) -> str:
|
|
707
|
+
"""PRIMARY_DEVICE function"""
|
|
695
708
|
if len(args) > 0:
|
|
696
709
|
return INVALID_NUMBER_OF_PARAMS.format(expected=0, received=len(args))
|
|
697
710
|
|
|
698
711
|
return self._asset_constants.get('primaryDevice', None)
|
|
699
712
|
|
|
700
|
-
def SUBSTRING(self, *args:
|
|
701
|
-
"""
|
|
713
|
+
def SUBSTRING(self: Self, *args: List[Any]) -> str:
|
|
714
|
+
"""Get a substring from string (args[0])"""
|
|
702
715
|
if len(args) < 2:
|
|
703
716
|
return INVALID_NUMBER_OF_PARAMS.format(
|
|
704
717
|
expected=2,
|
|
@@ -730,11 +743,11 @@ class LclCore:
|
|
|
730
743
|
if not isinstance(args[2], int):
|
|
731
744
|
return DIFFERENT_TYPES.format(arg1='str', arg2=type(args[2]).__name__)
|
|
732
745
|
|
|
733
|
-
return args[0][args[1]:args[2]]
|
|
734
|
-
return args[0][args[1]:]
|
|
746
|
+
return args[0][args[1] : args[2]]
|
|
747
|
+
return args[0][args[1] :]
|
|
735
748
|
|
|
736
|
-
def UNIX_TO_STR(self, *args:
|
|
737
|
-
"""
|
|
749
|
+
def UNIX_TO_STR(self: Self, *args: List[Any]) -> str:
|
|
750
|
+
"""Convert UNIX timestamp date (args[0]) to format (args[1]) string"""
|
|
738
751
|
if len(args) < 2:
|
|
739
752
|
return INVALID_NUMBER_OF_PARAMS.format(expected=2, received=len(args))
|
|
740
753
|
|
|
@@ -758,17 +771,15 @@ class LclCore:
|
|
|
758
771
|
except zoneinfo.ZoneInfoNotFoundError:
|
|
759
772
|
tz = zoneinfo.ZoneInfo('UTC')
|
|
760
773
|
|
|
761
|
-
return datetime
|
|
762
|
-
.fromtimestamp(int(args[0]), tz=zoneinfo.ZoneInfo('UTC'))\
|
|
763
|
-
.astimezone(tz)\
|
|
764
|
-
.strftime(args[1])
|
|
774
|
+
return datetime.fromtimestamp(int(args[0]), tz=zoneinfo.ZoneInfo('UTC')).astimezone(tz).strftime(args[1])
|
|
765
775
|
|
|
766
|
-
def VERSION(self, *args:
|
|
767
|
-
"""
|
|
776
|
+
def VERSION(self: Self, *args: List[Any]) -> str:
|
|
777
|
+
"""VERSION function"""
|
|
768
778
|
if len(args) > 0:
|
|
769
779
|
return INVALID_NUMBER_OF_PARAMS.format(expected=0, received=len(args))
|
|
770
780
|
|
|
771
781
|
import importlib.metadata
|
|
782
|
+
|
|
772
783
|
version = importlib.metadata.version('layrz_sdk')
|
|
773
784
|
|
|
774
785
|
return f'LCL {version} - Layrz SDK Runtime'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: layrz-sdk
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.8
|
|
4
4
|
Summary: Layrz SDK for Python
|
|
5
5
|
Author-email: "Golden M, Inc." <software@goldenm.com>
|
|
6
6
|
Maintainer-email: Kenny Mochizuki <kenny@goldenm.com>, Luis Reyes <lreyes@goldenm.com>, Kasen Li <kli@goldenm.com>
|
|
@@ -26,6 +26,11 @@ Managed by Golden M, Inc.
|
|
|
26
26
|
It's a group of tools/classes/SDKs that can be help you to implement scripts into Layrz modules, or
|
|
27
27
|
incorporate them into your own projects.
|
|
28
28
|
|
|
29
|
+
## Requirements
|
|
30
|
+
This library uses at least Python 3.10 or higher to work.
|
|
31
|
+
|
|
32
|
+
If you want to encrypt MS Excel files, you need to have the [`msoffice`](https://github.com/herumi/msoffice) utility installed in your system.
|
|
33
|
+
|
|
29
34
|
## Documentation
|
|
30
35
|
It's available in our documentation site [developers.layrz.com](https://developers.layrz.com/Kits/Sdk)
|
|
31
36
|
|