toolsos 0.1.4__tar.gz → 0.2.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.
Files changed (32) hide show
  1. {toolsos-0.1.4 → toolsos-0.2.1}/PKG-INFO +2 -2
  2. {toolsos-0.1.4 → toolsos-0.2.1}/README.md +1 -1
  3. {toolsos-0.1.4 → toolsos-0.2.1}/pyproject.toml +1 -1
  4. {toolsos-0.1.4/src/toolsos → toolsos-0.2.1/src/toolsos/database}/database_connection.py +9 -7
  5. toolsos-0.2.1/src/toolsos/huisstijl/graphs/graph_styles.py +30 -0
  6. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/graphs/linegraph.py +5 -1
  7. toolsos-0.2.1/src/toolsos/huisstijl/graphs/styler.py +182 -0
  8. toolsos-0.2.1/src/toolsos/huisstijl/tables/table_helpers.py +6 -0
  9. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/tables/tables.py +99 -36
  10. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos.egg-info/PKG-INFO +2 -2
  11. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos.egg-info/SOURCES.txt +3 -2
  12. toolsos-0.1.4/src/toolsos/huisstijl/graphs/graph_styles.py +0 -24
  13. toolsos-0.1.4/src/toolsos/huisstijl/graphs/styler.py +0 -103
  14. {toolsos-0.1.4 → toolsos-0.2.1}/setup.cfg +0 -0
  15. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/__init__.py +0 -0
  16. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/cbs_tools.py +0 -0
  17. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/create_tables.py +0 -0
  18. {toolsos-0.1.4/src/toolsos → toolsos-0.2.1/src/toolsos/database}/database_transfer.py +0 -0
  19. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/download.py +0 -0
  20. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/geo.py +0 -0
  21. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/helpers.py +0 -0
  22. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/__init__.py +0 -0
  23. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/colors.py +0 -0
  24. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/graphs/__init__.py +0 -0
  25. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/graphs/bargraph.py +0 -0
  26. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/graphs/piegraph.py +0 -0
  27. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/tables/__init__.py +0 -0
  28. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/huisstijl/tables/table_styles.py +0 -0
  29. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos/polars_helpers.py +0 -0
  30. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos.egg-info/dependency_links.txt +0 -0
  31. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos.egg-info/requires.txt +0 -0
  32. {toolsos-0.1.4 → toolsos-0.2.1}/src/toolsos.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: toolsos
