numbers-parser 4.10.1__py3-none-any.whl → 4.10.3__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.
- numbers_parser/__init__.py +8 -23
- numbers_parser/cell.py +1152 -165
- numbers_parser/constants.py +8 -0
- numbers_parser/containers.py +1 -1
- numbers_parser/document.py +17 -15
- numbers_parser/model.py +89 -263
- {numbers_parser-4.10.1.dist-info → numbers_parser-4.10.3.dist-info}/METADATA +15 -12
- {numbers_parser-4.10.1.dist-info → numbers_parser-4.10.3.dist-info}/RECORD +11 -12
- numbers_parser/cell_storage.py +0 -927
- {numbers_parser-4.10.1.dist-info → numbers_parser-4.10.3.dist-info}/LICENSE.rst +0 -0
- {numbers_parser-4.10.1.dist-info → numbers_parser-4.10.3.dist-info}/WHEEL +0 -0
- {numbers_parser-4.10.1.dist-info → numbers_parser-4.10.3.dist-info}/entry_points.txt +0 -0
numbers_parser/constants.py
CHANGED
|
@@ -147,6 +147,8 @@ class CellType(IntEnum):
|
|
|
147
147
|
DURATION = 6
|
|
148
148
|
ERROR = 7
|
|
149
149
|
RICH_TEXT = 8
|
|
150
|
+
CURRENCY = 101
|
|
151
|
+
MERGED = 102
|
|
150
152
|
|
|
151
153
|
|
|
152
154
|
class CellPadding(IntEnum):
|
|
@@ -214,6 +216,12 @@ class ControlFormattingType(IntEnum):
|
|
|
214
216
|
SCIENTIFIC = 7
|
|
215
217
|
|
|
216
218
|
|
|
219
|
+
class OwnerKind(IntEnum):
|
|
220
|
+
TABLE_MODEL = 1
|
|
221
|
+
MERGE_OWNER = 5
|
|
222
|
+
HAUNTED_OWNER = 35
|
|
223
|
+
|
|
224
|
+
|
|
217
225
|
FORMATTING_ALLOWED_CELLS = {
|
|
218
226
|
"base": ["NumberCell"],
|
|
219
227
|
"currency": ["NumberCell"],
|
numbers_parser/containers.py
CHANGED
|
@@ -10,7 +10,7 @@ from numbers_parser.iwork import IWork, IWorkHandler
|
|
|
10
10
|
class ItemsList:
|
|
11
11
|
def __init__(self, model, refs, item_class):
|
|
12
12
|
self._item_name = item_class.__name__.lower()
|
|
13
|
-
self._items = [item_class(model,
|
|
13
|
+
self._items = [item_class(model, id) for id in refs]
|
|
14
14
|
|
|
15
15
|
def __getitem__(self, key: int):
|
|
16
16
|
if isinstance(key, int):
|
numbers_parser/document.py
CHANGED
|
@@ -20,7 +20,6 @@ from numbers_parser.cell import (
|
|
|
20
20
|
xl_cell_to_rowcol,
|
|
21
21
|
xl_range,
|
|
22
22
|
)
|
|
23
|
-
from numbers_parser.cell_storage import CellStorage
|
|
24
23
|
from numbers_parser.constants import (
|
|
25
24
|
CUSTOM_FORMATTING_ALLOWED_CELLS,
|
|
26
25
|
DEFAULT_COLUMN_COUNT,
|
|
@@ -109,6 +108,11 @@ class Document:
|
|
|
109
108
|
"""List[:class:`Sheet`]: A list of sheets in the document."""
|
|
110
109
|
return self._sheets
|
|
111
110
|
|
|
111
|
+
@property
|
|
112
|
+
def default_table(self) -> Table:
|
|
113
|
+
"""Table: return the first table of the first sheet in the document."""
|
|
114
|
+
return self.sheets[0].tables[0]
|
|
115
|
+
|
|
112
116
|
@property
|
|
113
117
|
def styles(self) -> Dict[str, Style]:
|
|
114
118
|
"""Dict[str, :class:`Style`]: A dict mapping style names to to the corresponding style."""
|
|
@@ -432,14 +436,14 @@ class Table(Cacheable): # noqa: F811
|
|
|
432
436
|
for row in range(self.num_rows):
|
|
433
437
|
self._data.append([])
|
|
434
438
|
for col in range(self.num_cols):
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if merge_cells.is_merge_reference((row, col)):
|
|
438
|
-
cell = Cell.merged_cell(table_id, row, col, model)
|
|
439
|
-
else:
|
|
440
|
-
cell = Cell.empty_cell(table_id, row, col, model)
|
|
439
|
+
if merge_cells.is_merge_reference((row, col)):
|
|
440
|
+
cell = Cell._merged_cell(table_id, row, col, model)
|
|
441
441
|
else:
|
|
442
|
-
|
|
442
|
+
buffer = self._model.storage_buffer(table_id, row, col)
|
|
443
|
+
if buffer is None:
|
|
444
|
+
cell = Cell._empty_cell(table_id, row, col, model)
|
|
445
|
+
else:
|
|
446
|
+
cell = Cell._from_storage(table_id, row, col, buffer, model)
|
|
443
447
|
self._data[row].append(cell)
|
|
444
448
|
|
|
445
449
|
@property
|
|
@@ -873,10 +877,8 @@ class Table(Cacheable): # noqa: F811
|
|
|
873
877
|
"""
|
|
874
878
|
# TODO: write needs to retain/init the border
|
|
875
879
|
(row, col, value) = self._validate_cell_coords(*args)
|
|
876
|
-
self._data[row][col] = Cell.
|
|
877
|
-
|
|
878
|
-
storage.update_value(value, self._data[row][col])
|
|
879
|
-
self._data[row][col].update_storage(storage)
|
|
880
|
+
self._data[row][col] = Cell._from_value(row, col, value)
|
|
881
|
+
self._data[row][col]._update_value(value, self._data[row][col])
|
|
880
882
|
|
|
881
883
|
merge_cells = self._model.merge_cells(self._table_id)
|
|
882
884
|
self._data[row][col]._table_id = self._table_id
|
|
@@ -940,7 +942,7 @@ class Table(Cacheable): # noqa: F811
|
|
|
940
942
|
self._model.number_of_rows(self._table_id, self.num_rows)
|
|
941
943
|
|
|
942
944
|
row = [
|
|
943
|
-
Cell.
|
|
945
|
+
Cell._empty_cell(self._table_id, self.num_rows - 1, col, self._model)
|
|
944
946
|
for col in range(self.num_cols)
|
|
945
947
|
]
|
|
946
948
|
rows = [row.copy() for _ in range(num_rows)]
|
|
@@ -995,7 +997,7 @@ class Table(Cacheable): # noqa: F811
|
|
|
995
997
|
|
|
996
998
|
for row in range(self.num_rows):
|
|
997
999
|
cols = [
|
|
998
|
-
Cell.
|
|
1000
|
+
Cell._empty_cell(self._table_id, row, col, self._model) for col in range(num_cols)
|
|
999
1001
|
]
|
|
1000
1002
|
self._data[row][start_col:start_col] = cols
|
|
1001
1003
|
|
|
@@ -1109,7 +1111,7 @@ class Table(Cacheable): # noqa: F811
|
|
|
1109
1111
|
merge_cells.add_anchor(row_start, col_start, (num_rows, num_cols))
|
|
1110
1112
|
for row in range(row_start + 1, row_end + 1):
|
|
1111
1113
|
for col in range(col_start + 1, col_end + 1):
|
|
1112
|
-
self._data[row][col] =
|
|
1114
|
+
self._data[row][col] = Cell._merged_cell(self._table_id, row, col, self._model)
|
|
1113
1115
|
merge_cells.add_reference(row, col, (row_start, col_start, row_end, col_end))
|
|
1114
1116
|
|
|
1115
1117
|
for row, cells in enumerate(self._data):
|