gov-uk-dashboards 24.0.0__py3-none-any.whl → 24.1.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.
@@ -4,6 +4,7 @@ import polars as pl
4
4
  from dash import html, dcc
5
5
  from gov_uk_dashboards.components.dash.card import card
6
6
  from gov_uk_dashboards.components.dash.paragraph import paragraph
7
+ from gov_uk_dashboards.formatting.text_functions import create_id_from_string
7
8
 
8
9
 
9
10
  def table_from_polars_dataframe(
@@ -16,6 +17,7 @@ def table_from_polars_dataframe(
16
17
  format_column_headers_as_markdown: bool = False,
17
18
  sortable_headers: bool = False,
18
19
  table_id: str = "table",
20
+ assign_ids_to_rows: bool = False,
19
21
  table_footer: str = None,
20
22
  column_widths: Optional[list[str]] = None,
21
23
  columns_to_right_align: Optional[list[str]] = None,
@@ -48,6 +50,7 @@ def table_from_polars_dataframe(
48
50
  sortable_headers: (bool, optional): Sets if the column headers should be sortable. Defaults
49
51
  to False.
50
52
  table_id: (str, optional): ID for the table Defaults to "table".
53
+ assign_ids_to_rows: (bool, optional): Adds id's to table rows when True. Defaults to False.
51
54
  table_footer: (str, optional): Text to display underneath table as footer.
52
55
  column_widths: (list[str], optional): Determines width of table columns. Format as a list,
53
56
  "x%". List must be same length as dataframe columns. Defaults to None.
@@ -187,7 +190,14 @@ def table_from_polars_dataframe(
187
190
  else {},
188
191
  )
189
192
  for cell, column_name in zip(row[1:], dataframe.columns[1:])
190
- ]
193
+ ],
194
+ **(
195
+ {
196
+ "id": create_id_from_string(row[0])
197
+ if assign_ids_to_rows and create_id_from_string(row[0])
198
+ else {}
199
+ }
200
+ ),
191
201
  )
192
202
  if first_column_is_header and index != last_row_index
193
203
  else html.Tr(
@@ -200,7 +210,14 @@ def table_from_polars_dataframe(
200
210
  else {},
201
211
  )
202
212
  for cell, column_name in zip(row, dataframe.columns)
203
- ]
213
+ ],
214
+ **(
215
+ {
216
+ "id": create_id_from_string(row[0])
217
+ if assign_ids_to_rows and create_id_from_string(row[0])
218
+ else {}
219
+ }
220
+ ),
204
221
  )
205
222
  )
206
223
  for index, row in enumerate(dataframe.rows())
@@ -0,0 +1,11 @@
1
+ """Functions to format text"""
2
+
3
+ import re
4
+
5
+
6
+ def create_id_from_string(string):
7
+ """Function to create an id from a string. Remove non alphanumeric characters and replaces
8
+ spaces with dashes"""
9
+ if string is None:
10
+ return ""
11
+ return re.sub(r"[^a-z0-9]+", "-", string.lower()).strip("-")
@@ -163,6 +163,11 @@ def get_todays_date_for_downloaded_csv() -> str:
163
163
  return str(datetime.today().strftime("%d/%m/%Y"))
164
164
 
165
165
 
166
+ def convert_datetime_to_dd_mm_yyy_string(input_datetime: datetime):
167
+ """convert datetime to DD/MM/YYYY string"""
168
+ return str(input_datetime.strftime("%d/%m/%Y"))
169
+
170
+
166
171
  def date_string_is_full_month_and_full_year_format(date_string: str):
167
172
  """checks if a date string is in the format $B $Y"""
168
173
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gov_uk_dashboards
3
- Version: 24.0.0
3
+ Version: 24.1.1
4
4
  Summary: Provides access to functionality common to creating a data dashboard.
5
5
  Author: Department for Levelling Up, Housing and Communities
6
6
  Description-Content-Type: text/markdown
@@ -65,7 +65,7 @@ gov_uk_dashboards/components/dash/paragraph.py,sha256=yoWa_B6RLiebBX2QaszY3lyZEx
65
65
  gov_uk_dashboards/components/dash/phase_banner.py,sha256=7XIk_y-kStSaptXnk9yHVu8S0n-ypwWehDqOwjb5l-c,1787
66
66
  gov_uk_dashboards/components/dash/row_component.py,sha256=SdmJqyFJA1Kngyzxy0ooZUegIOiN6Bz1wRq6jGigfII,687
67
67
  gov_uk_dashboards/components/dash/side_navbar.py,sha256=pupA0FdjSbPbzdX9up6wEoIKWIuk3zGRun4opnBieCU,1332
