SheetMachine 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/PKG-INFO +1 -1
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/pyproject.toml +1 -1
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine/Field.py +8 -4
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine.egg-info/PKG-INFO +1 -1
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/LICENSE +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/README.md +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/setup.cfg +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine/Creator.py +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine/__init__.py +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine.egg-info/SOURCES.txt +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine.egg-info/dependency_links.txt +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine.egg-info/requires.txt +0 -0
- {sheetmachine-0.1.0 → sheetmachine-0.1.1}/src/SheetMachine.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
|
|
3
4
|
from enum import Enum
|
|
4
5
|
from typing import Optional
|
|
@@ -25,7 +26,11 @@ class Field:
|
|
|
25
26
|
|
|
26
27
|
def __init__(self, name: str, title: str, formular: str = None, group_by: bool = False, hidden: bool = False,
|
|
27
28
|
group_summary: AggregationType = None, total_summary: AggregationType = None,
|
|
28
|
-
excel_format_def: dict = None):
|
|
29
|
+
excel_format_def: dict = None, mapping: Callable = None):
|
|
30
|
+
|
|
31
|
+
assert not (formular is not None and group_by), "Group by a formular is not allowed"
|
|
32
|
+
assert not (formular is not None and mapping is not None), "Mapping ony for explicit Data"
|
|
33
|
+
|
|
29
34
|
self.name: str = name
|
|
30
35
|
self.title: str = title
|
|
31
36
|
self.formular: str = formular
|
|
@@ -34,16 +39,15 @@ class Field:
|
|
|
34
39
|
self.group_summary: Field.AggregationType= group_summary
|
|
35
40
|
self.total_summary: Field.AggregationType = total_summary
|
|
36
41
|
self.excel_format_def: dict = excel_format_def
|
|
42
|
+
self.mapping: Callable = (lambda x: x) if mapping is None else mapping
|
|
37
43
|
self.excel_format: Optional[Format] = None
|
|
38
44
|
self.excel_format_group_summary: Optional[Format] = None
|
|
39
45
|
self.excel_format_total_summary: Optional[Format] = None
|
|
40
46
|
self.idx_code: Optional[str] = None
|
|
41
47
|
|
|
42
|
-
assert not (self.formular is not None and self.group_by), "Group by a formular is not allowed"
|
|
43
|
-
|
|
44
48
|
def write(self, worksheet: Worksheet, i: int, j: int, row: dict, ef: Format) -> None:
|
|
45
49
|
if self.formular is None:
|
|
46
|
-
worksheet.write(i, j, row[self.name], ef)
|
|
50
|
+
worksheet.write(i, j, self.mapping(row[self.name]), ef)
|
|
47
51
|
else:
|
|
48
52
|
worksheet.write_formula(i, j, self.parse_formular(i, j), ef)
|
|
49
53
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|