IncludeCPP 3.6.0__py3-none-any.whl → 3.7.1__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.
- includecpp/__init__.py +1 -1
- includecpp/cli/commands.py +418 -0
- includecpp/core/cssl/CSSL_DOCUMENTATION.md +275 -13
- includecpp/core/cssl/cssl_builtins.py +114 -0
- includecpp/core/cssl/cssl_builtins.pyi +1393 -0
- includecpp/core/cssl/cssl_parser.py +174 -59
- includecpp/core/cssl/cssl_runtime.py +273 -1
- includecpp/core/cssl/cssl_types.py +224 -2
- includecpp/vscode/cssl/package.json +24 -4
- includecpp/vscode/cssl/snippets/cssl.snippets.json +1080 -0
- includecpp/vscode/cssl/syntaxes/cssl.tmLanguage.json +127 -7
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/METADATA +1 -1
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/RECORD +17 -15
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/WHEEL +0 -0
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/entry_points.txt +0 -0
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/licenses/LICENSE +0 -0
- {includecpp-3.6.0.dist-info → includecpp-3.7.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,1393 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CSSL Built-in Functions Type Stubs
|
|
3
|
+
===================================
|
|
4
|
+
|
|
5
|
+
This file provides type hints and documentation for all CSSL built-in functions.
|
|
6
|
+
Total: 150+ functions across 15 categories.
|
|
7
|
+
|
|
8
|
+
Categories:
|
|
9
|
+
- Output Functions (6)
|
|
10
|
+
- Type Conversion (6)
|
|
11
|
+
- Type Checking (8)
|
|
12
|
+
- String Operations (22)
|
|
13
|
+
- Array/List Operations (17)
|
|
14
|
+
- Dictionary Operations (13)
|
|
15
|
+
- Math Functions (26)
|
|
16
|
+
- Date/Time Functions (7)
|
|
17
|
+
- File System Functions (23)
|
|
18
|
+
- JSON Functions (13)
|
|
19
|
+
- Instance Introspection (8)
|
|
20
|
+
- Regex Functions (4)
|
|
21
|
+
- Hash Functions (3)
|
|
22
|
+
- System/Control Functions (15)
|
|
23
|
+
- CSSL-Specific Functions (10)
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from typing import Any, List, Dict, Optional, Callable, Union, Tuple
|
|
27
|
+
|
|
28
|
+
# =============================================================================
|
|
29
|
+
# OUTPUT FUNCTIONS
|
|
30
|
+
# =============================================================================
|
|
31
|
+
|
|
32
|
+
def print(*args: Any, sep: str = " ", end: str = "") -> None:
|
|
33
|
+
"""Print values without newline.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
*args: Values to print
|
|
37
|
+
sep: Separator between values (default: space)
|
|
38
|
+
end: String appended after last value (default: empty)
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
print("Hello", "World"); // Output: Hello World
|
|
42
|
+
"""
|
|
43
|
+
...
|
|
44
|
+
|
|
45
|
+
def printl(*args: Any, sep: str = " ") -> None:
|
|
46
|
+
"""Print values with newline (primary CSSL print function).
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
*args: Values to print
|
|
50
|
+
sep: Separator between values (default: space)
|
|
51
|
+
|
|
52
|
+
Example:
|
|
53
|
+
printl("Hello World"); // Output: Hello World\\n
|
|
54
|
+
"""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
def println(*args: Any, sep: str = " ") -> None:
|
|
58
|
+
"""Alias for printl. Print values with newline."""
|
|
59
|
+
...
|
|
60
|
+
|
|
61
|
+
def debug(*args: Any) -> None:
|
|
62
|
+
"""Print debug information with [DEBUG] prefix.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
*args: Debug values to display
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
debug("Variable x =", x); // Output: [DEBUG] Variable x = 42
|
|
69
|
+
"""
|
|
70
|
+
...
|
|
71
|
+
|
|
72
|
+
def error(*args: Any) -> None:
|
|
73
|
+
"""Print error message with [ERROR] prefix.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
*args: Error message components
|
|
77
|
+
|
|
78
|
+
Example:
|
|
79
|
+
error("File not found:", path);
|
|
80
|
+
"""
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
def warn(*args: Any) -> None:
|
|
84
|
+
"""Print warning message with [WARN] prefix.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
*args: Warning message components
|
|
88
|
+
"""
|
|
89
|
+
...
|
|
90
|
+
|
|
91
|
+
# =============================================================================
|
|
92
|
+
# TYPE CONVERSION FUNCTIONS
|
|
93
|
+
# =============================================================================
|
|
94
|
+
|
|
95
|
+
def int(value: Any) -> int:
|
|
96
|
+
"""Convert value to integer.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
value: Value to convert (string, float, bool)
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Integer representation
|
|
103
|
+
|
|
104
|
+
Example:
|
|
105
|
+
int("42"); // 42
|
|
106
|
+
int(3.14); // 3
|
|
107
|
+
int(true); // 1
|
|
108
|
+
"""
|
|
109
|
+
...
|
|
110
|
+
|
|
111
|
+
def float(value: Any) -> float:
|
|
112
|
+
"""Convert value to floating-point number.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
value: Value to convert
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Float representation
|
|
119
|
+
|
|
120
|
+
Example:
|
|
121
|
+
float("3.14"); // 3.14
|
|
122
|
+
float(42); // 42.0
|
|
123
|
+
"""
|
|
124
|
+
...
|
|
125
|
+
|
|
126
|
+
def str(value: Any) -> str:
|
|
127
|
+
"""Convert value to string.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
value: Value to convert
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
String representation
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
str(42); // "42"
|
|
137
|
+
str(true); // "True"
|
|
138
|
+
"""
|
|
139
|
+
...
|
|
140
|
+
|
|
141
|
+
def bool(value: Any) -> bool:
|
|
142
|
+
"""Convert value to boolean.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
value: Value to convert
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Boolean representation
|
|
149
|
+
|
|
150
|
+
Example:
|
|
151
|
+
bool(1); // true
|
|
152
|
+
bool(""); // false
|
|
153
|
+
bool("text"); // true
|
|
154
|
+
"""
|
|
155
|
+
...
|
|
156
|
+
|
|
157
|
+
def list(value: Any = None) -> List[Any]:
|
|
158
|
+
"""Convert value to list or create empty list.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
value: Optional value to convert (string, iterable)
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
List representation
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
list("abc"); // ["a", "b", "c"]
|
|
168
|
+
list(); // []
|
|
169
|
+
"""
|
|
170
|
+
...
|
|
171
|
+
|
|
172
|
+
def dict(value: Any = None) -> Dict[str, Any]:
|
|
173
|
+
"""Convert value to dictionary or create empty dict.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
value: Optional value to convert
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
Dictionary representation
|
|
180
|
+
"""
|
|
181
|
+
...
|
|
182
|
+
|
|
183
|
+
# =============================================================================
|
|
184
|
+
# TYPE CHECKING FUNCTIONS
|
|
185
|
+
# =============================================================================
|
|
186
|
+
|
|
187
|
+
def typeof(value: Any) -> str:
|
|
188
|
+
"""Get type name of value.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
value: Value to check
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Type name as string
|
|
195
|
+
|
|
196
|
+
Example:
|
|
197
|
+
typeof(42); // "int"
|
|
198
|
+
typeof("hello"); // "str"
|
|
199
|
+
typeof([1,2,3]); // "list"
|
|
200
|
+
"""
|
|
201
|
+
...
|
|
202
|
+
|
|
203
|
+
def isinstance(value: Any, type_name: str) -> bool:
|
|
204
|
+
"""Check if value is instance of type.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
value: Value to check
|
|
208
|
+
type_name: Type name string
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
True if value is instance of type
|
|
212
|
+
"""
|
|
213
|
+
...
|
|
214
|
+
|
|
215
|
+
def isint(value: Any) -> bool:
|
|
216
|
+
"""Check if value is an integer."""
|
|
217
|
+
...
|
|
218
|
+
|
|
219
|
+
def isfloat(value: Any) -> bool:
|
|
220
|
+
"""Check if value is a float."""
|
|
221
|
+
...
|
|
222
|
+
|
|
223
|
+
def isstr(value: Any) -> bool:
|
|
224
|
+
"""Check if value is a string."""
|
|
225
|
+
...
|
|
226
|
+
|
|
227
|
+
def isbool(value: Any) -> bool:
|
|
228
|
+
"""Check if value is a boolean."""
|
|
229
|
+
...
|
|
230
|
+
|
|
231
|
+
def islist(value: Any) -> bool:
|
|
232
|
+
"""Check if value is a list/array."""
|
|
233
|
+
...
|
|
234
|
+
|
|
235
|
+
def isdict(value: Any) -> bool:
|
|
236
|
+
"""Check if value is a dictionary."""
|
|
237
|
+
...
|
|
238
|
+
|
|
239
|
+
def isnull(value: Any) -> bool:
|
|
240
|
+
"""Check if value is null/None."""
|
|
241
|
+
...
|
|
242
|
+
|
|
243
|
+
# =============================================================================
|
|
244
|
+
# STRING OPERATIONS
|
|
245
|
+
# =============================================================================
|
|
246
|
+
|
|
247
|
+
def len(value: Union[str, List, Dict]) -> int:
|
|
248
|
+
"""Get length of string, list, or dictionary.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
value: String, list, or dictionary
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
Number of characters/elements/keys
|
|
255
|
+
|
|
256
|
+
Example:
|
|
257
|
+
len("hello"); // 5
|
|
258
|
+
len([1,2,3]); // 3
|
|
259
|
+
"""
|
|
260
|
+
...
|
|
261
|
+
|
|
262
|
+
def upper(s: str) -> str:
|
|
263
|
+
"""Convert string to uppercase.
|
|
264
|
+
|
|
265
|
+
Example:
|
|
266
|
+
upper("hello"); // "HELLO"
|
|
267
|
+
"""
|
|
268
|
+
...
|
|
269
|
+
|
|
270
|
+
def lower(s: str) -> str:
|
|
271
|
+
"""Convert string to lowercase.
|
|
272
|
+
|
|
273
|
+
Example:
|
|
274
|
+
lower("HELLO"); // "hello"
|
|
275
|
+
"""
|
|
276
|
+
...
|
|
277
|
+
|
|
278
|
+
def trim(s: str) -> str:
|
|
279
|
+
"""Remove whitespace from both ends of string.
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
trim(" hello "); // "hello"
|
|
283
|
+
"""
|
|
284
|
+
...
|
|
285
|
+
|
|
286
|
+
def ltrim(s: str) -> str:
|
|
287
|
+
"""Remove whitespace from left side of string."""
|
|
288
|
+
...
|
|
289
|
+
|
|
290
|
+
def rtrim(s: str) -> str:
|
|
291
|
+
"""Remove whitespace from right side of string."""
|
|
292
|
+
...
|
|
293
|
+
|
|
294
|
+
def split(s: str, delimiter: str = " ") -> List[str]:
|
|
295
|
+
"""Split string into list by delimiter.
|
|
296
|
+
|
|
297
|
+
Args:
|
|
298
|
+
s: String to split
|
|
299
|
+
delimiter: Split delimiter (default: space)
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
List of substrings
|
|
303
|
+
|
|
304
|
+
Example:
|
|
305
|
+
split("a,b,c", ","); // ["a", "b", "c"]
|
|
306
|
+
"""
|
|
307
|
+
...
|
|
308
|
+
|
|
309
|
+
def join(arr: List[str], delimiter: str = "") -> str:
|
|
310
|
+
"""Join list elements into string.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
arr: List of strings
|
|
314
|
+
delimiter: Join delimiter
|
|
315
|
+
|
|
316
|
+
Returns:
|
|
317
|
+
Joined string
|
|
318
|
+
|
|
319
|
+
Example:
|
|
320
|
+
join(["a", "b", "c"], "-"); // "a-b-c"
|
|
321
|
+
"""
|
|
322
|
+
...
|
|
323
|
+
|
|
324
|
+
def replace(s: str, old: str, new: str) -> str:
|
|
325
|
+
"""Replace all occurrences of substring.
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
s: Original string
|
|
329
|
+
old: Substring to replace
|
|
330
|
+
new: Replacement string
|
|
331
|
+
|
|
332
|
+
Example:
|
|
333
|
+
replace("hello", "l", "x"); // "hexxo"
|
|
334
|
+
"""
|
|
335
|
+
...
|
|
336
|
+
|
|
337
|
+
def substr(s: str, start: int, length: int = None) -> str:
|
|
338
|
+
"""Extract substring.
|
|
339
|
+
|
|
340
|
+
Args:
|
|
341
|
+
s: Original string
|
|
342
|
+
start: Start index (0-based)
|
|
343
|
+
length: Number of characters (optional)
|
|
344
|
+
|
|
345
|
+
Example:
|
|
346
|
+
substr("hello", 1, 3); // "ell"
|
|
347
|
+
"""
|
|
348
|
+
...
|
|
349
|
+
|
|
350
|
+
def contains(s: str, substring: str) -> bool:
|
|
351
|
+
"""Check if string contains substring.
|
|
352
|
+
|
|
353
|
+
Example:
|
|
354
|
+
contains("hello", "ell"); // true
|
|
355
|
+
"""
|
|
356
|
+
...
|
|
357
|
+
|
|
358
|
+
def startswith(s: str, prefix: str) -> bool:
|
|
359
|
+
"""Check if string starts with prefix.
|
|
360
|
+
|
|
361
|
+
Example:
|
|
362
|
+
startswith("hello", "he"); // true
|
|
363
|
+
"""
|
|
364
|
+
...
|
|
365
|
+
|
|
366
|
+
def endswith(s: str, suffix: str) -> bool:
|
|
367
|
+
"""Check if string ends with suffix.
|
|
368
|
+
|
|
369
|
+
Example:
|
|
370
|
+
endswith("hello", "lo"); // true
|
|
371
|
+
"""
|
|
372
|
+
...
|
|
373
|
+
|
|
374
|
+
def format(template: str, *args: Any) -> str:
|
|
375
|
+
"""Format string with placeholders.
|
|
376
|
+
|
|
377
|
+
Args:
|
|
378
|
+
template: String with {} placeholders
|
|
379
|
+
*args: Values to insert
|
|
380
|
+
|
|
381
|
+
Example:
|
|
382
|
+
format("Hello, {}!", "World"); // "Hello, World!"
|
|
383
|
+
"""
|
|
384
|
+
...
|
|
385
|
+
|
|
386
|
+
def concat(*strings: str) -> str:
|
|
387
|
+
"""Concatenate multiple strings.
|
|
388
|
+
|
|
389
|
+
Example:
|
|
390
|
+
concat("a", "b", "c"); // "abc"
|
|
391
|
+
"""
|
|
392
|
+
...
|
|
393
|
+
|
|
394
|
+
def repeat(s: str, count: int) -> str:
|
|
395
|
+
"""Repeat string n times.
|
|
396
|
+
|
|
397
|
+
Example:
|
|
398
|
+
repeat("ab", 3); // "ababab"
|
|
399
|
+
"""
|
|
400
|
+
...
|
|
401
|
+
|
|
402
|
+
def reverse(s: str) -> str:
|
|
403
|
+
"""Reverse string.
|
|
404
|
+
|
|
405
|
+
Example:
|
|
406
|
+
reverse("hello"); // "olleh"
|
|
407
|
+
"""
|
|
408
|
+
...
|
|
409
|
+
|
|
410
|
+
def indexof(s: str, substring: str, start: int = 0) -> int:
|
|
411
|
+
"""Find first occurrence of substring.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
s: String to search in
|
|
415
|
+
substring: Substring to find
|
|
416
|
+
start: Start position (default: 0)
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
Index of first occurrence, -1 if not found
|
|
420
|
+
|
|
421
|
+
Example:
|
|
422
|
+
indexof("hello", "l"); // 2
|
|
423
|
+
"""
|
|
424
|
+
...
|
|
425
|
+
|
|
426
|
+
def lastindexof(s: str, substring: str) -> int:
|
|
427
|
+
"""Find last occurrence of substring.
|
|
428
|
+
|
|
429
|
+
Returns:
|
|
430
|
+
Index of last occurrence, -1 if not found
|
|
431
|
+
"""
|
|
432
|
+
...
|
|
433
|
+
|
|
434
|
+
def padleft(s: str, length: int, char: str = " ") -> str:
|
|
435
|
+
"""Pad string on left to specified length.
|
|
436
|
+
|
|
437
|
+
Example:
|
|
438
|
+
padleft("42", 5, "0"); // "00042"
|
|
439
|
+
"""
|
|
440
|
+
...
|
|
441
|
+
|
|
442
|
+
def padright(s: str, length: int, char: str = " ") -> str:
|
|
443
|
+
"""Pad string on right to specified length.
|
|
444
|
+
|
|
445
|
+
Example:
|
|
446
|
+
padright("42", 5, "0"); // "42000"
|
|
447
|
+
"""
|
|
448
|
+
...
|
|
449
|
+
|
|
450
|
+
def capitalize(s: str) -> str:
|
|
451
|
+
"""Capitalize first character.
|
|
452
|
+
|
|
453
|
+
Example:
|
|
454
|
+
capitalize("hello"); // "Hello"
|
|
455
|
+
"""
|
|
456
|
+
...
|
|
457
|
+
|
|
458
|
+
def title(s: str) -> str:
|
|
459
|
+
"""Capitalize first character of each word.
|
|
460
|
+
|
|
461
|
+
Example:
|
|
462
|
+
title("hello world"); // "Hello World"
|
|
463
|
+
"""
|
|
464
|
+
...
|
|
465
|
+
|
|
466
|
+
# =============================================================================
|
|
467
|
+
# ARRAY/LIST OPERATIONS
|
|
468
|
+
# =============================================================================
|
|
469
|
+
|
|
470
|
+
def push(arr: List[Any], value: Any) -> List[Any]:
|
|
471
|
+
"""Add element to end of array.
|
|
472
|
+
|
|
473
|
+
Args:
|
|
474
|
+
arr: Target array
|
|
475
|
+
value: Value to add
|
|
476
|
+
|
|
477
|
+
Returns:
|
|
478
|
+
Modified array
|
|
479
|
+
|
|
480
|
+
Example:
|
|
481
|
+
push([1, 2], 3); // [1, 2, 3]
|
|
482
|
+
"""
|
|
483
|
+
...
|
|
484
|
+
|
|
485
|
+
def pop(arr: List[Any]) -> Any:
|
|
486
|
+
"""Remove and return last element.
|
|
487
|
+
|
|
488
|
+
Returns:
|
|
489
|
+
Removed element
|
|
490
|
+
|
|
491
|
+
Example:
|
|
492
|
+
pop([1, 2, 3]); // 3, array becomes [1, 2]
|
|
493
|
+
"""
|
|
494
|
+
...
|
|
495
|
+
|
|
496
|
+
def shift(arr: List[Any]) -> Any:
|
|
497
|
+
"""Remove and return first element.
|
|
498
|
+
|
|
499
|
+
Returns:
|
|
500
|
+
Removed element
|
|
501
|
+
"""
|
|
502
|
+
...
|
|
503
|
+
|
|
504
|
+
def unshift(arr: List[Any], value: Any) -> List[Any]:
|
|
505
|
+
"""Add element to beginning of array.
|
|
506
|
+
|
|
507
|
+
Returns:
|
|
508
|
+
Modified array
|
|
509
|
+
"""
|
|
510
|
+
...
|
|
511
|
+
|
|
512
|
+
def slice(arr: List[Any], start: int, end: int = None) -> List[Any]:
|
|
513
|
+
"""Extract portion of array.
|
|
514
|
+
|
|
515
|
+
Args:
|
|
516
|
+
arr: Source array
|
|
517
|
+
start: Start index
|
|
518
|
+
end: End index (exclusive, optional)
|
|
519
|
+
|
|
520
|
+
Returns:
|
|
521
|
+
New array with extracted elements
|
|
522
|
+
|
|
523
|
+
Example:
|
|
524
|
+
slice([1, 2, 3, 4], 1, 3); // [2, 3]
|
|
525
|
+
"""
|
|
526
|
+
...
|
|
527
|
+
|
|
528
|
+
def sort(arr: List[Any]) -> List[Any]:
|
|
529
|
+
"""Sort array in ascending order.
|
|
530
|
+
|
|
531
|
+
Returns:
|
|
532
|
+
Sorted array
|
|
533
|
+
"""
|
|
534
|
+
...
|
|
535
|
+
|
|
536
|
+
def rsort(arr: List[Any]) -> List[Any]:
|
|
537
|
+
"""Sort array in descending order.
|
|
538
|
+
|
|
539
|
+
Returns:
|
|
540
|
+
Reverse sorted array
|
|
541
|
+
"""
|
|
542
|
+
...
|
|
543
|
+
|
|
544
|
+
def unique(arr: List[Any]) -> List[Any]:
|
|
545
|
+
"""Remove duplicate elements.
|
|
546
|
+
|
|
547
|
+
Returns:
|
|
548
|
+
Array with unique elements only
|
|
549
|
+
|
|
550
|
+
Example:
|
|
551
|
+
unique([1, 2, 2, 3]); // [1, 2, 3]
|
|
552
|
+
"""
|
|
553
|
+
...
|
|
554
|
+
|
|
555
|
+
def flatten(arr: List[Any]) -> List[Any]:
|
|
556
|
+
"""Flatten nested arrays.
|
|
557
|
+
|
|
558
|
+
Example:
|
|
559
|
+
flatten([[1, 2], [3, 4]]); // [1, 2, 3, 4]
|
|
560
|
+
"""
|
|
561
|
+
...
|
|
562
|
+
|
|
563
|
+
def filter(arr: List[Any], predicate: Callable[[Any], bool]) -> List[Any]:
|
|
564
|
+
"""Filter array by predicate function.
|
|
565
|
+
|
|
566
|
+
Args:
|
|
567
|
+
arr: Source array
|
|
568
|
+
predicate: Function returning true for elements to keep
|
|
569
|
+
|
|
570
|
+
Returns:
|
|
571
|
+
Filtered array
|
|
572
|
+
"""
|
|
573
|
+
...
|
|
574
|
+
|
|
575
|
+
def map(arr: List[Any], func: Callable[[Any], Any]) -> List[Any]:
|
|
576
|
+
"""Apply function to each element.
|
|
577
|
+
|
|
578
|
+
Args:
|
|
579
|
+
arr: Source array
|
|
580
|
+
func: Transformation function
|
|
581
|
+
|
|
582
|
+
Returns:
|
|
583
|
+
Transformed array
|
|
584
|
+
"""
|
|
585
|
+
...
|
|
586
|
+
|
|
587
|
+
def reduce(arr: List[Any], func: Callable[[Any, Any], Any], initial: Any = None) -> Any:
|
|
588
|
+
"""Reduce array to single value.
|
|
589
|
+
|
|
590
|
+
Args:
|
|
591
|
+
arr: Source array
|
|
592
|
+
func: Reducer function (accumulator, current) -> result
|
|
593
|
+
initial: Initial accumulator value
|
|
594
|
+
|
|
595
|
+
Returns:
|
|
596
|
+
Reduced value
|
|
597
|
+
"""
|
|
598
|
+
...
|
|
599
|
+
|
|
600
|
+
def find(arr: List[Any], predicate: Callable[[Any], bool]) -> Optional[Any]:
|
|
601
|
+
"""Find first element matching predicate.
|
|
602
|
+
|
|
603
|
+
Returns:
|
|
604
|
+
First matching element or null
|
|
605
|
+
"""
|
|
606
|
+
...
|
|
607
|
+
|
|
608
|
+
def findindex(arr: List[Any], predicate: Callable[[Any], bool]) -> int:
|
|
609
|
+
"""Find index of first matching element.
|
|
610
|
+
|
|
611
|
+
Returns:
|
|
612
|
+
Index or -1 if not found
|
|
613
|
+
"""
|
|
614
|
+
...
|
|
615
|
+
|
|
616
|
+
def range(start_or_stop: int, stop: int = None, step: int = 1) -> List[int]:
|
|
617
|
+
"""Generate range of integers.
|
|
618
|
+
|
|
619
|
+
Args:
|
|
620
|
+
start_or_stop: Start value (or stop if only arg)
|
|
621
|
+
stop: Stop value (exclusive)
|
|
622
|
+
step: Step increment
|
|
623
|
+
|
|
624
|
+
Returns:
|
|
625
|
+
List of integers
|
|
626
|
+
|
|
627
|
+
Example:
|
|
628
|
+
range(5); // [0, 1, 2, 3, 4]
|
|
629
|
+
range(1, 5); // [1, 2, 3, 4]
|
|
630
|
+
range(0, 10, 2); // [0, 2, 4, 6, 8]
|
|
631
|
+
"""
|
|
632
|
+
...
|
|
633
|
+
|
|
634
|
+
# =============================================================================
|
|
635
|
+
# DICTIONARY OPERATIONS
|
|
636
|
+
# =============================================================================
|
|
637
|
+
|
|
638
|
+
def keys(d: Dict[str, Any]) -> List[str]:
|
|
639
|
+
"""Get all dictionary keys.
|
|
640
|
+
|
|
641
|
+
Returns:
|
|
642
|
+
List of keys
|
|
643
|
+
"""
|
|
644
|
+
...
|
|
645
|
+
|
|
646
|
+
def values(d: Dict[str, Any]) -> List[Any]:
|
|
647
|
+
"""Get all dictionary values.
|
|
648
|
+
|
|
649
|
+
Returns:
|
|
650
|
+
List of values
|
|
651
|
+
"""
|
|
652
|
+
...
|
|
653
|
+
|
|
654
|
+
def items(d: Dict[str, Any]) -> List[Tuple[str, Any]]:
|
|
655
|
+
"""Get all key-value pairs.
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
List of (key, value) tuples
|
|
659
|
+
"""
|
|
660
|
+
...
|
|
661
|
+
|
|
662
|
+
def haskey(d: Dict[str, Any], key: str) -> bool:
|
|
663
|
+
"""Check if dictionary has key.
|
|
664
|
+
|
|
665
|
+
Example:
|
|
666
|
+
haskey({"a": 1}, "a"); // true
|
|
667
|
+
"""
|
|
668
|
+
...
|
|
669
|
+
|
|
670
|
+
def getkey(d: Dict[str, Any], key: str, default: Any = None) -> Any:
|
|
671
|
+
"""Get value by key with optional default.
|
|
672
|
+
|
|
673
|
+
Args:
|
|
674
|
+
d: Dictionary
|
|
675
|
+
key: Key to look up
|
|
676
|
+
default: Default value if key not found
|
|
677
|
+
|
|
678
|
+
Returns:
|
|
679
|
+
Value or default
|
|
680
|
+
"""
|
|
681
|
+
...
|
|
682
|
+
|
|
683
|
+
def setkey(d: Dict[str, Any], key: str, value: Any) -> Dict[str, Any]:
|
|
684
|
+
"""Set key-value pair in dictionary.
|
|
685
|
+
|
|
686
|
+
Returns:
|
|
687
|
+
Modified dictionary
|
|
688
|
+
"""
|
|
689
|
+
...
|
|
690
|
+
|
|
691
|
+
def delkey(d: Dict[str, Any], key: str) -> Dict[str, Any]:
|
|
692
|
+
"""Delete key from dictionary.
|
|
693
|
+
|
|
694
|
+
Returns:
|
|
695
|
+
Modified dictionary
|
|
696
|
+
"""
|
|
697
|
+
...
|
|
698
|
+
|
|
699
|
+
def merge(*dicts: Dict[str, Any]) -> Dict[str, Any]:
|
|
700
|
+
"""Merge multiple dictionaries.
|
|
701
|
+
|
|
702
|
+
Returns:
|
|
703
|
+
Merged dictionary (later values override earlier)
|
|
704
|
+
"""
|
|
705
|
+
...
|
|
706
|
+
|
|
707
|
+
# =============================================================================
|
|
708
|
+
# MATH FUNCTIONS
|
|
709
|
+
# =============================================================================
|
|
710
|
+
|
|
711
|
+
def abs(x: Union[int, float]) -> Union[int, float]:
|
|
712
|
+
"""Absolute value."""
|
|
713
|
+
...
|
|
714
|
+
|
|
715
|
+
def min(*values: Union[int, float]) -> Union[int, float]:
|
|
716
|
+
"""Minimum value."""
|
|
717
|
+
...
|
|
718
|
+
|
|
719
|
+
def max(*values: Union[int, float]) -> Union[int, float]:
|
|
720
|
+
"""Maximum value."""
|
|
721
|
+
...
|
|
722
|
+
|
|
723
|
+
def sum(arr: List[Union[int, float]]) -> Union[int, float]:
|
|
724
|
+
"""Sum of array elements."""
|
|
725
|
+
...
|
|
726
|
+
|
|
727
|
+
def avg(arr: List[Union[int, float]]) -> float:
|
|
728
|
+
"""Average of array elements."""
|
|
729
|
+
...
|
|
730
|
+
|
|
731
|
+
def round(x: float, decimals: int = 0) -> float:
|
|
732
|
+
"""Round to specified decimal places."""
|
|
733
|
+
...
|
|
734
|
+
|
|
735
|
+
def floor(x: float) -> int:
|
|
736
|
+
"""Round down to nearest integer."""
|
|
737
|
+
...
|
|
738
|
+
|
|
739
|
+
def ceil(x: float) -> int:
|
|
740
|
+
"""Round up to nearest integer."""
|
|
741
|
+
...
|
|
742
|
+
|
|
743
|
+
def pow(base: float, exponent: float) -> float:
|
|
744
|
+
"""Raise base to power."""
|
|
745
|
+
...
|
|
746
|
+
|
|
747
|
+
def sqrt(x: float) -> float:
|
|
748
|
+
"""Square root."""
|
|
749
|
+
...
|
|
750
|
+
|
|
751
|
+
def random() -> float:
|
|
752
|
+
"""Random float between 0 and 1."""
|
|
753
|
+
...
|
|
754
|
+
|
|
755
|
+
def randint(min_val: int, max_val: int) -> int:
|
|
756
|
+
"""Random integer in range [min, max]."""
|
|
757
|
+
...
|
|
758
|
+
|
|
759
|
+
def sin(x: float) -> float:
|
|
760
|
+
"""Sine (radians)."""
|
|
761
|
+
...
|
|
762
|
+
|
|
763
|
+
def cos(x: float) -> float:
|
|
764
|
+
"""Cosine (radians)."""
|
|
765
|
+
...
|
|
766
|
+
|
|
767
|
+
def tan(x: float) -> float:
|
|
768
|
+
"""Tangent (radians)."""
|
|
769
|
+
...
|
|
770
|
+
|
|
771
|
+
def asin(x: float) -> float:
|
|
772
|
+
"""Arc sine (returns radians)."""
|
|
773
|
+
...
|
|
774
|
+
|
|
775
|
+
def acos(x: float) -> float:
|
|
776
|
+
"""Arc cosine (returns radians)."""
|
|
777
|
+
...
|
|
778
|
+
|
|
779
|
+
def atan(x: float) -> float:
|
|
780
|
+
"""Arc tangent (returns radians)."""
|
|
781
|
+
...
|
|
782
|
+
|
|
783
|
+
def atan2(y: float, x: float) -> float:
|
|
784
|
+
"""Two-argument arc tangent."""
|
|
785
|
+
...
|
|
786
|
+
|
|
787
|
+
def log(x: float, base: float = None) -> float:
|
|
788
|
+
"""Natural logarithm (or log with specified base)."""
|
|
789
|
+
...
|
|
790
|
+
|
|
791
|
+
def log10(x: float) -> float:
|
|
792
|
+
"""Base-10 logarithm."""
|
|
793
|
+
...
|
|
794
|
+
|
|
795
|
+
def exp(x: float) -> float:
|
|
796
|
+
"""Exponential function (e^x)."""
|
|
797
|
+
...
|
|
798
|
+
|
|
799
|
+
def pi() -> float:
|
|
800
|
+
"""Mathematical constant pi (3.14159...)."""
|
|
801
|
+
...
|
|
802
|
+
|
|
803
|
+
def e() -> float:
|
|
804
|
+
"""Mathematical constant e (2.71828...)."""
|
|
805
|
+
...
|
|
806
|
+
|
|
807
|
+
def radians(degrees: float) -> float:
|
|
808
|
+
"""Convert degrees to radians."""
|
|
809
|
+
...
|
|
810
|
+
|
|
811
|
+
def degrees(radians: float) -> float:
|
|
812
|
+
"""Convert radians to degrees."""
|
|
813
|
+
...
|
|
814
|
+
|
|
815
|
+
# =============================================================================
|
|
816
|
+
# DATE/TIME FUNCTIONS
|
|
817
|
+
# =============================================================================
|
|
818
|
+
|
|
819
|
+
def now() -> float:
|
|
820
|
+
"""Current timestamp as float (seconds since epoch)."""
|
|
821
|
+
...
|
|
822
|
+
|
|
823
|
+
def timestamp() -> int:
|
|
824
|
+
"""Current timestamp as integer."""
|
|
825
|
+
...
|
|
826
|
+
|
|
827
|
+
def sleep(seconds: float) -> None:
|
|
828
|
+
"""Pause execution for specified seconds.
|
|
829
|
+
|
|
830
|
+
Example:
|
|
831
|
+
sleep(1.5); // Wait 1.5 seconds
|
|
832
|
+
"""
|
|
833
|
+
...
|
|
834
|
+
|
|
835
|
+
def date(format: str = "%Y-%m-%d") -> str:
|
|
836
|
+
"""Current date as formatted string.
|
|
837
|
+
|
|
838
|
+
Args:
|
|
839
|
+
format: strftime format string
|
|
840
|
+
|
|
841
|
+
Example:
|
|
842
|
+
date(); // "2025-12-30"
|
|
843
|
+
date("%d/%m/%Y"); // "30/12/2025"
|
|
844
|
+
"""
|
|
845
|
+
...
|
|
846
|
+
|
|
847
|
+
def time(format: str = "%H:%M:%S") -> str:
|
|
848
|
+
"""Current time as formatted string.
|
|
849
|
+
|
|
850
|
+
Example:
|
|
851
|
+
time(); // "14:30:45"
|
|
852
|
+
"""
|
|
853
|
+
...
|
|
854
|
+
|
|
855
|
+
def datetime(format: str = "%Y-%m-%d %H:%M:%S") -> str:
|
|
856
|
+
"""Current date and time as formatted string."""
|
|
857
|
+
...
|
|
858
|
+
|
|
859
|
+
def strftime(format: str, timestamp: float = None) -> str:
|
|
860
|
+
"""Format timestamp as string.
|
|
861
|
+
|
|
862
|
+
Args:
|
|
863
|
+
format: strftime format string
|
|
864
|
+
timestamp: Unix timestamp (default: now)
|
|
865
|
+
"""
|
|
866
|
+
...
|
|
867
|
+
|
|
868
|
+
# =============================================================================
|
|
869
|
+
# FILE SYSTEM FUNCTIONS
|
|
870
|
+
# =============================================================================
|
|
871
|
+
|
|
872
|
+
def read(path: str, encoding: str = "utf-8") -> str:
|
|
873
|
+
"""Read entire file content.
|
|
874
|
+
|
|
875
|
+
Args:
|
|
876
|
+
path: File path
|
|
877
|
+
encoding: Character encoding (default: utf-8)
|
|
878
|
+
|
|
879
|
+
Returns:
|
|
880
|
+
File content as string
|
|
881
|
+
|
|
882
|
+
Example:
|
|
883
|
+
string content = read("/path/to/file.txt");
|
|
884
|
+
"""
|
|
885
|
+
...
|
|
886
|
+
|
|
887
|
+
def readline(line: int, path: str) -> str:
|
|
888
|
+
"""Read specific line from file (1-indexed).
|
|
889
|
+
|
|
890
|
+
Args:
|
|
891
|
+
line: Line number (1-based)
|
|
892
|
+
path: File path
|
|
893
|
+
|
|
894
|
+
Returns:
|
|
895
|
+
Line content
|
|
896
|
+
|
|
897
|
+
Example:
|
|
898
|
+
string line5 = readline(5, "file.txt");
|
|
899
|
+
"""
|
|
900
|
+
...
|
|
901
|
+
|
|
902
|
+
def write(path: str, content: str) -> int:
|
|
903
|
+
"""Write content to file (overwrites).
|
|
904
|
+
|
|
905
|
+
Args:
|
|
906
|
+
path: File path
|
|
907
|
+
content: Content to write
|
|
908
|
+
|
|
909
|
+
Returns:
|
|
910
|
+
Number of characters written
|
|
911
|
+
"""
|
|
912
|
+
...
|
|
913
|
+
|
|
914
|
+
def writeline(line: int, content: str, path: str) -> bool:
|
|
915
|
+
"""Write/replace specific line in file.
|
|
916
|
+
|
|
917
|
+
Args:
|
|
918
|
+
line: Line number (1-based)
|
|
919
|
+
content: New line content
|
|
920
|
+
path: File path
|
|
921
|
+
|
|
922
|
+
Returns:
|
|
923
|
+
Success status
|
|
924
|
+
"""
|
|
925
|
+
...
|
|
926
|
+
|
|
927
|
+
def appendfile(path: str, content: str) -> int:
|
|
928
|
+
"""Append content to file.
|
|
929
|
+
|
|
930
|
+
Returns:
|
|
931
|
+
Number of characters written
|
|
932
|
+
"""
|
|
933
|
+
...
|
|
934
|
+
|
|
935
|
+
def readlines(path: str) -> List[str]:
|
|
936
|
+
"""Read all lines from file.
|
|
937
|
+
|
|
938
|
+
Returns:
|
|
939
|
+
List of lines
|
|
940
|
+
"""
|
|
941
|
+
...
|
|
942
|
+
|
|
943
|
+
def pathexists(path: str) -> bool:
|
|
944
|
+
"""Check if path exists (file or directory)."""
|
|
945
|
+
...
|
|
946
|
+
|
|
947
|
+
def isfile(path: str) -> bool:
|
|
948
|
+
"""Check if path is a file."""
|
|
949
|
+
...
|
|
950
|
+
|
|
951
|
+
def isdir(path: str) -> bool:
|
|
952
|
+
"""Check if path is a directory."""
|
|
953
|
+
...
|
|
954
|
+
|
|
955
|
+
def listdir(path: str) -> List[str]:
|
|
956
|
+
"""List directory contents.
|
|
957
|
+
|
|
958
|
+
Returns:
|
|
959
|
+
List of file/folder names
|
|
960
|
+
"""
|
|
961
|
+
...
|
|
962
|
+
|
|
963
|
+
def makedirs(path: str) -> bool:
|
|
964
|
+
"""Create directory and parent directories.
|
|
965
|
+
|
|
966
|
+
Returns:
|
|
967
|
+
Success status
|
|
968
|
+
"""
|
|
969
|
+
...
|
|
970
|
+
|
|
971
|
+
def removefile(path: str) -> bool:
|
|
972
|
+
"""Delete a file."""
|
|
973
|
+
...
|
|
974
|
+
|
|
975
|
+
def removedir(path: str) -> bool:
|
|
976
|
+
"""Delete an empty directory."""
|
|
977
|
+
...
|
|
978
|
+
|
|
979
|
+
def copyfile(src: str, dst: str) -> bool:
|
|
980
|
+
"""Copy file from source to destination."""
|
|
981
|
+
...
|
|
982
|
+
|
|
983
|
+
def movefile(src: str, dst: str) -> bool:
|
|
984
|
+
"""Move/rename file."""
|
|
985
|
+
...
|
|
986
|
+
|
|
987
|
+
def filesize(path: str) -> int:
|
|
988
|
+
"""Get file size in bytes."""
|
|
989
|
+
...
|
|
990
|
+
|
|
991
|
+
def basename(path: str) -> str:
|
|
992
|
+
"""Get filename from path.
|
|
993
|
+
|
|
994
|
+
Example:
|
|
995
|
+
basename("/path/to/file.txt"); // "file.txt"
|
|
996
|
+
"""
|
|
997
|
+
...
|
|
998
|
+
|
|
999
|
+
def dirname(path: str) -> str:
|
|
1000
|
+
"""Get directory from path.
|
|
1001
|
+
|
|
1002
|
+
Example:
|
|
1003
|
+
dirname("/path/to/file.txt"); // "/path/to"
|
|
1004
|
+
"""
|
|
1005
|
+
...
|
|
1006
|
+
|
|
1007
|
+
def joinpath(*parts: str) -> str:
|
|
1008
|
+
"""Join path components.
|
|
1009
|
+
|
|
1010
|
+
Example:
|
|
1011
|
+
joinpath("/path", "to", "file.txt"); // "/path/to/file.txt"
|
|
1012
|
+
"""
|
|
1013
|
+
...
|
|
1014
|
+
|
|
1015
|
+
def abspath(path: str) -> str:
|
|
1016
|
+
"""Get absolute path."""
|
|
1017
|
+
...
|
|
1018
|
+
|
|
1019
|
+
# =============================================================================
|
|
1020
|
+
# JSON FUNCTIONS (json:: namespace)
|
|
1021
|
+
# =============================================================================
|
|
1022
|
+
|
|
1023
|
+
def json_read(path: str) -> Any:
|
|
1024
|
+
"""Read and parse JSON file.
|
|
1025
|
+
|
|
1026
|
+
Usage: json::read("/path/to/file.json")
|
|
1027
|
+
|
|
1028
|
+
Returns:
|
|
1029
|
+
Parsed JSON data
|
|
1030
|
+
"""
|
|
1031
|
+
...
|
|
1032
|
+
|
|
1033
|
+
def json_write(path: str, data: Any, indent: int = 2) -> bool:
|
|
1034
|
+
"""Write data to JSON file.
|
|
1035
|
+
|
|
1036
|
+
Usage: json::write("/path/to/file.json", data)
|
|
1037
|
+
|
|
1038
|
+
Returns:
|
|
1039
|
+
Success status
|
|
1040
|
+
"""
|
|
1041
|
+
...
|
|
1042
|
+
|
|
1043
|
+
def json_parse(s: str) -> Any:
|
|
1044
|
+
"""Parse JSON string.
|
|
1045
|
+
|
|
1046
|
+
Usage: json::parse('{"key": "value"}')
|
|
1047
|
+
|
|
1048
|
+
Returns:
|
|
1049
|
+
Parsed object/array
|
|
1050
|
+
"""
|
|
1051
|
+
...
|
|
1052
|
+
|
|
1053
|
+
def json_stringify(data: Any) -> str:
|
|
1054
|
+
"""Convert data to JSON string.
|
|
1055
|
+
|
|
1056
|
+
Usage: json::stringify(data)
|
|
1057
|
+
"""
|
|
1058
|
+
...
|
|
1059
|
+
|
|
1060
|
+
def json_pretty(data: Any, indent: int = 2) -> str:
|
|
1061
|
+
"""Pretty print JSON with indentation.
|
|
1062
|
+
|
|
1063
|
+
Usage: json::pretty(data)
|
|
1064
|
+
"""
|
|
1065
|
+
...
|
|
1066
|
+
|
|
1067
|
+
def json_get(data: Any, path: str, default: Any = None) -> Any:
|
|
1068
|
+
"""Get value by dot-path.
|
|
1069
|
+
|
|
1070
|
+
Usage: json::get(data, "user.name")
|
|
1071
|
+
|
|
1072
|
+
Args:
|
|
1073
|
+
data: JSON object
|
|
1074
|
+
path: Dot-separated path (e.g., "user.profile.age")
|
|
1075
|
+
default: Default value if path not found
|
|
1076
|
+
"""
|
|
1077
|
+
...
|
|
1078
|
+
|
|
1079
|
+
def json_set(data: Any, path: str, value: Any) -> Any:
|
|
1080
|
+
"""Set value by dot-path.
|
|
1081
|
+
|
|
1082
|
+
Usage: json::set(data, "user.name", "John")
|
|
1083
|
+
|
|
1084
|
+
Returns:
|
|
1085
|
+
Modified data
|
|
1086
|
+
"""
|
|
1087
|
+
...
|
|
1088
|
+
|
|
1089
|
+
def json_has(data: Any, path: str) -> bool:
|
|
1090
|
+
"""Check if path exists.
|
|
1091
|
+
|
|
1092
|
+
Usage: json::has(data, "user.email")
|
|
1093
|
+
"""
|
|
1094
|
+
...
|
|
1095
|
+
|
|
1096
|
+
def json_keys(data: Dict) -> List[str]:
|
|
1097
|
+
"""Get all keys from JSON object.
|
|
1098
|
+
|
|
1099
|
+
Usage: json::keys(data)
|
|
1100
|
+
"""
|
|
1101
|
+
...
|
|
1102
|
+
|
|
1103
|
+
def json_values(data: Dict) -> List[Any]:
|
|
1104
|
+
"""Get all values from JSON object.
|
|
1105
|
+
|
|
1106
|
+
Usage: json::values(data)
|
|
1107
|
+
"""
|
|
1108
|
+
...
|
|
1109
|
+
|
|
1110
|
+
def json_merge(*dicts: Dict) -> Dict:
|
|
1111
|
+
"""Deep merge multiple JSON objects.
|
|
1112
|
+
|
|
1113
|
+
Usage: json::merge(obj1, obj2, obj3)
|
|
1114
|
+
"""
|
|
1115
|
+
...
|
|
1116
|
+
|
|
1117
|
+
# =============================================================================
|
|
1118
|
+
# INSTANCE INTROSPECTION (instance:: namespace)
|
|
1119
|
+
# =============================================================================
|
|
1120
|
+
|
|
1121
|
+
def instance_getMethods(obj: Any) -> List[str]:
|
|
1122
|
+
"""Get all method names from object/module.
|
|
1123
|
+
|
|
1124
|
+
Usage: instance::getMethods(@module)
|
|
1125
|
+
|
|
1126
|
+
Returns:
|
|
1127
|
+
List of callable method names
|
|
1128
|
+
"""
|
|
1129
|
+
...
|
|
1130
|
+
|
|
1131
|
+
def instance_getClasses(obj: Any) -> List[str]:
|
|
1132
|
+
"""Get all class names from module.
|
|
1133
|
+
|
|
1134
|
+
Usage: instance::getClasses(@module)
|
|
1135
|
+
"""
|
|
1136
|
+
...
|
|
1137
|
+
|
|
1138
|
+
def instance_getVars(obj: Any) -> List[str]:
|
|
1139
|
+
"""Get all variable/attribute names.
|
|
1140
|
+
|
|
1141
|
+
Usage: instance::getVars(@module)
|
|
1142
|
+
"""
|
|
1143
|
+
...
|
|
1144
|
+
|
|
1145
|
+
def instance_getAll(obj: Any) -> Dict[str, List[str]]:
|
|
1146
|
+
"""Get all attributes categorized.
|
|
1147
|
+
|
|
1148
|
+
Usage: instance::getAll(@module)
|
|
1149
|
+
|
|
1150
|
+
Returns:
|
|
1151
|
+
Dict with 'methods', 'classes', 'vars' keys
|
|
1152
|
+
"""
|
|
1153
|
+
...
|
|
1154
|
+
|
|
1155
|
+
def instance_call(obj: Any, method_name: str, *args: Any, **kwargs: Any) -> Any:
|
|
1156
|
+
"""Dynamically call method on object.
|
|
1157
|
+
|
|
1158
|
+
Usage: instance::call(@module, "methodName", arg1, arg2)
|
|
1159
|
+
"""
|
|
1160
|
+
...
|
|
1161
|
+
|
|
1162
|
+
def instance_has(obj: Any, name: str) -> bool:
|
|
1163
|
+
"""Check if object has attribute.
|
|
1164
|
+
|
|
1165
|
+
Usage: instance::has(@module, "methodName")
|
|
1166
|
+
"""
|
|
1167
|
+
...
|
|
1168
|
+
|
|
1169
|
+
def instance_type(obj: Any) -> str:
|
|
1170
|
+
"""Get type name of object.
|
|
1171
|
+
|
|
1172
|
+
Usage: instance::type(@module)
|
|
1173
|
+
"""
|
|
1174
|
+
...
|
|
1175
|
+
|
|
1176
|
+
def isavailable(name_or_obj: Any) -> bool:
|
|
1177
|
+
"""Check if shared instance exists.
|
|
1178
|
+
|
|
1179
|
+
Usage:
|
|
1180
|
+
isavailable("MyInstance") // Check by name
|
|
1181
|
+
isavailable($MyInstance) // Check if not null
|
|
1182
|
+
instance::exists("Name") // Alias
|
|
1183
|
+
"""
|
|
1184
|
+
...
|
|
1185
|
+
|
|
1186
|
+
# =============================================================================
|
|
1187
|
+
# REGEX FUNCTIONS
|
|
1188
|
+
# =============================================================================
|
|
1189
|
+
|
|
1190
|
+
def match(pattern: str, string: str) -> Optional[Dict]:
|
|
1191
|
+
"""Match regex at start of string.
|
|
1192
|
+
|
|
1193
|
+
Returns:
|
|
1194
|
+
Dict with 'match', 'groups', 'start', 'end' or null
|
|
1195
|
+
"""
|
|
1196
|
+
...
|
|
1197
|
+
|
|
1198
|
+
def search(pattern: str, string: str) -> Optional[Dict]:
|
|
1199
|
+
"""Search for regex anywhere in string.
|
|
1200
|
+
|
|
1201
|
+
Returns:
|
|
1202
|
+
Dict with match info or null
|
|
1203
|
+
"""
|
|
1204
|
+
...
|
|
1205
|
+
|
|
1206
|
+
def findall(pattern: str, string: str) -> List[str]:
|
|
1207
|
+
"""Find all regex matches.
|
|
1208
|
+
|
|
1209
|
+
Returns:
|
|
1210
|
+
List of all matches
|
|
1211
|
+
"""
|
|
1212
|
+
...
|
|
1213
|
+
|
|
1214
|
+
def sub(pattern: str, replacement: str, string: str) -> str:
|
|
1215
|
+
"""Replace all regex matches.
|
|
1216
|
+
|
|
1217
|
+
Example:
|
|
1218
|
+
sub("\\d+", "X", "a1b2c3"); // "aXbXcX"
|
|
1219
|
+
"""
|
|
1220
|
+
...
|
|
1221
|
+
|
|
1222
|
+
# =============================================================================
|
|
1223
|
+
# HASH FUNCTIONS
|
|
1224
|
+
# =============================================================================
|
|
1225
|
+
|
|
1226
|
+
def md5(s: str) -> str:
|
|
1227
|
+
"""Calculate MD5 hash.
|
|
1228
|
+
|
|
1229
|
+
Returns:
|
|
1230
|
+
Hexadecimal hash string
|
|
1231
|
+
"""
|
|
1232
|
+
...
|
|
1233
|
+
|
|
1234
|
+
def sha1(s: str) -> str:
|
|
1235
|
+
"""Calculate SHA1 hash."""
|
|
1236
|
+
...
|
|
1237
|
+
|
|
1238
|
+
def sha256(s: str) -> str:
|
|
1239
|
+
"""Calculate SHA256 hash."""
|
|
1240
|
+
...
|
|
1241
|
+
|
|
1242
|
+
# =============================================================================
|
|
1243
|
+
# SYSTEM/CONTROL FUNCTIONS
|
|
1244
|
+
# =============================================================================
|
|
1245
|
+
|
|
1246
|
+
def exit(code: int = 0) -> None:
|
|
1247
|
+
"""Exit CSSL execution.
|
|
1248
|
+
|
|
1249
|
+
Args:
|
|
1250
|
+
code: Exit code (default: 0)
|
|
1251
|
+
"""
|
|
1252
|
+
...
|
|
1253
|
+
|
|
1254
|
+
def input(prompt: str = "") -> str:
|
|
1255
|
+
"""Read user input from console.
|
|
1256
|
+
|
|
1257
|
+
Args:
|
|
1258
|
+
prompt: Optional prompt message
|
|
1259
|
+
|
|
1260
|
+
Returns:
|
|
1261
|
+
User input string
|
|
1262
|
+
"""
|
|
1263
|
+
...
|
|
1264
|
+
|
|
1265
|
+
def env(name: str) -> Optional[str]:
|
|
1266
|
+
"""Get environment variable.
|
|
1267
|
+
|
|
1268
|
+
Args:
|
|
1269
|
+
name: Variable name
|
|
1270
|
+
|
|
1271
|
+
Returns:
|
|
1272
|
+
Variable value or null
|
|
1273
|
+
"""
|
|
1274
|
+
...
|
|
1275
|
+
|
|
1276
|
+
def setenv(name: str, value: str) -> None:
|
|
1277
|
+
"""Set environment variable."""
|
|
1278
|
+
...
|
|
1279
|
+
|
|
1280
|
+
def clear() -> None:
|
|
1281
|
+
"""Clear console screen."""
|
|
1282
|
+
...
|
|
1283
|
+
|
|
1284
|
+
def copy(obj: Any) -> Any:
|
|
1285
|
+
"""Create shallow copy of object."""
|
|
1286
|
+
...
|
|
1287
|
+
|
|
1288
|
+
def deepcopy(obj: Any) -> Any:
|
|
1289
|
+
"""Create deep copy of object."""
|
|
1290
|
+
...
|
|
1291
|
+
|
|
1292
|
+
def pyimport(module_name: str) -> Any:
|
|
1293
|
+
"""Import Python module dynamically.
|
|
1294
|
+
|
|
1295
|
+
Example:
|
|
1296
|
+
@os = pyimport("os");
|
|
1297
|
+
@os.getcwd();
|
|
1298
|
+
"""
|
|
1299
|
+
...
|
|
1300
|
+
|
|
1301
|
+
def include(path: str) -> Any:
|
|
1302
|
+
"""Include/import CSSL module.
|
|
1303
|
+
|
|
1304
|
+
Args:
|
|
1305
|
+
path: Module path (e.g., "mymodule.cssl-mod")
|
|
1306
|
+
|
|
1307
|
+
Returns:
|
|
1308
|
+
Imported module object
|
|
1309
|
+
"""
|
|
1310
|
+
...
|
|
1311
|
+
|
|
1312
|
+
def payload(path: str) -> Any:
|
|
1313
|
+
"""Load CSSL payload file.
|
|
1314
|
+
|
|
1315
|
+
Args:
|
|
1316
|
+
path: Payload file path (e.g., "data.cssl-pl")
|
|
1317
|
+
"""
|
|
1318
|
+
...
|
|
1319
|
+
|
|
1320
|
+
# =============================================================================
|
|
1321
|
+
# CSSL-SPECIFIC FUNCTIONS
|
|
1322
|
+
# =============================================================================
|
|
1323
|
+
|
|
1324
|
+
def OpenFind(type_or_combo: Any, index: int = 0) -> Optional[Any]:
|
|
1325
|
+
"""Find open parameter by type or combo space.
|
|
1326
|
+
|
|
1327
|
+
Usage:
|
|
1328
|
+
string name = OpenFind<string>(0);
|
|
1329
|
+
value = OpenFind(&comboSpace);
|
|
1330
|
+
"""
|
|
1331
|
+
...
|
|
1332
|
+
|
|
1333
|
+
def datastruct(element_type: str = "dynamic") -> Any:
|
|
1334
|
+
"""Create datastruct container.
|
|
1335
|
+
|
|
1336
|
+
Example:
|
|
1337
|
+
datastruct<string> data;
|
|
1338
|
+
"""
|
|
1339
|
+
...
|
|
1340
|
+
|
|
1341
|
+
def shuffled(element_type: str = "dynamic") -> Any:
|
|
1342
|
+
"""Create shuffled container for unorganized fast storage."""
|
|
1343
|
+
...
|
|
1344
|
+
|
|
1345
|
+
def iterator(element_type: str = "int", size: int = 16) -> Any:
|
|
1346
|
+
"""Create iterator with programmable tasks."""
|
|
1347
|
+
...
|
|
1348
|
+
|
|
1349
|
+
def combo(element_type: str = "dynamic") -> Any:
|
|
1350
|
+
"""Create combo filter/search space."""
|
|
1351
|
+
...
|
|
1352
|
+
|
|
1353
|
+
def share(name: str, obj: Any) -> None:
|
|
1354
|
+
"""Share Python object with CSSL.
|
|
1355
|
+
|
|
1356
|
+
Args:
|
|
1357
|
+
name: Instance name for CSSL access
|
|
1358
|
+
obj: Python object to share
|
|
1359
|
+
|
|
1360
|
+
Example (Python):
|
|
1361
|
+
CSSL.share("mydata", data_object)
|
|
1362
|
+
|
|
1363
|
+
Example (CSSL):
|
|
1364
|
+
$mydata.property;
|
|
1365
|
+
"""
|
|
1366
|
+
...
|
|
1367
|
+
|
|
1368
|
+
def delete(name: str) -> bool:
|
|
1369
|
+
"""Delete shared object.
|
|
1370
|
+
|
|
1371
|
+
Args:
|
|
1372
|
+
name: Shared object name
|
|
1373
|
+
|
|
1374
|
+
Returns:
|
|
1375
|
+
True if deleted, False if not found
|
|
1376
|
+
"""
|
|
1377
|
+
...
|
|
1378
|
+
|
|
1379
|
+
# =============================================================================
|
|
1380
|
+
# PLATFORM DETECTION
|
|
1381
|
+
# =============================================================================
|
|
1382
|
+
|
|
1383
|
+
def isLinux() -> bool:
|
|
1384
|
+
"""Check if running on Linux."""
|
|
1385
|
+
...
|
|
1386
|
+
|
|
1387
|
+
def isWindows() -> bool:
|
|
1388
|
+
"""Check if running on Windows."""
|
|
1389
|
+
...
|
|
1390
|
+
|
|
1391
|
+
def isMac() -> bool:
|
|
1392
|
+
"""Check if running on macOS."""
|
|
1393
|
+
...
|