basic-report 0.4.2__tar.gz → 0.4.4__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 (59) hide show
  1. {basic_report-0.4.2 → basic_report-0.4.4}/PKG-INFO +1 -1
  2. {basic_report-0.4.2 → basic_report-0.4.4}/pyproject.toml +1 -1
  3. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/configs/default.yaml +2 -0
  4. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/heatmap.py +1 -1
  5. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/page.py +49 -3
  6. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/report.py +36 -3
  7. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/base.html +10 -0
  8. basic_report-0.4.4/src/basic_report/templates/elements/download_button.html +8 -0
  9. basic_report-0.4.4/src/basic_report/templates/heatmap/button_next.html +1 -0
  10. basic_report-0.4.4/src/basic_report/templates/heatmap/button_prev.html +1 -0
  11. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/heatmap/script.html +2 -2
  12. basic_report-0.4.2/src/basic_report/templates/heatmap/button_next.html +0 -1
  13. basic_report-0.4.2/src/basic_report/templates/heatmap/button_prev.html +0 -1
  14. {basic_report-0.4.2 → basic_report-0.4.4}/LICENSE.md +0 -0
  15. {basic_report-0.4.2 → basic_report-0.4.4}/README.md +0 -0
  16. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/__init__.py +0 -0
  17. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/basic_report/section_title.css +0 -0
  18. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/bootstrap/bootstrap.min.css +0 -0
  19. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/bootstrap/bootstrap.min.js +0 -0
  20. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/bootstrap/jquery-3.3.1.slim.min.js +0 -0
  21. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/bootstrap/popper.min.js +0 -0
  22. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/datatables/dataTables.bootstrap4.min.js +0 -0
  23. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/datatables/jquery.dataTables.min.js +0 -0
  24. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/CalendarLabel.min.js +0 -0
  25. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/Legend.min.js +0 -0
  26. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/Tooltip.min.js +0 -0
  27. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/cal-heatmap.css +0 -0
  28. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/cal-heatmap.min.js +0 -0
  29. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/d3.v7.min.js +0 -0
  30. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/css_and_scripts/heatmap/popper.min.js +0 -0
  31. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/accordion.css +0 -0
  32. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/colors.css +0 -0
  33. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/heatmap.css +0 -0
  34. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/navbar.css +0 -0
  35. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/site.css +0 -0
  36. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/table.css +0 -0
  37. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/css/tabs.css +0 -0
  38. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/accordion.html +0 -0
  39. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/cards.html +0 -0
  40. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/columns.html +0 -0
  41. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/dictionary.html +0 -0
  42. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/global_links.html +0 -0
  43. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/header.html +0 -0
  44. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/image.html +0 -0
  45. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/list.html +0 -0
  46. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/navbar_left.html +0 -0
  47. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/navbar_right.html +0 -0
  48. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/navbar_top.html +0 -0
  49. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/report_ball_section.html +0 -0
  50. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/report_header.html +0 -0
  51. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/section_title.html +0 -0
  52. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/sublevel.html +0 -0
  53. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/table.html +0 -0
  54. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/tabs.html +0 -0
  55. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/elements/text.html +0 -0
  56. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/heatmap/base.html +0 -0
  57. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/heatmap/heatmap.html +0 -0
  58. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/templates/heatmap/legend.html +0 -0
  59. {basic_report-0.4.2 → basic_report-0.4.4}/src/basic_report/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: basic-report
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: A lightweight Python package for generating clean, professional static HTML reports.
5
5
  Keywords: html,report,static,responsive,website
6
6
  Author: Björn Scholz
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "basic-report"
7
- version = "0.4.2"
7
+ version = "0.4.4"
8
8
  description = "A lightweight Python package for generating clean, professional static HTML reports."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -84,6 +84,7 @@ default_color_profiles:
84
84
  report_ball: slate
85
85
  text: slate
86
86
  navbar: slate
87
+ download_button: light-gray
87
88
  section_title:
88
89
  text: slate
89
90
  bars: slate
@@ -109,6 +110,7 @@ default_color_profiles:
109
110
  report_ball: slate
110
111
  text: slate
111
112
  navbar: slate