3
- Version: 0.1.4
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
@@ -35,4 +35,4 @@ Instructions on building a package can be found [here](https://packaging.python.
35
35
  - make a pypi account
36
36
  - ask to be added as collaborator to toolsos
37
37
  - first update twine: py -m pip install --upgrade twin
38
- - upload to pypi: twine upload dist/*
38
+ - upload to pypi: twine upload dist/* --skip-existing
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "toolsos"
9
- version = "0.1.4"
9
+ version = "0.2.1"
10
10
  description = "OS tools"
11
11
  readme = "README.md"
12
12
  authors = [{ name = "OS", email = "d.schmitz@amsterdam.nl" }]
@@ -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["pw"] == "acces_token":
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
- # engine_strings = get_db_connection_strings("python/database_config.yml")
108
- # print(engine_strings.ruimte_analyse222)
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
- # engine_strings = get_db_connection_strings(
112
- # "python/database_config.yml", reset_pw=["ruimte_analyse222"]
113
- # )
114
- # print(engine_strings.ruimte_analyse222)
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)
@@ -0,0 +1,30 @@
1
+ font = "Amsterdam Sans ExtraBold, Corbel"
2
+ # font = "Arial"
3
+
4
+ STYLE_OLD = {
5
+ "font": {"family": "Corbel", "size": 15},
6
+ "plot_bgcolor": "#FFFFFF",
7
+ "gridline_color": "#E8E8E8",
8
+ "gridlinewidth": 0.75,
9
+ "showline": True,
10
+ "showgrid": False,
11
+ "zerolinecolor": "#E8E8E8",
12
+ "gridcolor": "#E8E8E8",
13
+ "separators": ",",
14
+ }
15
+
16
+
17
+ STYLE_NEW = {
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},
21
+ "plot_bgcolor": "#FFFFFF",
22
+ "gridline_color": "#dbdbdb",
23
+ "gridline_width": 0.75,
24
+ "showline": True,
25
+ "showgrid": False,
26
+ "zerolinecolor": "#dbdbdb",
27
+ "gridcolor": "#dbdbdb",
28
+ "gridlinecolor": "#dbdbdb",
29
+ "separators": ",",
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
@@ -0,0 +1,182 @@
1
+ import json
2
+
3
+ import plotly.graph_objects as go
4
+ import requests
5
+ from requests import ConnectionError
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
+
102
+
103
+ class BaseStyle:
104
+ def __init__(self, style_path=None):
105
+ if style_path is None:
106
+ self.style = STYLE_NEW
107
+ else:
108
+ with open(style_path) as file:
109
+ self.style = json.load(file)
110
+
111
+ def _get_axis_format(self):
112
+ self.gridline_color = "#dbdbdb" # Jorren vragen om deze aan te passen
113
+
114
+ return {
115
+ "zerolinecolor": self.style["gridline_color"],
116
+ "gridcolor": self.style["gridline_color"],
117
+ "gridwidth": self.style["gridline_width"],
118
+ "showline": True,
119
+ "linewidth": self.style["gridline_width"],
120
+ "linecolor": self.style["gridline_color"],
121
+ "showgrid": self.style["showgrid"],
122
+ }
123
+
124
+ def _get_base_template_layout(self):
125
+ return go.layout.Template(
126
+ layout={
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"],
140
+ "separators": ",", # Jorren vragen om deze toe te voegen
141
+ "font": self.style["font_bold"],
142
+ }
143
+ )
144
+
145
+ def get_base_template(
146
+ self, graph_type: str = None, orientation: str = None, colors: str = None
147
+ ):
148
+ """[summary]
149
+
150
+ Args:
151
+ graph_type (str, optional): Pick 'bar', 'line' or 'bar'. Defaults to None.
152
+ orientation (str, optional): [description]. Pick horizontal ('h') or vertical 'v'. Defaults to None.
153
+ colors (str, optional): Set basecolors. Defaults to None.
154
+
155
+ Raises:
156
+ ValueError: [description]
157
+
158
+ Returns:
159
+ [type]: [description]
160
+ """
161
+ base_template = self._get_base_template_layout()
162
+ axis_format = self._get_axis_format()
163
+
164
+ if graph_type == "bar":
165
+ if orientation in ["v", "vertical"]:
166
+ base_template.layout.xaxis.update(axis_format)
167
+ base_template.layout.yaxis.update(zeroline=False)
168
+ elif orientation in ["h", "horizontal"]:
169
+ base_template.layout.yaxis.update(axis_format)
170
+ base_template.layout.xaxis.update(zeroline=False)
171
+ else:
172
+ raise ValueError(
173
+ "Orientation ('v'/'vertical' or 'h'/'horizontal') should be supplied with graph_type=='bar'"
174
+ )
175
+
176
+ elif graph_type == "line":
177
+ base_template.layout.xaxis.update(axis_format)
178
+
179
+ if colors:
180
+ base_template.layout.update({"colorway": colors})
181
+
182
+ return base_template
@@ -0,0 +1,6 @@
1
+ import pandas as pd
2
+
3
+
4
+ def remove_underscores_from_columns(df: pd.DataFrame) -> pd.DataFrame:
5
+ df.columns = df.columns.str.replace("_", " ")
6
+ return df
@@ -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, n_levels=1):
71
- levels = flatten_multiindex_columns(df)
72
- levels = levels[0:n_levels]
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
- merge_cells = []
75
- start_col = 1
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
- for level in levels:
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 merge_cells
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
- autofit_columns: bool | None = None,
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
- def _merge_cells(ws, cells_to_merge):
409
- for start, stop in cells_to_merge:
410
- cell = ws.cell(1, start)
411
- cell.alignment = Alignment(horizontal="left")
412
- ws.merge_cells(start_row=1, end_row=1, start_column=start, end_column=stop)
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(width, height + 1, source)
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: bool | None = False,
495
+ autofit_columns: str | None = "column_names",
451
496
  col_filter: bool | None = False,
452
497
  style: str = "old",
453
- combine_multiindex_cols: bool | int = False,
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 combine_multiindex_cols:
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=source,
636
+ source=title_src,
574
637
  col_filter=col_filter,
575
- autofit_columns=autofit_columns,
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.4
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
@@ -3,8 +3,6 @@ pyproject.toml
3
3
  src/toolsos/__init__.py
4
4
  src/toolsos/cbs_tools.py
5
5
  src/toolsos/create_tables.py
6
- src/toolsos/database_connection.py
7
- src/toolsos/database_transfer.py
8
6
  src/toolsos/download.py
9
7
  src/toolsos/geo.py
10
8
  src/toolsos/helpers.py
@@ -14,6 +12,8 @@ src/toolsos.egg-info/SOURCES.txt
14
12
  src/toolsos.egg-info/dependency_links.txt
15
13
  src/toolsos.egg-info/requires.txt
16
14
  src/toolsos.egg-info/top_level.txt
15
+ src/toolsos/database/database_connection.py
16
+ src/toolsos/database/database_transfer.py
17
17
  src/toolsos/huisstijl/__init__.py
18
18
  src/toolsos/huisstijl/colors.py
19
19
  src/toolsos/huisstijl/graphs/__init__.py
@@ -23,5 +23,6 @@ src/toolsos/huisstijl/graphs/linegraph.py
23
23
  src/toolsos/huisstijl/graphs/piegraph.py
24
24
  src/toolsos/huisstijl/graphs/styler.py
25
25
  src/toolsos/huisstijl/tables/__init__.py
26
+ src/toolsos/huisstijl/tables/table_helpers.py
26
27
  src/toolsos/huisstijl/tables/table_styles.py
27
28
  src/toolsos/huisstijl/tables/tables.py
@@ -1,24 +0,0 @@
1
- STYLE_OLD = {
2
- "font": {"family": "Corbel", "font_size": 15},
3
- "plot_bgcolor": "#FFFFFF",
4
- "gridline_color": "#E8E8E8",
5
- "gridlinewidth": 0.75,
6
- "showline": True,
7
- "showgrid": False,
8
- "zerolinecolor": "#E8E8E8",
9
- "gridcolor": "#E8E8E8",
10
- "separators": ",",
11
- }
12
-
13
-
14
- STYLE_NEW = {
15
- "font": "Amsterdam Sans ExtraBold, Corbel",
16
- "font_size": 15,
17
- "plot_bgcolor": "#FFFFFF",
18
- "gridline_color": "#E8E8E8",
19
- "gridlinewidth": 0.75,
20
- "showline": True,
21
- "showgrid": False,
22
- "zerolinecolor": "#E8E8E8",
23
- "gridcolor": "#E8E8E8",
24
- }
@@ -1,103 +0,0 @@
1
- import json
2
-
3
- import plotly.graph_objects as go
4
- import requests
5
- from requests import ConnectionError
6
-
7
-
8
- class BaseStyle:
9
- style_url = (
10
- "https://raw.githubusercontent.com/jbosga-ams/oistyle/main/base_style.json"
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
23
- else:
24
- res = json.loads()
25
-
26
- for k, v in res.items():
27
- setattr(self, k, v)
28
-
29
- self.font = "Amsterdam Sans ExtraBold, Corbel"
30
-
31
- def _get_axis_format(self):
32
- self.gridline_color = "#dbdbdb" # Jorren vragen om deze aan te passen
33
-
34
- return {
35
- "zerolinecolor": self.gridline_color,
36
- "gridcolor": self.gridline_color,
37
- "gridwidth": self.gridline_width,
38
- "showline": True,
39
- "linewidth": self.gridline_width,
40
- "linecolor": self.gridline_color,
41
- # "mirror": True,
42
- "showgrid": False,
43
- }
44
-
45
- def _get_base_template_layout(self):
46
- return go.layout.Template(
47
- layout={
48
- "font": {"family": self.font, "size": self.font_size},
49
- "plot_bgcolor": self.plot_bgcolor,
50
- "colorway": self.colors["darkblue_lightblue_gradient_5"],
51
- "separators": ",", # Jorren vragen om deze toe te voegen
52
- }
53
- )
54
-
55
- def get_base_template(
56
- self, graph_type: str = None, orientation: str = None, colors: str = None
57
- ):
58
- """[summary]
59
-
60
- Args:
61
- graph_type (str, optional): Pick 'bar', 'line' or 'bar'. Defaults to None.
62
- orientation (str, optional): [description]. Pick horizontal ('h') or vertical 'v'. Defaults to None.
63
- colors (str, optional): Set basecolors. Defaults to None.
64
-
65
- Raises:
66
- ValueError: [description]
67
-
68
- Returns:
69
- [type]: [description]
70
- """
71
- base_template = self._get_base_template_layout()
72
- axis_format = self._get_axis_format()
73
-
74
- if graph_type == "bar":
75
- if orientation in ["v", "vertical"]:
76
- base_template.layout.xaxis.update(axis_format)
77
- base_template.layout.yaxis.update(zeroline=False)
78
- elif orientation in ["h", "horizontal"]:
79
- base_template.layout.yaxis.update(axis_format)
80
- base_template.layout.xaxis.update(zeroline=False)
81
- else:
82
- raise ValueError(
83
- "Orientation ('v'/'vertical' or 'h'/'horizontal') should be supplied with graph_type=='bar'"
84
- )
85
-
86
- elif graph_type == "line":
87
- base_template.layout.xaxis.update(axis_format)
88
-
89
- if colors:
90
- base_template.layout.update({"colorway": colors})
91
-
92
- 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): ...
File without changes
File without changes
File without changes
File without changes
File without changes