import io p = "index.html" s = open(p).read() PHOTOS = { "blackWidow":"blackWidow.jpg","dampwood":"dampwood.jpg","subter":"subter.jpg", "carpAnt":"carpAnt.jpg","notchAnt":"notchAnt.jpg","mound":"mound.jpg", "buprestid":"buprestid.jpg","german":"german.jpg","oriental":"oriental.jpg", "american":"american.jpg","brownband":"brownband.jpg","drugstore":"drugstore.png", "sawtooth":"sawtooth.png","indianmeal":"indianmeal.jpg","carpetLarva":"carpetLarva.jpg", "clothesMoth":"clothesMoth.jpg","clusterFly":"clusterFly.jpg","mothFly":"mothFly.jpg", "hobo":"hobo.gif","mosquito":"mosquito.jpg","flea":"flea.jpg","tick":"tick.jpg", "bedbug":"bedbug.jpg","moleGopher":"moleGopher.jpg","bat":"bat.jpg", } WANOTES = { "blackWidow": "Washington's widow is the western black widow (Latrodectus hesperus) — most common east of the Cascades. The red hourglass is on the underside of the abdomen, never the top.", "dampwood": "The Pacific dampwood termite is the dominant termite west of the Cascades. It needs moist wood but no ground contact — soldiers are large with dark, rectangular heads. Look for it in wet framing and log piles.", "subter": "The western subterranean termite (Reticulitermes hesperus) is WA's main soil-touching termite. Winged swarms fly on warm, humid spring days — a swarm indoors is the classic WA alarm bell.", "carpAnt": "Carpenter ants are the #1 wood-destroying pest in Washington. The PNW species Camponotus modoc has a smooth, evenly-rounded thorax. Piles of coarse sawdust ('frass') under a sill plate are the tell.", "notchAnt": "Moisture ants (Lasius) are a Washington sign of decaying wood — their presence means water is already winning. The notched, uneven thorax (side view) separates them from carpenter ants.", "mound": "The western thatching ant (Formica obscuripes) builds the dome mounds of grass and twigs seen across WA clear-cuts and yards — they bite, don't sting.", "buprestid": "The golden buprestid (Buprestis aurulenta) is a PNW native — its larvae tunnel Douglas fir and can emerge from milled lumber years later.", "hobo": "The hobo spider (Eratigena agrestis) is a Pacific Northwest native and one of the most common house spiders in WA — the old 'hobo bite is necrotic' claim is disproven; it's medically harmless.", "tick": "The Rocky Mountain wood tick (Dermacentor andersoni) is the hard tick of Eastern WA rangeland — a vector of Rocky Mountain spotted fever.", "bat": "The little brown bat (Myotis lucifugus) is WA's most common bat — the usual species found roosting in attics and gable vents.", "moleGopher": "The Townsend's mole is the mole of Western WA lawns — raised surface tunnels, not the fan-shaped mounds of a gopher.", "mosquito": "WA's most bothersome mosquitoes are Culex and Aedes species breeding in standing water — Culex pipiens can vector West Nile in Eastern WA.", "bedbug": "Bed bugs are a growing WA urban issue — confirm with the cast skins and fecal spots at mattress seams, not just bites.", } INJECT = r''' ''' CSS = r''' ''' # 1. swap the two render sites old1 = '
${ART[p.art]||\'\'}
${p.cap||\'\'}
' new1 = '
${plateImg(p.art)}
${p.cap||\'\'}
' assert old1 in s, "render site 1 not found" s = s.replace(old1, new1) old2 = '
${ART[r.art]||\'\'}

${r.n}

' new2 = '
${plateImg(r.art)}

${r.n}

' assert old2 in s, "render site 2 not found" s = s.replace(old2, new2) # 2. inject the script (PHOTOS/WANOTES/plateImg) + CSS before the first that has the render, or just append before a known anchor # Inject right after the ART definition script block ends. Find a safe anchor: the first '' after 'const ART={}' # Simpler: append to EOF (global scope scripts execute in order; render happens on demand later) s = s.rstrip() + '\n' + INJECT + '\n' + CSS + '\n' open(p, 'w').write(s) print(f"integrated {len(PHOTOS)} photos + {len(WANOTES)} WA notes; size {len(s)}")