"""GE Aerospace image pages: the Drivers tab (Deploy/Control/HardwareDriver.json). The page holds the whole driver map in the browser: search and filters, move up/down (PESetup takes the FIRST matching entry, so order is policy), edit an entry in a modal, remove, add an unregistered zip. Nothing is written until Review and save: POST /drivers/check the staged map -> zip status + lint findings per row (services/driver_lint), nothing written POST /drivers/preview per-entry changes with old vs new JSON, the whole file diff, lint before/after; nothing written POST /drivers/save the same body + the previewed hash; backup to HardwareDriver.json.bak--webui, atomic write in the file's own format (services/control_files) POST /drivers/undo put the last save back (only while the file still holds what that save wrote) POST /drivers/orphans/remove delete unregistered zips no image uses Every JSON body carries "base", the map's sha256 when the page was loaded: a map rewritten since (another tab, the Dell updater) is never overwritten with a stale copy. Uploads stay on /drivers/upload in app.py. The endpoint images_drivers.page is the "drivers" row of services/image_pages.IMAGE_TABS; keep the name, or change that row. """ import json import os from flask import Blueprint, flash, jsonify, redirect, render_template, request, url_for from markupsafe import Markup import config from services import control_files, driver_lint, driver_map, hardware_coverage, image_pages from services.audit import audit bp = Blueprint("images_drivers", __name__, url_prefix="/images") UNDO_SCOPE = "drivers" def _unknown(): flash("Unknown image type.", "danger") return redirect(url_for("dashboard")) def _script_json(value): """JSON for a