113
+ download_button: light-gray
112
114
  section_title:
113
115
  text: slate
114
116
  bars: slate
@@ -397,7 +397,7 @@ class CalendarHeatmap:
397
397
  logger.error(msg)
398
398
  raise RuntimeError(msg)
399
399
 
400
- html = template.render()
400
+ html = template.render(misc_id=self.misc.id)
401
401
  return html
402
402
 
403
403
  def make_heatmap_div(self):
@@ -59,6 +59,7 @@ class ReportPage:
59
59
  self.rel_dir = Path()
60
60
  self.abs_dir = Path(report_dir)
61
61
  self.img_dir = self.abs_dir / 'images'
62
+ self.file_dir = self.abs_dir / 'files'
62
63
  self.rel_file = self.rel_dir / self.file_name
63
64
  self.abs_file = self.abs_dir / self.file_name
64
65
  self.config = config
@@ -123,13 +124,10 @@ class ReportPage:
123
124
  ):
124
125
  """ Add a section containing errors/warnings/infos
125
126
 
126
- If a report ball is provided it takes precedence over the other lists.
127
-
128
127
  Args:
129
128
  errors (Optional[list[str]]): List of errors encountered
130
129
  warnings (Optional[list[str]]): List of warnings encountered
131
130
  info (Optional[list[str]]): List of info encountered
132
-
133
131
  """
134
132
  errors = default(errors, [])
135
133
  warnings = default(warnings, [])
@@ -501,6 +499,54 @@ class ReportPage:
501
499
  html = template.render(source=rel_image_path, responsive=responsive, center=center)
502
500
  self._update_content(html)
503
501
 
502
+ # region File
503
+ # ------------
504
+ def add_download_button(
505
+ self,
506
+ file_source: Union[str, Path],
507
+ remove_source: Optional[bool]=None,
508
+ button_color: Optional[bool]=None,
509
+ button_text: Optional[str]=None,
510
+ min_width: Optional[str]=None
511
+ ):
512
+ """ Add a download button to the page
513
+
514
+ Args:
515
+ file_source (Union[str, Path]): Path to file that needs to be added. The file will be copied to
516
+ report/page/files/
517
+ remove_source (Optional[bool]): If true the source will be deleted and we will only keep the copy in the
518
+ report dir
519
+ button_color (Optional[bool]): Color scheme for the download button
520
+ button_text (Optional[str]): Text written on the download button. If none is given the file name will be
521
+ used
522
+ min_width (Optional[str]): The minimum width of the download button
523
+ """
524
+ self.file_dir.mkdir(parents=True, exist_ok=True)
525
+ remove_source = default(remove_source, False)
526
+ button_color = default(button_color, self.color_map.get_default_color('download_button'))
527
+
528
+ min_width = default(min_width, '40px')
529
+
530
+ file_source = Path(file_source)
531
+ file_name = file_source.name
532
+
533
+ button_text = default(button_text, file_name)
534
+
535
+ file_dest = self.file_dir / file_name
536
+ shutil.copyfile(file_source, file_dest)
537
+ if remove_source:
538
+ file_source.unlink()
539
+
540
+ rel_file_path = self.rel_dir / 'files' / file_name
541
+ template = self.jinja_env.get_template('elements/download_button.html')
542
+ html = template.render(
543
+ file_path=rel_file_path,
544
+ button_color=button_color,
545
+ button_text=button_text,
546
+ min_width=min_width,
547
+ )
548
+ self._update_content(html)
549
+
504
550
  # region Custom HTML Code
505
551
  # -----------------------
506
552
  def add_custom_html_code(self, html: str):
@@ -198,9 +198,20 @@ class Report:
198
198
  """
199
199
  self.current.add_report_header(self.report_title, self.report_date, include_date, include_created_at, color)
200
200
 
201
- def add_error_warning_info_section(self, **kwargs):
202
- """ Add a section detailing errors, warnings, and info """
203
- self.current.add_error_warning_info_section(**kwargs)
201
+ def add_error_warning_info_section(
202
+ self,
203
+ errors: Optional[list[str]]=None,
204
+ warnings: Optional[list[str]]=None,
205
+ info: Optional[list[str]]=None,
206
+ ):
207
+ """ Add a section containing errors/warnings/infos
208
+
209
+ Args:
210
+ errors (Optional[list[str]]): List of errors encountered
211
+ warnings (Optional[list[str]]): List of warnings encountered
212
+ info (Optional[list[str]]): List of info encountered
213
+ """
214
+ self.current.add_error_warning_info_section(errors, warnings, info)
204
215
 
205
216
  def add_header(self, header_text: str, color: Optional[str]=None):
206
217
  """ Add a header to the current page
