35 lines
1.7 KiB
Python
Executable file
35 lines
1.7 KiB
Python
Executable file
with open('/workspace/prds/generate_template.py', 'r', encoding='utf-8') as f:
|
|
c = f.read()
|
|
|
|
target_marker = "const dashDone = (pDone / 100) * C;"
|
|
replacement = """const C = 238.76;
|
|
const lDone = (pDone / 100) * C;
|
|
const lInProg = (pInProg / 100) * C;
|
|
const lTodo = (pTodo / 100) * C;
|
|
|
|
container.innerHTML = `
|
|
<div class="donut-svg-container">
|
|
<svg width="180" height="180" viewBox="0 0 100 100" style="transform: rotate(-90deg);">
|
|
<!-- Background track -->
|
|
<circle cx="50" cy="50" r="38" fill="transparent" stroke="#f1f5f9" stroke-width="12" />
|
|
<!-- Done segment (Green) -->
|
|
<circle cx="50" cy="50" r="38" fill="transparent" stroke="#10b981" stroke-width="12"
|
|
stroke-dasharray="${lDone} ${C - lDone}" stroke-dashoffset="0" />
|
|
<!-- InProgress segment (Blue) -->
|
|
<circle cx="50" cy="50" r="38" fill="transparent" stroke="#0284c7" stroke-width="12"
|
|
stroke-dasharray="${lInProg} ${C - lInProg}" stroke-dashoffset="${-lDone}" />
|
|
<!-- ToDo segment (Gray) -->
|
|
<circle cx="50" cy="50" r="38" fill="transparent" stroke="#cbd5e1" stroke-width="12"
|
|
stroke-dasharray="${lTodo} ${C - lTodo}" stroke-dashoffset="${-(lDone + lInProg)}" />
|
|
</svg>"""
|
|
|
|
idx_start = c.find("// SVG circle circumference")
|
|
idx_end = c.find("</svg>", idx_start) + 6
|
|
|
|
if idx_start != -1 and idx_end != -1:
|
|
c = c[:idx_start] + replacement + c[idx_end:]
|
|
with open('/workspace/prds/generate_template.py', 'w', encoding='utf-8') as f:
|
|
f.write(c)
|
|
print("Replaced donut block successfully!")
|
|
else:
|
|
print("Could not find boundaries", idx_start, idx_end)
|