# D2 + licence badges: Founding Member kept, main licence badge (premium), secondary ratings/instructor (existing .tag style) import re h=open('d2.html').read() old='FOUNDING MEMBERCPL(A)NightFIRGrade III Instructor' assert old in h new=('FOUNDING MEMBER' '' 'CPL (A)' '' 'Night ratingInstrument ratingGrade 3 InstructorGrade 2 Instructor') h=h.replace(old,new) css=''' /* No Logbook yet: hide hours and currency */\n.pass:has(>.ph>span:first-child:is(.x,*)):has(.strp),section.card:has(>h2:first-child):is(.hide-nolog){display:none!important}\n.bdg-brk{flex-basis:100%;height:0} .tag.lic-main{padding:5px 12px 5px 9px;font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:#fff; background:linear-gradient(135deg,color-mix(in srgb,var(--acc) 70%,#fff) 0%,var(--acc) 45%,color-mix(in srgb,var(--acc) 70%,#000) 100%); box-shadow:inset 0 1px 0 rgba(255,255,255,.45),inset 0 0 0 .5px rgba(255,255,255,.25),0 6px 16px -6px color-mix(in srgb,var(--acc) 70%,transparent);position:relative;overflow:hidden} .tag.lic-main svg{width:13px;height:13px;fill:currentColor} .tag.lic-main::after{content:"";position:absolute;inset:0;background:linear-gradient(120deg,transparent 35%,rgba(255,255,255,.35) 50%,transparent 65%);background-size:250% 100%;animation:sheen 6s ease-in-out infinite} ''' h=h.replace('',css+'',1) js='' h=h.replace('',js+'') h=re.sub(r'.*?','Pilot profile - D2 with licence badges',h) import re as _r for t in ('Hours','Currency detail'): h,n=_r.subn(r'
(\s*

'+t+')',r'
\2',h);assert n==1,t # v3: actions on the pass, no badges grid, 5 saved slots, trimmed privacy EDIT='' SHARE='' a='Grade 2 Instructor' assert a in h h=h.replace(a,a+'
'+EDIT+SHARE+'
',1) h,n=_r.subn(r'
.*?Share card
','',h,count=1,flags=_r.S);assert n==1 h,n=_r.subn(r'
\s*

Badges

.*?
','',h,count=1,flags=_r.S);assert n==1 SV=[('FACT','Cape Town Intl','Home'),('FASH','Stellenbosch','Saved'),('FAGG','George','Saved'),('FAOH','Oudtshoorn','Saved')] sv=''.join(f'
{i} {n}{t}
' for i,n,t in SV) sv+='
+ Add an aerodromeSlot 5
' h,n=_r.subn(r'(
\s*

Saved)

.*?
',lambda m:m.group(1)+' 4 / 5

'+sv+'
',h,count=1,flags=_r.S);assert n==1 for t in ['Show total hours','Show currency and medical']: h,n=_r.subn(r'
'+t+r'
\n?','',h);assert n==1,t h=h.replace('','''.pact{display:flex;gap:8px;margin-top:14px;padding-top:12px;border-top:.5px dashed var(--ln)} .pbtn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border-radius:999px;border:0;font-family:inherit;font-weight:600;font-size:12.5px;color:var(--tx);background:var(--gl2);box-shadow:inset 0 0 0 .5px var(--ln),inset 0 1px 0 var(--hl);cursor:pointer} .pbtn svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round} .pbtn.pri{color:#fff;background:var(--acc);box-shadow:0 4px 12px -4px color-mix(in srgb,var(--acc) 70%,transparent)} .chip.empty{opacity:.7;background:transparent;border:1px dashed var(--ln)} ''',1) # v4: licence badge plain (no sheen, no plane icon), edit sheet (?sheet=edit) h=_r.sub(r'()',r'\1',h) h=h.replace('','''.tag.lic-main::after{content:none!important;animation:none!important}.tag.lic-main{padding:5px 12px!important} .shv{position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:50;display:none;align-items:flex-end}.shv.on{display:flex} .sheet{width:100%;box-sizing:border-box;border-radius:24px 24px 0 0;padding:10px 20px 34px;background:var(--bg2,var(--gl2));backdrop-filter:blur(30px);-webkit-backdrop-filter:blur(30px);box-shadow:0 -10px 40px rgba(0,0,0,.25),inset 0 .5px 0 var(--hl);color:var(--tx)} .sheet .grab{width:38px;height:5px;border-radius:3px;background:var(--ln);margin:0 auto 14px} .sheet .top{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.sheet .top b{font-size:17px} .sheet .lnk{background:none;border:0;font:inherit;font-size:16px;color:var(--tx2)}.sheet .lnk.sv{color:var(--acc);font-weight:700} .fld{margin-bottom:16px}.fld label{display:block;font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--tx3);margin-bottom:6px} .fld .in{height:46px;border-radius:14px;padding:0 14px;display:flex;align-items:center;justify-content:space-between;font-size:16px;background:var(--gl2);box-shadow:inset 0 0 0 .5px var(--ln)} .fld .in.focus{box-shadow:inset 0 0 0 1.5px var(--acc)} .fld .in.lock{opacity:.55}.fld .hint{font-size:12px;color:var(--tx3);margin-top:6px} .fld .in svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8} ''',1) SHEET='''
Edit profile
MT
Shown on your pass and share card.
@capecpl_mt
Your handle cannot be changed.
''' h=h.replace('',SHEET+'',1) open('d2badges.html','w').write(h);print('ok')