Files
kis_trader/scratch/move_recent_jobs.py

44 lines
1.4 KiB
Python

import re
import sys
with open('templates/backtest.html', 'r', encoding='utf-8') as f:
content = f.read()
# The block starts with <div class="card p-3 mb-3"> and ends after the table and its div.
# We'll use regex to grab it precisely by searching for the "최근 잡" header.
start_idx = content.find(' <div class="card p-3 mb-3">\n <div class="d-flex flex-wrap justify-content-between align-items-center gap-2 mb-2">\n <h6 class="mb-0">최근 잡')
if start_idx == -1:
print("Could not find start of block")
sys.exit(1)
# Find the end of the block (the closing div of the card)
end_str = ' </table>\n </div>\n </div>\n'
end_idx = content.find(end_str, start_idx)
if end_idx == -1:
print("Could not find end of block")
sys.exit(1)
end_idx += len(end_str)
block = content[start_idx:end_idx]
# Remove the block from the original location
content = content[:start_idx] + content[end_idx:]
# Find the insertion point: right after <div id="tab-optuna" style="display:none">
insert_target = ' <div id="tab-optuna" style="display:none">\n'
insert_idx = content.find(insert_target)
if insert_idx == -1:
print("Could not find insertion target")
sys.exit(1)
insert_idx += len(insert_target)
# Insert the block
content = content[:insert_idx] + block + content[insert_idx:]
with open('templates/backtest.html', 'w', encoding='utf-8') as f:
f.write(content)
print("Moved 'Recent Jobs' block successfully.")