toolsos 0.1.4__py3-none-any.whl → 0.2.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.
- toolsos/{database_connection.py → database/database_connection.py} +9 -7
- toolsos/huisstijl/graphs/graph_styles.py +13 -7
- toolsos/huisstijl/graphs/linegraph.py +5 -1
- toolsos/huisstijl/graphs/styler.py +120 -41
- toolsos/huisstijl/tables/table_helpers.py +6 -0
- toolsos/huisstijl/tables/tables.py +99 -36
- {toolsos-0.1.4.dist-info → toolsos-0.2.1.dist-info}/METADATA +2 -2
- {toolsos-0.1.4.dist-info → toolsos-0.2.1.dist-info}/RECORD +11 -10
- /toolsos/{database_transfer.py → database/database_transfer.py} +0 -0
- {toolsos-0.1.4.dist-info → toolsos-0.2.1.dist-info}/WHEEL +0 -0
- {toolsos-0.1.4.dist-info → toolsos-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -33,7 +33,7 @@ def get_db_connection_strings(
|
|
|
33
33
|
for dbname, params in db_info.items():
|
|
34
34
|
flush = dbname in reset_pw if reset_pw else False
|
|
35
35
|
|
|
36
|
-
if params["
|
|
36
|
+
if params["password"] == "access_token":
|
|
37
37
|
pw = get_azure_access_token()
|
|
38
38
|
else:
|
|
39
39
|
pw = get_pw_from_keyring(dbname=dbname, user=params["user"], reset_pw=flush)
|
|
@@ -104,11 +104,13 @@ if __name__ == "__main__":
|
|
|
104
104
|
# Examples
|
|
105
105
|
|
|
106
106
|
# Get database connection settings from yaml
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
engine_strings = get_db_connection_strings(
|
|
108
|
+
"src/toolsos/database/database_config.yml"
|
|
109
|
+
)
|
|
110
|
+
print(engine_strings.ruimte_analyse222)
|
|
109
111
|
|
|
110
112
|
# Get database connection settings from yaml and reset password
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
engine_strings = get_db_connection_strings(
|
|
114
|
+
"src/toolsos/database/database_config.yml", reset_pw=["ruimte_analyse222"]
|
|
115
|
+
)
|
|
116
|
+
print(engine_strings.ruimte_analyse222)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
font = "Amsterdam Sans ExtraBold, Corbel"
|
|
2
|
+
# font = "Arial"
|
|
3
|
+
|
|
1
4
|
STYLE_OLD = {
|
|
2
|
-
"font": {"family": "Corbel", "
|
|
5
|
+
"font": {"family": "Corbel", "size": 15},
|
|
3
6
|
"plot_bgcolor": "#FFFFFF",
|
|
4
7
|
"gridline_color": "#E8E8E8",
|
|
5
8
|
"gridlinewidth": 0.75,
|
|
@@ -12,13 +15,16 @@ STYLE_OLD = {
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
STYLE_NEW = {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
18
|
+
"font_bold": {"family": "Amsterdam Sans ExtraBold, Corbel", "size": 15},
|
|
19
|
+
"font": {"family": "Amsterdam Sans, Corbel", "size": 15},
|
|
20
|
+
"axis_font": {"family": font, "size": 15},
|
|
17
21
|
"plot_bgcolor": "#FFFFFF",
|
|
18
|
-
"gridline_color": "#
|
|
19
|
-
"
|
|
22
|
+
"gridline_color": "#dbdbdb",
|
|
23
|
+
"gridline_width": 0.75,
|
|
20
24
|
"showline": True,
|
|
21
25
|
"showgrid": False,
|
|
22
|
-
"zerolinecolor": "#
|
|
23
|
-
"gridcolor": "#
|
|
26
|
+
"zerolinecolor": "#dbdbdb",
|
|
27
|
+
"gridcolor": "#dbdbdb",
|
|
28
|
+
"gridlinecolor": "#dbdbdb",
|
|
29
|
+
"separators": ",",
|
|
24
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import plotly.express as px
|
|
2
|
-
from .styler import BaseStyle
|
|
3
2
|
|
|
3
|
+
from .styler import BaseStyle
|
|
4
4
|
|
|
5
5
|
basestyle = BaseStyle()
|
|
6
6
|
|
|
@@ -17,4 +17,8 @@ def line(data, x, y, color: None, width=750, height=490, **kwargs):
|
|
|
17
17
|
**kwargs,
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
+
fig.update_layout(
|
|
21
|
+
dict(xaxis_title_text="", yaxis_title_text="", legend_title_text="")
|
|
22
|
+
)
|
|
23
|
+
|
|
20
24
|
return fig
|
|
@@ -4,51 +4,141 @@ import plotly.graph_objects as go
|
|
|
4
4
|
import requests
|
|
5
5
|
from requests import ConnectionError
|
|
6
6
|
|
|
7
|
+
from .graph_styles import STYLE_NEW
|
|
8
|
+
|
|
9
|
+
# class BaseStyle:
|
|
10
|
+
# style_url = (
|
|
11
|
+
# "https://raw.githubusercontent.com/jbosga-ams/oistyle/main/base_style.json"
|
|
12
|
+
# )
|
|
13
|
+
|
|
14
|
+
# def __init__(self):
|
|
15
|
+
# self.grab_styling()
|
|
16
|
+
|
|
17
|
+
# def grab_styling(self, style_path: str = None):
|
|
18
|
+
# if not style_path:
|
|
19
|
+
# try:
|
|
20
|
+
# res = requests.get(self.style_url).json()
|
|
21
|
+
# except ConnectionError:
|
|
22
|
+
# print("Failed grabbing basestyle from the interwebs")
|
|
23
|
+
# # Add option to manually provide json file
|
|
24
|
+
# else:
|
|
25
|
+
# res = json.loads()
|
|
26
|
+
|
|
27
|
+
# for k, v in res.items():
|
|
28
|
+
# setattr(self, k, v)
|
|
29
|
+
|
|
30
|
+
# self.font = "Amsterdam Sans ExtraBold, Corbel"
|
|
31
|
+
|
|
32
|
+
# def _get_axis_format(self):
|
|
33
|
+
# self.gridline_color = "#dbdbdb" # Jorren vragen om deze aan te passen
|
|
34
|
+
|
|
35
|
+
# return {
|
|
36
|
+
# "zerolinecolor": self.gridline_color,
|
|
37
|
+
# "gridcolor": self.gridline_color,
|
|
38
|
+
# "gridwidth": self.gridline_width,
|
|
39
|
+
# "showline": True,
|
|
40
|
+
# "linewidth": self.gridline_width,
|
|
41
|
+
# "linecolor": self.gridline_color,
|
|
42
|
+
# # "mirror": True,
|
|
43
|
+
# "showgrid": False,
|
|
44
|
+
# }
|
|
45
|
+
|
|
46
|
+
# def _get_base_template_layout(self):
|
|
47
|
+
# return go.layout.Template(
|
|
48
|
+
# layout={
|
|
49
|
+
# "font": {"family": self.font, "size": self.font_size},
|
|
50
|
+
# "plot_bgcolor": self.plot_bgcolor,
|
|
51
|
+
# "colorway": self.colors["darkblue_lightblue_gradient_5"],
|
|
52
|
+
# "separators": ",", # Jorren vragen om deze toe te voegen
|
|
53
|
+
# }
|
|
54
|
+
# )
|
|
55
|
+
|
|
56
|
+
# def get_base_template(
|
|
57
|
+
# self, graph_type: str = None, orientation: str = None, colors: str = None
|
|
58
|
+
# ):
|
|
59
|
+
# """[summary]
|
|
60
|
+
|
|
61
|
+
# Args:
|
|
62
|
+
# graph_type (str, optional): Pick 'bar', 'line' or 'bar'. Defaults to None.
|
|
63
|
+
# orientation (str, optional): [description]. Pick horizontal ('h') or vertical 'v'. Defaults to None.
|
|
64
|
+
# colors (str, optional): Set basecolors. Defaults to None.
|
|
65
|
+
|
|
66
|
+
# Raises:
|
|
67
|
+
# ValueError: [description]
|
|
68
|
+
|
|
69
|
+
# Returns:
|
|
70
|
+
# [type]: [description]
|
|
71
|
+
# """
|
|
72
|
+
# base_template = self._get_base_template_layout()
|
|
73
|
+
# axis_format = self._get_axis_format()
|
|
74
|
+
|
|
75
|
+
# if graph_type == "bar":
|
|
76
|
+
# if orientation in ["v", "vertical"]:
|
|
77
|
+
# base_template.layout.xaxis.update(axis_format)
|
|
78
|
+
# base_template.layout.yaxis.update(zeroline=False)
|
|
79
|
+
# elif orientation in ["h", "horizontal"]:
|
|
80
|
+
# base_template.layout.yaxis.update(axis_format)
|
|
81
|
+
# base_template.layout.xaxis.update(zeroline=False)
|
|
82
|
+
# else:
|
|
83
|
+
# raise ValueError(
|
|
84
|
+
# "Orientation ('v'/'vertical' or 'h'/'horizontal') should be supplied with graph_type=='bar'"
|
|
85
|
+
# )
|
|
86
|
+
|
|
87
|
+
# elif graph_type == "line":
|
|
88
|
+
# base_template.layout.xaxis.update(axis_format)
|
|
89
|
+
|
|
90
|
+
# if colors:
|
|
91
|
+
# base_template.layout.update({"colorway": colors})
|
|
92
|
+
|
|
93
|
+
# return base_template
|
|
94
|
+
|
|
95
|
+
# def get_ois_colors(self, colorscale):
|
|
96
|
+
# colorscale = self.colors.get(colorscale, [])
|
|
97
|
+
# if not colorscale:
|
|
98
|
+
# raise Exception(f"Kies uit {self.colors.keys()}")
|
|
99
|
+
|
|
100
|
+
# return colorscale
|
|
101
|
+
|
|
7
102
|
|
|
8
103
|
class BaseStyle:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def __init__(self):
|
|
14
|
-
self.grab_styling()
|
|
15
|
-
|
|
16
|
-
def grab_styling(self, style_path: str = None):
|
|
17
|
-
if not style_path:
|
|
18
|
-
try:
|
|
19
|
-
res = requests.get(self.style_url).json()
|
|
20
|
-
except ConnectionError:
|
|
21
|
-
print("Failed grabbing basestyle from the interwebs")
|
|
22
|
-
# Add option to manually provide json file
|
|
104
|
+
def __init__(self, style_path=None):
|
|
105
|
+
if style_path is None:
|
|
106
|
+
self.style = STYLE_NEW
|
|
23
107
|
else:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for k, v in res.items():
|
|
27
|
-
setattr(self, k, v)
|
|
28
|
-
|
|
29
|
-
self.font = "Amsterdam Sans ExtraBold, Corbel"
|
|
108
|
+
with open(style_path) as file:
|
|
109
|
+
self.style = json.load(file)
|
|
30
110
|
|
|
31
111
|
def _get_axis_format(self):
|
|
32
112
|
self.gridline_color = "#dbdbdb" # Jorren vragen om deze aan te passen
|
|
33
113
|
|
|
34
114
|
return {
|
|
35
|
-
"zerolinecolor": self.gridline_color,
|
|
36
|
-
"gridcolor": self.gridline_color,
|
|
37
|
-
"gridwidth": self.gridline_width,
|
|
115
|
+
"zerolinecolor": self.style["gridline_color"],
|
|
116
|
+
"gridcolor": self.style["gridline_color"],
|
|
117
|
+
"gridwidth": self.style["gridline_width"],
|
|
38
118
|
"showline": True,
|
|
39
|
-
"linewidth": self.gridline_width,
|
|
40
|
-
"linecolor": self.gridline_color,
|
|
41
|
-
|
|
42
|
-
"showgrid": False,
|
|
119
|
+
"linewidth": self.style["gridline_width"],
|
|
120
|
+
"linecolor": self.style["gridline_color"],
|
|
121
|
+
"showgrid": self.style["showgrid"],
|
|
43
122
|
}
|
|
44
123
|
|
|
45
124
|
def _get_base_template_layout(self):
|
|
46
125
|
return go.layout.Template(
|
|
47
126
|
layout={
|
|
48
|
-
"font":
|
|
49
|
-
"
|
|
50
|
-
|
|
127
|
+
# "font": self.styles["font_bold"],
|
|
128
|
+
"xaxis": {
|
|
129
|
+
"tickfont": self.style["font_bold"],
|
|
130
|
+
},
|
|
131
|
+
"yaxis": {
|
|
132
|
+
"tickfont": {
|
|
133
|
+
"family": self.style["axis_font"]["family"],
|
|
134
|
+
"size": self.style["axis_font"]["size"],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
"legend": {"font": self.style["font"]},
|
|
138
|
+
"plot_bgcolor": self.style["plot_bgcolor"],
|
|
139
|
+
# "colorway": self.colors["darkblue_lightblue_gradient_5"],
|
|
51
140
|
"separators": ",", # Jorren vragen om deze toe te voegen
|
|
141
|
+
"font": self.style["font_bold"],
|
|
52
142
|
}
|
|
53
143
|
)
|
|
54
144
|
|
|
@@ -90,14 +180,3 @@ class BaseStyle:
|
|
|
90
180
|
base_template.layout.update({"colorway": colors})
|
|
91
181
|
|
|
92
182
|
return base_template
|
|
93
|
-
|
|
94
|
-
def get_ois_colors(self, colorscale):
|
|
95
|
-
colorscale = self.colors.get(colorscale, [])
|
|
96
|
-
if not colorscale:
|
|
97
|
-
raise Exception(f"Kies uit {self.colors.keys()}")
|
|
98
|
-
|
|
99
|
-
return colorscale
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
class Basestyle2:
|
|
103
|
-
def __init__(self, style): ...
|
|
@@ -46,6 +46,36 @@ def set_global_style(style: str) -> None:
|
|
|
46
46
|
STYLES = STYLE_NEW
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def cols_to_str(df: pd.DataFrame) -> pd.DataFrame:
|
|
50
|
+
"""Change column names in to string. Multiindex column names are nog changed because
|
|
51
|
+
these are always strings
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
df (pd.DataFrame): Dataframe
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
pd.DataFrame: Dataframe with column names as strings
|
|
58
|
+
"""
|
|
59
|
+
if df.columns.nlevels == 1:
|
|
60
|
+
df.columns = df.columns.astype(str)
|
|
61
|
+
|
|
62
|
+
return df
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_max_col_widths(data: pd.DataFrame | np.ndarray) -> list[float]:
|
|
66
|
+
col_widths = []
|
|
67
|
+
if isinstance(data, pd.DataFrame):
|
|
68
|
+
for col in zip(*flatten_multiindex_columns(data)):
|
|
69
|
+
col_widths.append(max(len(e) for e in col))
|
|
70
|
+
else:
|
|
71
|
+
for col in zip(*data):
|
|
72
|
+
col_widths.append(max(len(str(e)) for e in col))
|
|
73
|
+
|
|
74
|
+
col_widths = [col_width * 1.13 for col_width in col_widths]
|
|
75
|
+
|
|
76
|
+
return col_widths
|
|
77
|
+
|
|
78
|
+
|
|
49
79
|
def flatten_multiindex_columns(df):
|
|
50
80
|
column_multi = []
|
|
51
81
|
for level in range(df.columns.nlevels):
|
|
@@ -67,20 +97,32 @@ def df_to_array(df: pd.DataFrame) -> np.ndarray:
|
|
|
67
97
|
return np.vstack([column_names, df.to_numpy()])
|
|
68
98
|
|
|
69
99
|
|
|
70
|
-
def get_cells_to_merge(df
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
def get_cells_to_merge(df: pd.DataFrame) -> dict[int : list[int, int]]:
|
|
101
|
+
"""Pandas dataframes sometimes have mutliindex columns. For all but the last level
|
|
102
|
+
a dictionary is created to merge the cells. The last level isn't merged because these
|
|
103
|
+
are these contain unique column names
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
df (pd.DataFrame): Pandas dataframe. If the dataframe has multicolumn indices
|
|
107
|
+
a dictionary containg the cells to merge is returned
|
|
73
108
|
|
|
74
|
-
|
|
75
|
-
|
|
109
|
+
Returns:
|
|
110
|
+
dict[int: list[int, int]]: Dictionary containg the cells to merge
|
|
111
|
+
"""
|
|
112
|
+
levels = flatten_multiindex_columns(df)[:-1]
|
|
76
113
|
|
|
77
|
-
|
|
114
|
+
cells_to_merge = {}
|
|
115
|
+
for level_idx, level in enumerate(levels):
|
|
116
|
+
start_col = 1
|
|
117
|
+
start_col = 1
|
|
118
|
+
merge_cells = []
|
|
78
119
|
for _, val in groupby(level):
|
|
79
120
|
val = list(val)
|
|
80
121
|
merge_cells.append([start_col, start_col + len(val) - 1])
|
|
81
122
|
start_col += len(val)
|
|
123
|
+
cells_to_merge[level_idx] = merge_cells
|
|
82
124
|
|
|
83
|
-
return
|
|
125
|
+
return cells_to_merge
|
|
84
126
|
|
|
85
127
|
|
|
86
128
|
def get_fmt_table(arr: np.ndarray) -> Fmt:
|
|
@@ -336,7 +378,7 @@ def write_worksheet(
|
|
|
336
378
|
title: str | None = None,
|
|
337
379
|
source: str | None = None,
|
|
338
380
|
col_filter: bool | None = None,
|
|
339
|
-
|
|
381
|
+
col_widths: list | None = None,
|
|
340
382
|
cells_to_merge: list[list[int]] | None = None,
|
|
341
383
|
) -> None:
|
|
342
384
|
"""Writing data to worksheet. Used for writing values to cells and formatting the cells
|
|
@@ -377,51 +419,54 @@ def write_worksheet(
|
|
|
377
419
|
filters = ws.auto_filter
|
|
378
420
|
filters.ref = f"A1:{excel_style(len(fmt), len(fmt[0]))}"
|
|
379
421
|
|
|
380
|
-
if autofit_columns:
|
|
381
|
-
_autofit_columns(ws)
|
|
382
|
-
|
|
383
422
|
if source:
|
|
384
423
|
_insert_source(ws, source, arr)
|
|
385
424
|
|
|
425
|
+
if col_widths:
|
|
426
|
+
_set_column_widths(ws, col_widths)
|
|
427
|
+
|
|
386
428
|
if title:
|
|
387
429
|
_insert_title(ws, title)
|
|
388
430
|
|
|
389
431
|
if cells_to_merge:
|
|
390
|
-
_merge_cells(ws, cells_to_merge)
|
|
391
|
-
|
|
432
|
+
_merge_cells(ws, cells_to_merge, title)
|
|
392
433
|
|
|
393
|
-
# def _set_column_width(ws: Any, column_widths: list) -> None:
|
|
394
|
-
# for i, column_number in enumerate(range(ws.max_column)):
|
|
395
|
-
# column_letter = get_column_letter(column_letter)
|
|
396
|
-
# column_width = column_widths[i]
|
|
397
|
-
# ws.column_dimensions[column_letter].width = column_width
|
|
398
434
|
|
|
435
|
+
def _set_column_widths(ws: Any, col_widths: list[int]) -> None:
|
|
436
|
+
for idx, col_width in enumerate(col_widths):
|
|
437
|
+
col_letter = get_column_letter(idx + 1)
|
|
438
|
+
ws.column_dimensions[col_letter].width = col_width
|
|
399
439
|
|
|
400
|
-
def _autofit_columns(ws: Any) -> None:
|
|
401
|
-
column_letters = tuple(
|
|
402
|
-
get_column_letter(col_number + 1) for col_number in range(ws.max_column)
|
|
403
|
-
)
|
|
404
|
-
for column_letter in column_letters:
|
|
405
|
-
ws.column_dimensions[column_letter].auto_fit = True
|
|
406
440
|
|
|
441
|
+
def _merge_cells(ws, cells_to_merge, title: str | None = None) -> None:
|
|
442
|
+
add = 0
|
|
443
|
+
if title:
|
|
444
|
+
add = 1
|
|
407
445
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
446
|
+
for row_idx, merge in cells_to_merge.items():
|
|
447
|
+
row_idx = row_idx + add
|
|
448
|
+
for start, stop in merge:
|
|
449
|
+
cell = ws.cell(row_idx + 1, start)
|
|
450
|
+
cell.alignment = Alignment(horizontal="center")
|
|
451
|
+
ws.merge_cells(
|
|
452
|
+
start_row=row_idx + 1,
|
|
453
|
+
end_row=row_idx + 1,
|
|
454
|
+
start_column=start,
|
|
455
|
+
end_column=stop,
|
|
456
|
+
)
|
|
413
457
|
|
|
414
458
|
|
|
415
459
|
def _insert_source(ws, source, arr):
|
|
416
460
|
height, width = arr.shape
|
|
417
|
-
cell = ws.cell(
|
|
418
|
-
cell.font = Font(**STYLES["calibri"]["font"])
|
|
461
|
+
cell = ws.cell(height + 1, width, source)
|
|
419
462
|
cell.alignment = Alignment(horizontal="right")
|
|
463
|
+
cell.font = Font(**STYLES["calibri"]["font"])
|
|
420
464
|
|
|
421
465
|
|
|
422
466
|
def _insert_title(ws: Any, title: str) -> None:
|
|
423
467
|
ws.insert_rows(0)
|
|
424
468
|
cell = ws.cell(1, 1, title)
|
|
469
|
+
cell.alignment = Alignment(horizontal="left")
|
|
425
470
|
for t, kwa in STYLES["title_bold"].items():
|
|
426
471
|
setattr(cell, t, LOOKUP[t](**kwa))
|
|
427
472
|
|
|
@@ -447,10 +492,11 @@ def write_table(
|
|
|
447
492
|
blue_border: bool | None = True,
|
|
448
493
|
blue_border_row_ids: int | list[int] | None = None,
|
|
449
494
|
number_format: str = "0.0",
|
|
450
|
-
autofit_columns:
|
|
495
|
+
autofit_columns: str | None = "column_names",
|
|
451
496
|
col_filter: bool | None = False,
|
|
452
497
|
style: str = "old",
|
|
453
|
-
|
|
498
|
+
combine_multiindex: bool | int = False,
|
|
499
|
+
column_names_to_string: bool = True,
|
|
454
500
|
):
|
|
455
501
|
"""_summary_
|
|
456
502
|
|
|
@@ -484,6 +530,9 @@ def write_table(
|
|
|
484
530
|
data = {"Sheet1": data}
|
|
485
531
|
|
|
486
532
|
for sheet_name, df in data.items():
|
|
533
|
+
if column_names_to_string == True:
|
|
534
|
+
df = cols_to_str(df)
|
|
535
|
+
|
|
487
536
|
arr = df_to_array(df)
|
|
488
537
|
|
|
489
538
|
blue_rows = []
|
|
@@ -495,6 +544,7 @@ def write_table(
|
|
|
495
544
|
p_ids = []
|
|
496
545
|
cells_to_merge = []
|
|
497
546
|
title_tbl = None
|
|
547
|
+
title_src = None
|
|
498
548
|
|
|
499
549
|
if isinstance(header_row, int):
|
|
500
550
|
blue_rows.extend(list(range(0, header_row + 1)))
|
|
@@ -505,6 +555,12 @@ def write_table(
|
|
|
505
555
|
elif isinstance(title, dict):
|
|
506
556
|
title_tbl = title.get(sheet_name)
|
|
507
557
|
|
|
558
|
+
if source:
|
|
559
|
+
if isinstance(source, str):
|
|
560
|
+
title_src = source
|
|
561
|
+
elif isinstance(title, dict):
|
|
562
|
+
title_src = source.get(sheet_name)
|
|
563
|
+
|
|
508
564
|
if right_align_ids:
|
|
509
565
|
r_align_ids.extend(right_align_ids)
|
|
510
566
|
|
|
@@ -546,9 +602,16 @@ def write_table(
|
|
|
546
602
|
if blue_border_row_ids:
|
|
547
603
|
blue_border_ids.extend(blue_border_row_ids)
|
|
548
604
|
|
|
549
|
-
if
|
|
605
|
+
if combine_multiindex:
|
|
550
606
|
cells_to_merge = get_cells_to_merge(df)
|
|
551
607
|
|
|
608
|
+
if autofit_columns == "column_names":
|
|
609
|
+
col_widths = get_max_col_widths(df)
|
|
610
|
+
elif autofit_columns == "all_data":
|
|
611
|
+
col_widths = get_max_col_widths(arr)
|
|
612
|
+
else:
|
|
613
|
+
col_widths = None
|
|
614
|
+
|
|
552
615
|
ws = wb.create_sheet(sheet_name)
|
|
553
616
|
|
|
554
617
|
fmt = cell_formatting(
|
|
@@ -570,9 +633,9 @@ def write_table(
|
|
|
570
633
|
arr=arr,
|
|
571
634
|
fmt=fmt,
|
|
572
635
|
title=title_tbl,
|
|
573
|
-
source=
|
|
636
|
+
source=title_src,
|
|
574
637
|
col_filter=col_filter,
|
|
575
|
-
|
|
638
|
+
col_widths=col_widths,
|
|
576
639
|
cells_to_merge=cells_to_merge,
|
|
577
640
|
)
|
|
578
641
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: toolsos
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: OS tools
|
|
5
5
|
Author-email: OS <d.schmitz@amsterdam.nl>
|
|
6
6
|
Keywords: tools,Onderzoek & Statistiek
|
|
@@ -64,4 +64,4 @@ Instructions on building a package can be found [here](https://packaging.python.
|
|
|
64
64
|
- make a pypi account
|
|
65
65
|
- ask to be added as collaborator to toolsos
|
|
66
66
|
- first update twine: py -m pip install --upgrade twin
|
|
67
|
-
- upload to pypi: twine upload dist/*
|
|
67
|
+
- upload to pypi: twine upload dist/* --skip-existing
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
toolsos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
toolsos/cbs_tools.py,sha256=VLhptzy7m5EaET07s6VeAfDz79g1Hs38qeWPyA14wkw,2823
|
|
3
3
|
toolsos/create_tables.py,sha256=43FHK3EERjumBtnGhngIdtthZzcc_Qi37lJ1MgATzBg,908
|
|
4
|
-
toolsos/database_connection.py,sha256=BlHzLS17KzJP_7R5-IBd8WqgwAt-zDRwJXD4Jx6Tetw,3323
|
|
5
|
-
toolsos/database_transfer.py,sha256=1ghq5VEtKyOdCKdM45uOyrZSoXMuWsdC35R3WNuFvdU,1827
|
|
6
4
|
toolsos/download.py,sha256=88hehmPL5m5d1nrcJjltuh4xrCItF5EYHaZdHOcSt-g,2652
|
|
7
5
|
toolsos/geo.py,sha256=_OexkeUgXcnPW1mw27VN6fMcX2PMUSljLwIg48Xkv3M,2412
|
|
8
6
|
toolsos/helpers.py,sha256=VeOl-fLgePCbjEmAQdVmYe7z8OE1pISeDDuP1t5QSxM,997
|
|
9
7
|
toolsos/polars_helpers.py,sha256=P3RHLQFeDL7-9U_Q1n4ma_NSkdYAiker4pnc57uluHw,770
|
|
8
|
+
toolsos/database/database_connection.py,sha256=z5uDDfw3GPAjWp4rVLwNaE2xpW8n_pgfrZ7cf1D-Mks,3362
|
|
9
|
+
toolsos/database/database_transfer.py,sha256=1ghq5VEtKyOdCKdM45uOyrZSoXMuWsdC35R3WNuFvdU,1827
|
|
10
10
|
toolsos/huisstijl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
toolsos/huisstijl/colors.py,sha256=lSCHCdSjge5cGfLfAObd6mV6TaXq3QGImLOmoGJpGkw,1484
|
|
12
12
|
toolsos/huisstijl/graphs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
toolsos/huisstijl/graphs/bargraph.py,sha256=02-2UCnGyvSKXRSOt-f5WuYu8_-6x9tFEkSi-FdD654,2582
|
|
14
|
-
toolsos/huisstijl/graphs/graph_styles.py,sha256=
|
|
15
|
-
toolsos/huisstijl/graphs/linegraph.py,sha256=
|
|
14
|
+
toolsos/huisstijl/graphs/graph_styles.py,sha256=kiGEo6yyCEywViG17VsM_nUEHhWQ3yQQK5I-NV0Hz34,827
|
|
15
|
+
toolsos/huisstijl/graphs/linegraph.py,sha256=xTYgBwY_aaWnOL9Oz9Ogzhis9OIkEhDSIBk2Pq8Ktms,527
|
|
16
16
|
toolsos/huisstijl/graphs/piegraph.py,sha256=Pzc3vrbvlkv40V3OYWh6bDDc5arRRwJq7dfRzplPKWY,571
|
|
17
|
-
toolsos/huisstijl/graphs/styler.py,sha256=
|
|
17
|
+
toolsos/huisstijl/graphs/styler.py,sha256=XmPLX8sRxcH2OFWn49hzZ6IhAlmCHjUC_m9LKE9c3Sw,6626
|
|
18
18
|
toolsos/huisstijl/tables/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
toolsos/huisstijl/tables/table_helpers.py,sha256=F-gRNx8pNU9P-gocno6zCMRwxMszLfOJXekkg98fZ0Q,163
|
|
19
20
|
toolsos/huisstijl/tables/table_styles.py,sha256=oYU6GJcfqlKpZof5PUjPsA7woJ3Tew78CHPyT0_jY6w,1343
|
|
20
|
-
toolsos/huisstijl/tables/tables.py,sha256=
|
|
21
|
-
toolsos-0.1.
|
|
22
|
-
toolsos-0.1.
|
|
23
|
-
toolsos-0.1.
|
|
24
|
-
toolsos-0.1.
|
|
21
|
+
toolsos/huisstijl/tables/tables.py,sha256=FAlAnMPC-mWKeo7kmMu6aE88-W8k6pmMWERwzz75e4c,21521
|
|
22
|
+
toolsos-0.2.1.dist-info/METADATA,sha256=ifgCSDsbAq9iwCS8-TtxSdwus0ZFDbBCfk6ORgITdoU,2433
|
|
23
|
+
toolsos-0.2.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
24
|
+
toolsos-0.2.1.dist-info/top_level.txt,sha256=2ClEjUBbtfDQ8oPwvWRy1Sz2nrkLCXlg0mHaMdCWia0,8
|
|
25
|
+
toolsos-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|