In this section
- GlobalGrid2050 Add V6 V7 Print V2 Compact Report Mode storage · globalgrid2050 / scripts/add_v6_v7_print_v2_compact_report_mode.py lines 1–383
- GlobalGrid2050 Add V6 V7 Print V3 Financials Patch storage · globalgrid2050 / scripts/add_v6_v7_print_v3_financials_patch.py lines 1–314
GlobalGrid2050 Add V6 V7 Print V2 Compact Report Mode
A Python command-line tool in the scripts folder that reads solar, battery storage (BESS) and cables. It is built from the read step (`read`) and the write step (`write`).
storageglobalgrid2050 / scripts/add_v6_v7_print_v2_compact_report_mode.py · lines 1–383 of 383 · Entry point
- What it does
- It loads solar, battery storage (BESS) and cables. Defines read, write, main. Uses libraries __future__, datetime, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain terms in the code: solar, battery storage (BESS), cables.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Add V6 V7 Print V2 Compact Report Mode Workflow (globalgrid2050).
- What it achieves
- Add V6 and V7 compact A4 portrait print report mode.
- Why it matters
- Run by GlobalGrid2050 Add V6 V7 Print V2 Compact Report Mode Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- __future__, datetime, pathlib
- Used by
- run by GlobalGrid2050 Add V6 V7 Print V2 Compact Report Mode Workflow (workflow run)
- Produces
- read, write, main
- Defines here
- read, write, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/add_v6_v7_print_v2_compact_report_mode.py:1-383 · blob 50819b5f0261127598933fbe249304f1a0aeec41 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: unknown · users: none · canonical: production_core
#!/usr/bin/env python3
"""
Add V6 and V7 compact A4 portrait print report mode.
Purpose:
- Replace weak print rules with stricter compact print layout rules.
- Remove large gaps by reducing padding, avoiding forced page breaks and printing only active tab content.
- Hide interactive controls, tool overlays and irrelevant screen controls.
- Reset expanded map positioning for print.
- Keep map, legend, active inputs, outputs, notes and disclaimers visible.
This script appends a later print CSS block so it overrides earlier print CSS without deleting history.
"""
from __future__ import annotations
import datetime as dt
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
REPORTS = ROOT / "gridbot_reports"
REPORT = REPORTS / "add_v6_v7_print_v2_compact_report_mode.md"
TARGET_CSS = [
ROOT / "solar-bess-topology-v6" / "gis-sld-financial-sandbox" / "gis-sld-v5.css",
ROOT / "solar-bess-topology-v7" / "gis-sld-financial-sandbox" / "gis-sld-v5.css",
ROOT / "solar-bess-topology-v6" / "module-layout" / "module-layout-v5.css",
ROOT / "solar-bess-topology-v7" / "module-layout" / "module-layout-v5.css",
ROOT / "solar-bess-topology-v6" / "dc-ac-lv-topology-review" / "dc-ac-lv-topology-review-v5.css",
ROOT / "solar-bess-topology-v7" / "dc-ac-lv-topology-review" / "dc-ac-lv-topology-review-v5.css",
ROOT / "solar-bess-topology-v6" / "cable-geometry-visualiser" / "style.css",
ROOT / "solar-bess-topology-v7" / "cable-geometry-visualiser" / "style.css",
]
MARKER = "/* GLOBALGRID2050 PRINT V2 COMPACT REPORT MODE */"
PRINT_V2_CSS = r'''
/* GLOBALGRID2050 PRINT V2 COMPACT REPORT MODE */
@media print {
@page {
size: A4 portrait;
margin: 9mm;
}
html,
body {
width: auto !important;
height: auto !important;
min-height: 0 !important;
overflow: visible !important;
display: block !important;
background: #fff !important;
color: #111 !important;
padding: 0 !important;
margin: 0 !important;
font-size: 8.5pt !important;
line-height: 1.22 !important;
}
body::before {
content: "GlobalGrid2050 Screening Report";
display: block !important;
font-weight: 700 !important;
font-size: 11pt !important;
color: #111 !important;
border-bottom: 1px solid #999 !important;
padding: 0 0 3mm 0 !important;
margin: 0 0 4mm 0 !important;
}
.dashboard,
.module-app-shell,
.module-main,
.topo-main,
main {
display: block !important;
width: 100% !important;
max-width: none !important;
height: auto !important;
min-height: 0 !important;
overflow: visible !important;
gap: 0 !important;
}
header,
.panel,
.panel-left,
.panel-right,
.module-panel,
.topo-panel,
.module-map-card,
.guidance-box,
.warning-box,
.status-box,
.module-note {
display: block !important;
position: static !important;
inset: auto !important;
float: none !important;
width: 100% !important;
max-width: none !important;
height: auto !important;
min-height: 0 !important;
overflow: visible !important;
background: #fff !important;
color: #111 !important;
border: 1px solid #ccc !important;
border-radius: 0 !important;
box-shadow: none !important;
padding: 3.5mm !important;
margin: 0 0 4mm 0 !important;
break-inside: avoid;
page-break-inside: avoid;
}
.panel-left,
.module-panel,
.topo-panel {
column-count: 2;
column-gap: 8mm;
column-rule: 1px solid #ddd;
}
.panel-right,
.panel-right.map-expanded,
.panel-right.map-fullscreen,
.module-map-card {
position: static !important;
inset: auto !important;
width: 100% !important;
height: auto !important;
min-height: 0 !important;
z-index: auto !important;
page-break-before: auto !important;
break-before: auto !important;
column-count: initial !important;
column-gap: initial !important;
column-rule: none !important;
}
#map,
#module_map {
display: block !important;
width: 100% !important;
height: 125mm !important;
min-height: 125mm !important;
max-height: 125mm !important;
border: 1px solid #999 !important;
margin: 0 0 3mm 0 !important;
break-inside: avoid;
page-break-inside: avoid;
}
canvas,
svg {
max-width: 100% !important;
height: auto !important;
break-inside: avoid;
page-break-inside: avoid;
}
.maplibregl-canvas,
.maplibregl-map {
max-width: 100% !important;
}
.map-controls,
.map-tool-overlay,
.module-map-toolbar,
.crosshair,
#fetch_status,
.maplibregl-control-container,
.maplibregl-ctrl,
.maplibregl-ctrl-group,
.search-box,
.button-row,
.btn,
button,
.tab-container,
.topo-tabs,
.toolbar,
.print-btn,
[id*="btn_"],
[class*="toggle"] {
display: none !important;
}
.legend {
display: block !important;
position: static !important;
width: 100% !important;
max-width: none !important;
background: #fff !important;
color: #111 !important;
border: 1px solid #ccc !important;
padding: 2.5mm !important;
margin: 2mm 0 0 0 !important;
font-size: 7.5pt !important;
break-inside: avoid;
page-break-inside: avoid;
}
.legend * {
color: #111 !important;
}
h1 {
font-size: 14pt !important;
line-height: 1.15 !important;
margin: 0 0 3mm 0 !important;
padding: 0 !important;
}
h2 {
font-size: 10pt !important;
line-height: 1.15 !important;
margin: 2.5mm 0 1.5mm 0 !important;
padding: 0 0 1mm 0 !important;
border-bottom: 1px solid #999 !important;
color: #111 !important;
break-after: avoid;
page-break-after: avoid;
}
h3 {
font-size: 8.5pt !important;
line-height: 1.15 !important;
margin: 2mm 0 1mm 0 !important;
padding: 0 0 0.75mm 0 !important;
border-bottom: 1px dotted #bbb !important;
color: #111 !important;
break-after: avoid;
page-break-after: avoid;
}
p,
label,
div,
span,
small,
strong,
li {
color: #111 !important;
}
p {
margin: 0 0 2mm 0 !important;
}
.input-group,
.module-stat,
.stat-row,
.summary-row {
display: grid !important;
grid-template-columns: 1fr auto !important;
gap: 2mm !important;
align-items: baseline !important;
margin: 0 0 1mm 0 !important;
break-inside: avoid;
page-break-inside: avoid;
}
input,
select,
textarea {
color: #111 !important;
background: #fff !important;
border: none !important;
border-bottom: 1px solid #aaa !important;
padding: 0 !important;
min-height: 0 !important;
font-size: 8.5pt !important;
print-color-adjust: exact;
-webkit-print-color-adjust: exact;
}
.tab-content,
.topo-mode {
display: none !important;
}
.tab-content.active,
.topo-mode.active,
.topo-mode[data-mode-panel].active {
display: block !important;
}
details:not([open]) {
display: none !important;
}
.collapsed,
.hidden,
[hidden] {
display: none !important;
}
.warning,
.notice,
.guidance-box,
.warning-box,
.status-box,
.module-note {
font-size: 8pt !important;
line-height: 1.2 !important;
}
a::after {
content: "" !important;
}
* {
text-shadow: none !important;
box-shadow: none !important;
print-color-adjust: exact;
-webkit-print-color-adjust: exact;
}
}
'''
def read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def write(path: Path, text: str) -> None:
path.write_text(text, encoding="utf-8")
def main() -> int:
actions: list[str] = []
for path in TARGET_CSS:
if not path.exists():
raise SystemExit(f"Missing CSS file: {path.relative_to(ROOT)}")
css = read(path)
if MARKER in css:
actions.append(f"already present: {path.relative_to(ROOT)}")
continue
write(path, css.rstrip() + PRINT_V2_CSS + "\n")
actions.append(f"appended print v2 compact report mode: {path.relative_to(ROOT)}")
REPORTS.mkdir(parents=True, exist_ok=True)
timestamp = dt.datetime.now(dt.timezone.utc).isoformat()
report = "\n".join([
"# Add V6 V7 Print V2 Compact Report Mode",
"",
f"UTC created: {timestamp}",
"",
"## Purpose",
"",
"Improve A4 portrait PDF output by reducing white space, hiding irrelevant controls and preventing map overlap.",
"",
"## Fixes targeted",
"",
"- Do not print inactive tabs.",
"- Do not print map controls or tool overlays.",
"- Reset expanded or fullscreen map positioning before print.",
"- Reduce panel padding and font size for A4 portrait.",
"- Use two compact columns for input and output panels where appropriate.",
"- Keep map and legend as report figures rather than raw UI overlays.",
"",
"## Actions",
"",
*[f"- {a}" for a in actions],
"",
"## Manual acceptance test",
"",
"1. Open each V6 and V7 app.",
"2. Press Print or use browser print.",
"3. Confirm active tab only is printed.",
"4. Confirm no tool buttons appear in the PDF.",
"5. Confirm map is not overlaid on report text.",
"6. Confirm there are no large blank gaps between report sections.",
"",
])
write(REPORT, report)
print(f"Print V2 compact report mode complete. Report: {REPORT.relative_to(ROOT)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())GlobalGrid2050 Add V6 V7 Print V3 Financials Patch
A Python command-line tool in the scripts folder that reads solar and battery storage (BESS). It is built from the read step (`read`) and the write step (`write`).
storageglobalgrid2050 / scripts/add_v6_v7_print_v3_financials_patch.py · lines 1–314 of 314 · Entry point
- What it does
- It loads solar and battery storage (BESS). Defines read, write, main. Uses libraries __future__, datetime, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain terms in the code: solar, battery storage (BESS).
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Add V6 V7 Print V3 Financials Patch Workflow (globalgrid2050).
- What it achieves
- Add V6 and V7 print V3 financial formatting patch.
- Why it matters
- Run by GlobalGrid2050 Add V6 V7 Print V3 Financials Patch Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- __future__, datetime, pathlib
- Used by
- run by GlobalGrid2050 Add V6 V7 Print V3 Financials Patch Workflow (workflow run)
- Produces
- read, write, main
- Defines here
- read, write, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/add_v6_v7_print_v3_financials_patch.py:1-314 · blob 28eab63ee4ce861eda9cb48aa79b689a52017bbd · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: unknown · users: none · canonical: production_core
#!/usr/bin/env python3
"""
Add V6 and V7 print V3 financial formatting patch.
Purpose:
- Make expanded financial tabs print compactly.
- Remove green/cyan/orange financial screen colours from print.
- Reduce blank spaces in financial sections.
- Hide inactive topology tab content more aggressively.
- Keep finance details readable in A4 portrait PDF output.
"""
from __future__ import annotations
import datetime as dt
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
REPORTS = ROOT / "gridbot_reports"
REPORT = REPORTS / "add_v6_v7_print_v3_financials_patch.md"
TARGET_CSS = [
ROOT / "solar-bess-topology-v6" / "gis-sld-financial-sandbox" / "gis-sld-v5.css",
ROOT / "solar-bess-topology-v7" / "gis-sld-financial-sandbox" / "gis-sld-v5.css",
]
MARKER = "/* GLOBALGRID2050 PRINT V3 FINANCIALS PATCH */"
PRINT_V3_CSS = r'''
/* GLOBALGRID2050 PRINT V3 FINANCIALS PATCH */
@media print {
@page {
size: A4 portrait;
margin: 8mm;
}
body {
font-size: 8pt !important;
line-height: 1.16 !important;
}
/* Print only the selected topology tab. */
#string_tab:not(.active),
#central_tab:not(.active),
.tab-content:not(.active) {
display: none !important;
height: 0 !important;
min-height: 0 !important;
max-height: 0 !important;
overflow: hidden !important;
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
}
#string_tab.active,
#central_tab.active,
.tab-content.active {
display: block !important;
height: auto !important;
max-height: none !important;
overflow: visible !important;
}
/* Financial section should read like a report table, not a screen form. */
details.finance-box,
details.finance-box[open],
.finance-box {
display: block !important;
open: true;
background: #ffffff !important;
color: #111111 !important;
border: 1px solid #bbbbbb !important;
border-radius: 0 !important;
padding: 2.5mm !important;
margin: 2mm 0 3mm 0 !important;
break-inside: auto !important;
page-break-inside: auto !important;
}
.finance-box summary {
display: block !important;
font-weight: 700 !important;
font-size: 9pt !important;
color: #111111 !important;
border-bottom: 1px solid #999999 !important;
padding: 0 0 1.5mm 0 !important;
margin: 0 0 2mm 0 !important;
list-style: none !important;
}
.finance-box summary::-webkit-details-marker {
display: none !important;
}
.finance-headline,
.finance-box .finance-headline {
display: grid !important;
grid-template-columns: 1fr 1fr !important;
column-gap: 6mm !important;
row-gap: 0.6mm !important;
background: #ffffff !important;
border: 0 !important;
padding: 0 !important;
margin: 0 0 2mm 0 !important;
}
.finance-box h3 {
display: block !important;
clear: both !important;
font-size: 8.5pt !important;
color: #111111 !important;
border-bottom: 1px solid #bbbbbb !important;
margin: 2mm 0 1mm 0 !important;
padding: 0 0 0.8mm 0 !important;
break-after: avoid !important;
page-break-after: avoid !important;
}
.finance-box .input-group,
.finance-box .stat-row,
details.finance-box .input-group,
details.finance-box .stat-row {
display: grid !important;
grid-template-columns: minmax(0, 1fr) 34mm !important;
gap: 2mm !important;
align-items: baseline !important;
min-height: 0 !important;
height: auto !important;
margin: 0 !important;
padding: 0.55mm 0 !important;
border-bottom: 1px dotted #dddddd !important;
break-inside: avoid !important;
page-break-inside: avoid !important;
}
.finance-box .input-group[style],
details.finance-box .input-group[style] {
display: grid !important;
grid-template-columns: minmax(0, 1fr) 58mm !important;
margin: 0 !important;
padding: 0.55mm 0 !important;
}
.finance-box label,
.finance-box .stat-row span:first-child {
color: #111111 !important;
font-weight: 400 !important;
white-space: normal !important;
}
.finance-box input,
.finance-box select,
.finance-box textarea,
.finance-box .stat-val,
.finance-box .cyan,
.finance-box .orange,
.finance-box .green,
.finance-box [class*="cyan"],
.finance-box [class*="green"],
.finance-box [class*="orange"] {
color: #111111 !important;
background: #ffffff !important;
border: 0 !important;
border-bottom: 1px solid #aaaaaa !important;
box-shadow: none !important;
text-shadow: none !important;
font-weight: 700 !important;
text-align: right !important;
min-height: 0 !important;
height: auto !important;
padding: 0 !important;
margin: 0 !important;
}
.finance-box select {
white-space: normal !important;
text-align: left !important;
font-weight: 400 !important;
width: 100% !important;
}
.finance-box .warning-box,
.finance-box [id$="_warnings"] {
display: block !important;
color: #111111 !important;
background: #ffffff !important;
border: 1px solid #999999 !important;
padding: 2mm !important;
margin: 2mm 0 0 0 !important;
font-size: 7.5pt !important;
line-height: 1.18 !important;
}
.finance-box .warning-box:empty,
.finance-box [id$="_warnings"]:empty {
display: none !important;
}
/* Prevent repeated zero width oddities and duplicated single values. */
.finance-box input[type="checkbox"] {
width: 4mm !important;
height: 4mm !important;
border: 1px solid #111111 !important;
}
/* Compact normal left report panels after finance expansion. */
.panel-left {
padding: 3mm !important;
}
.panel-left > h2 {
font-size: 11pt !important;
margin-bottom: 3mm !important;
}
.stat-box,
.disclaimer-box,
.explainer-box {
padding: 2.5mm !important;
margin: 0 0 3mm 0 !important;
}
.explainer-box p,
.disclaimer-box,
.ux-note {
font-size: 7.6pt !important;
line-height: 1.18 !important;
}
/* Keep the map as a final report figure and not an oversized blank section. */
.panel-right {
padding: 3mm !important;
margin-top: 3mm !important;
}
#map {
height: 115mm !important;
min-height: 115mm !important;
max-height: 115mm !important;
}
.legend {
font-size: 7pt !important;
padding: 2mm !important;
margin-top: 2mm !important;
}
}
'''
def read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def write(path: Path, text: str) -> None:
path.write_text(text, encoding="utf-8")
def main() -> int:
actions: list[str] = []
for path in TARGET_CSS:
if not path.exists():
raise SystemExit(f"Missing CSS file: {path.relative_to(ROOT)}")
css = read(path)
if MARKER in css:
actions.append(f"already present: {path.relative_to(ROOT)}")
continue
write(path, css.rstrip() + PRINT_V3_CSS + "\n")
actions.append(f"appended print v3 financials patch: {path.relative_to(ROOT)}")
REPORTS.mkdir(parents=True, exist_ok=True)
timestamp = dt.datetime.now(dt.timezone.utc).isoformat()
report = "\n".join([
"# Add V6 V7 Print V3 Financials Patch",
"",
f"UTC created: {timestamp}",
"",
"## Purpose",
"",
"Improve print output where the financial details panel is expanded.",
"",
"## Fixes",
"",
"- Print only the active topology tab.",
"- Compact financial headline rows into two columns.",
"- Remove green, cyan and orange financial colours in print.",
"- Use black financial values for PDF readability.",
"- Reduce large blank spaces and excessive padding.",
"- Improve Development Stage wrapping.",
"- Keep financial warnings readable as compact report notes.",
"",
"## Actions",
"",
*[f"- {a}" for a in actions],
"",
"## Manual acceptance test",
"",
"1. Open V6 or V7 GIS SLD.",
"2. Expand Baseline Project Economics.",
"3. Print to A4 portrait PDF.",
"4. Confirm finance values are black and readable.",
"5. Confirm only the active tab prints.",
"6. Confirm no large blank gaps appear around the finance section.",
"",
])
write(REPORT, report)
print(f"Print V3 financials patch complete. Report: {REPORT.relative_to(ROOT)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())