tksheet 7.0.6__py3-none-any.whl → 7.1.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.
- tksheet/__init__.py +96 -96
- tksheet/column_headers.py +252 -270
- tksheet/functions.py +37 -9
- tksheet/main_table.py +743 -795
- tksheet/other_classes.py +129 -4
- tksheet/row_index.py +470 -316
- tksheet/sheet.py +994 -177
- tksheet/sheet_options.py +34 -0
- tksheet/text_editor.py +93 -78
- tksheet/themes.py +104 -0
- tksheet/vars.py +35 -0
- {tksheet-7.0.6.dist-info → tksheet-7.1.0.dist-info}/METADATA +1 -1
- tksheet-7.1.0.dist-info/RECORD +20 -0
- {tksheet-7.0.6.dist-info → tksheet-7.1.0.dist-info}/WHEEL +1 -1
- tksheet-7.0.6.dist-info/RECORD +0 -20
- {tksheet-7.0.6.dist-info → tksheet-7.1.0.dist-info}/LICENSE.txt +0 -0
- {tksheet-7.0.6.dist-info → tksheet-7.1.0.dist-info}/top_level.txt +0 -0
tksheet/functions.py
CHANGED
@@ -4,6 +4,7 @@ import bisect
|
|
4
4
|
import pickle
|
5
5
|
import re
|
6
6
|
import zlib
|
7
|
+
from collections import deque
|
7
8
|
from collections.abc import (
|
8
9
|
Callable,
|
9
10
|
Generator,
|
@@ -244,6 +245,14 @@ def is_iterable(o: object) -> bool:
|
|
244
245
|
return False
|
245
246
|
|
246
247
|
|
248
|
+
def unpack(t: tuple[object] | tuple[Iterator[object]]) -> tuple[object]:
|
249
|
+
if not len(t):
|
250
|
+
return t
|
251
|
+
if is_iterable(t[0]) and len(t) == 1:
|
252
|
+
return t[0]
|
253
|
+
return t
|
254
|
+
|
255
|
+
|
247
256
|
def is_type_int(o: object) -> bool:
|
248
257
|
return isinstance(o, int) and not isinstance(o, bool)
|
249
258
|
|
@@ -336,7 +345,7 @@ def get_seq_without_gaps_at_index(
|
|
336
345
|
return seq
|
337
346
|
|
338
347
|
|
339
|
-
def consecutive_chunks(seq: list[object]) ->
|
348
|
+
def consecutive_chunks(seq: list[object]) -> Generator[object]:
|
340
349
|
if not seq:
|
341
350
|
yield seq
|
342
351
|
start = 0
|
@@ -357,6 +366,21 @@ def is_contiguous(seq: list[int]) -> bool:
|
|
357
366
|
return all(i == (prev := prev + 1) for i in itr)
|
358
367
|
|
359
368
|
|
369
|
+
def get_last(
|
370
|
+
it: Iterator,
|
371
|
+
) -> object:
|
372
|
+
if hasattr(it, "__reversed__"):
|
373
|
+
try:
|
374
|
+
return next(reversed(it))
|
375
|
+
except Exception:
|
376
|
+
return None
|
377
|
+
else:
|
378
|
+
try:
|
379
|
+
return deque(it, maxlen=1)[0]
|
380
|
+
except Exception:
|
381
|
+
return None
|
382
|
+
|
383
|
+
|
360
384
|
def index_exists(seq: Sequence[object], index: int) -> bool:
|
361
385
|
try:
|
362
386
|
seq[index]
|
@@ -1080,14 +1104,6 @@ def del_named_span_options_nested(options: dict, itr1: Iterator, itr2: Iterator,
|
|
1080
1104
|
del options[k][type_]
|
1081
1105
|
|
1082
1106
|
|
1083
|
-
def coords_tag_to_int_tuple(s: str) -> tuple[int, int, int, int] | tuple[int, int]:
|
1084
|
-
return tuple(map(int, filter(None, s.split("_"))))
|
1085
|
-
|
1086
|
-
|
1087
|
-
def coords_tag_to_box_nt(s: str) -> Box_nt[int, int, int, int]:
|
1088
|
-
return Box_nt(*(map(int, filter(None, s.split("_")))))
|
1089
|
-
|
1090
|
-
|
1091
1107
|
def add_highlight(
|
1092
1108
|
options: dict,
|
1093
1109
|
key: int | tuple[int, int],
|
@@ -1246,3 +1262,15 @@ def mod_event_val(
|
|
1246
1262
|
event_data.value = val
|
1247
1263
|
event_data.loc = loc
|
1248
1264
|
return event_data
|
1265
|
+
|
1266
|
+
|
1267
|
+
def pop_positions(
|
1268
|
+
itr: Iterator[int],
|
1269
|
+
to_pop: dict[int, int], # displayed index: data index
|
1270
|
+
save_to: dict[int, int],
|
1271
|
+
) -> Iterator[int]:
|
1272
|
+
for i, pos in enumerate(itr()):
|
1273
|
+
if i in to_pop:
|
1274
|
+
save_to[to_pop[i]] = pos
|
1275
|
+
else:
|
1276
|
+
yield pos
|