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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SheetMachine
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Create XLSX files from data
5
5
  Author: Nicolas Bschor
6
6
  License: Apache License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "SheetMachine"
7
- version = "0.1.0"
7
+ version = "0.1.01"
8
8
  description = "Create XLSX files from data"
9
9
  readme = "README.md"
10
10
  authors = [{name = "Nicolas Bschor"}]
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SheetMachine
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Create XLSX files from data
5
5
  Author: Nicolas Bschor
6
6
  License: Apache License
File without changes
File without changes
File without changes