@@ -395,6 +406,28 @@ class Report:
395
406
  """
396
407
  self.current.add_image(image_source, remove_source, responsive, center)
397
408
 
409
+ def add_download_button(
410
+ self,
411
+ file_source: Union[str, Path],
412
+ remove_source: Optional[bool]=None,
413
+ button_color: Optional[bool]=None,
414
+ button_text: Optional[str]=None,
415
+ min_width: Optional[str]=None
416
+ ):
417
+ """ Add a download button to the page
418
+
419
+ Args:
420
+ file_source (Union[str, Path]): Path to file that needs to be added. The file will be copied to
421
+ report/page/files/
422
+ remove_source (Optional[bool]): If true the source will be deleted and we will only keep the copy in the
423
+ report dir
424
+ button_color (Optional[bool]): Color scheme for the download button
425
+ button_text (Optional[str]): Text written on the download button. If none is given the file name will be
426
+ used
427
+ min_width (Optional[str]): The minimum width of the download button
428
+ """
429
+ self.current.add_download_button(file_source, remove_source, button_color, button_text, min_width)
430
+
398
431
  def add_local_link_to_page(self, page_name: str, link_name: str):
399
432
  """ Add a link to another page to the current page
400
433
 
@@ -37,6 +37,16 @@
37
37
  <link rel="stylesheet" type="text/css" href="css_and_scripts/table.css" />
38
38
  <link rel="stylesheet" type="text/css" href="css_and_scripts/navbar.css" />
39
39
 
40
+ <!-- SYMBOLS --!>
41
+ <svg xmlns="http://www.w3.org/2000/svg" style="display:none">
42
+ <defs>
43
+ <symbol id="icon-download" viewBox="0 0 16 16">
44
+ <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
45
+ <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/>
46
+ </symbol>
47
+ </defs>
48
+ </svg>
49
+
40
50
  {{ head_content }}
41
51
 
42
52
  </head>
@@ -0,0 +1,8 @@
1
+ <div class="container mb-3 justify-content-center">
2
+ <a href="{{ file_path }}" download class="btn btn-{{ button_color }}" style="min-width: {{ min_width }};">
3
+ <svg width="16" height="16" fill="currentColor" class="mr-1">
4
+ <use href="#icon-download"/>
5
+ </svg>
6
+ {{ button_text }}
7
+ </a>
8
+ </div>
@@ -0,0 +1 @@
1
+ <button id="{{ misc_id }}-next-btn" class="btn btn-slate btn-no-focus">Next →</button>
@@ -0,0 +1 @@
1
+ <button id="{{ misc_id }}-prev-btn" class="btn btn-slate btn-no-focus">← Previous</button>
@@ -2,12 +2,12 @@
2
2
  document.addEventListener("DOMContentLoaded", function () {
3
3
 
4
4
  const cal = new CalHeatmap();
5
- document.getElementById("prev-btn").addEventListener("click", function (e) {
5
+ document.getElementById("{{ misc_id }}-prev-btn").addEventListener("click", function (e) {
6
6
  e.preventDefault();
7
7
  cal.previous();
8
8
  });
9
9
 
10
- document.getElementById("next-btn").addEventListener("click", function (e) {
10
+ document.getElementById("{{ misc_id }}-next-btn").addEventListener("click", function (e) {
11
11
  e.preventDefault();
12
12
  cal.next();
13
13
  });
@@ -1 +0,0 @@
1
- <button id="next-btn" class="btn btn-slate btn-no-focus">Next →</button>
@@ -1 +0,0 @@
1
- <button id="prev-btn" class="btn btn-slate btn-no-focus">← Previous</button>
File without changes
File without changes