68
- gov_uk_dashboards/components/dash/table.py,sha256=TJ21lWZ3xFueHyg9xq2YbXp5Z-8kUEovr4L0zXTVGvg,10220
68
+ gov_uk_dashboards/components/dash/table.py,sha256=Jt2dFddWsXBaLBXVdO1QKntrT4MYZeG2GgwYycldi64,11060
69
69
  gov_uk_dashboards/components/dash/tooltip.py,sha256=qTkRWQanhG535Yi4NiaLlEMJqqzjubgRdKJDIhxXzd4,978
70
70
  gov_uk_dashboards/components/dash/tooltip_title.py,sha256=2exMYItzR17yOu3gTL77DyUU4Hi3CIB-ZPS8ftetqZg,874
71
71
  gov_uk_dashboards/components/dash/visualisation_commentary.py,sha256=jBy8qy2DWYqodqDZ8QdDmgOO_USDSwn2Sj5CnL58VMM,648
@@ -97,6 +97,7 @@ gov_uk_dashboards/formatting/human_readable.py,sha256=o5-Xlbm7wP_4wU9mIdsG0ztU5a
97
97
  gov_uk_dashboards/formatting/number_formatting.py,sha256=9LVqKqx0mMQyv8XLI_im1pdASZDJxRjzRWtRN-g6kPs,913
98
98
  gov_uk_dashboards/formatting/round_and_add_prefix_and_suffix.py,sha256=_DboRfdvwb9Y62H9LFDFJ0ju4626z-_oFuwagRgyZDY,1456
99
99
  gov_uk_dashboards/formatting/rounding.py,sha256=Em1yri_j18IYHbZ64d3bhVKX-XEllRSM9FzAUo1o6fU,968
100
+ gov_uk_dashboards/formatting/text_functions.py,sha256=vHstpUo16LnsSk-rzwFDNP1SIAy2npIo-4ims1xNa64,306
100
101
  gov_uk_dashboards/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
101
102
  gov_uk_dashboards/lib/enable_basic_auth.py,sha256=Ul2tnopTJm6_UQ1ljKGwk-Ay3Z8KnPNKNjwiBOf1yd0,749
102
103
  gov_uk_dashboards/lib/http_headers.py,sha256=Hur3R0_hAsWz8PntBhD66w4kgdW6EvwHNNugnA0DIJM,1592
@@ -105,12 +106,12 @@ gov_uk_dashboards/lib/dap/__init__.py,sha256=bYga8kJuf9TGkfpnd16SInrD1FcN8iPn4Sz
105
106
  gov_uk_dashboards/lib/dap/dap_deployment.py,sha256=ZXixeOAtRNjMsPdGKLwwLNamlo0miZLaKCckKtq8_iI,2313
106
107
  gov_uk_dashboards/lib/dap/get_dataframe_from_cds.py,sha256=6DUaoVBO4YqwiuCXvetE8_t-8mVcO27HnCRKlzz8Hpk,4090
107
108
  gov_uk_dashboards/lib/datetime_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
- gov_uk_dashboards/lib/datetime_functions/datetime_functions.py,sha256=BQgr8I_vFNYwLi-fE4YC6jZ5PpbPea2rnD_2a_lw0YE,12209
109
+ gov_uk_dashboards/lib/datetime_functions/datetime_functions.py,sha256=e1RXgLBD37n2slm4fKcFSIrb6O9ZoFROceZHO5CUzj8,12379
109
110
  gov_uk_dashboards/lib/download_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
111
  gov_uk_dashboards/lib/download_functions/convert_fig_to_image_and_download.py,sha256=-dkYbpTL6txftFfAZW-vfW_O9efb6Dse9WJ9MM6mAqw,534
111
112
  gov_uk_dashboards/lib/download_functions/download_csv_with_headers.py,sha256=aLL3UodmilZA_1bQhtjtKi3FoB-4X_MtLOcDw5e1Nwo,4412
112
- gov_uk_dashboards-24.0.0.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
113
- gov_uk_dashboards-24.0.0.dist-info/METADATA,sha256=dGVh5xbbOEk_7RcARicohjQMSukSaAzfDAFt8w8a9mw,5890
114
- gov_uk_dashboards-24.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
- gov_uk_dashboards-24.0.0.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
116
- gov_uk_dashboards-24.0.0.dist-info/RECORD,,
113
+ gov_uk_dashboards-24.1.1.dist-info/licenses/LICENSE,sha256=GDiD7Y2Gx7JucPV1JfVySJeah-qiSyBPdpJ6RHCEHTc,1126
114
+ gov_uk_dashboards-24.1.1.dist-info/METADATA,sha256=-E9u_Wvs85lErIoWT9fHIEnFLPw_2FGii3mHAq0V6kY,5890
115
+ gov_uk_dashboards-24.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
+ gov_uk_dashboards-24.1.1.dist-info/top_level.txt,sha256=gPaN1P3-H3Rgi2me6tt-fX_cxo19CZfA4PjlZPjGRpo,18
117
+ gov_uk_dashboards-24.1.1.dist-info/RECORD,,