Integrate corrected char expressions into Liam code36

This commit is contained in:
zenord
2026-10-14 20:46:10 +08:00
parent 0c386ac8ec
commit 99a03e0487
23 changed files with 607 additions and 59 deletions
+16 -6
View File
@@ -38,16 +38,25 @@ def catalog():
return data
def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mouth=False, startup=False):
def authorized_debug_sha(pin):
return any(row.get('userAuthorizedDebug') is True and row['indexSha256']==pin
for row in catalog()['mediaBundles'].values())
def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mouth=False, startup=False, media_bundle=None):
data = catalog()
require(profile in data['profiles'], 'unknown character profile')
role = data['profiles'][profile]
bundle_id = ('black-correct03' if user_assets else 'white-full04') if emotion_sha else None
require(role['mediaSelection'] == 'existing-build-flags' or
role['mediaSelection'] == bundle_id and mouth and startup, 'profile/media flags mismatch')
require(not media_bundle or emotion_sha, 'explicit media needs an exact pin')
bundle_id = (media_bundle or ('black-correct03' if user_assets else 'white-full04')) if emotion_sha else None
require(bundle_id is None or bundle_id in data['mediaBundles'], 'unknown media bundle')
allowed = [role['mediaSelection'], *role.get('additionalMediaSelections', [])]
require((role['mediaSelection'] == 'existing-build-flags' and bundle_id in (None,'black-correct03','white-full04')) or
bundle_id in allowed and mouth and startup, 'profile/media flags mismatch')
bundle = data['mediaBundles'][bundle_id] if bundle_id else None
if bundle:
require(emotion_sha == bundle['indexSha256'], 'selected exact index mismatch')
require(user_assets == bundle.get('userAuthorizedDebug',False), 'media authorization mode mismatch')
assets = Path(assets).resolve(strict=True)
files = {}
@@ -111,7 +120,7 @@ def selection(assets, profile='main', *, emotion_sha='', user_assets=False, mout
require(boot['sourceIndexSha256'] == emotion_sha and boot['body']['path'] in files and
files[boot['body']['path']]['sha256'] == boot['body']['sha256'], 'bootstrap/index/body mismatch')
poster = add(boot_root + 'poster.png', boot['posterSha256'])
resource = ROOT / 'app/src/main/res/drawable-nodpi' / (bundle['posterResource'] + '.png')
resource = ROOT / bundle.get('resourceDirectory','app/src/main/res') / 'drawable-nodpi' / (bundle['posterResource'] + '.png')
require(resource.read_bytes() == poster, 'drawable/bootstrap poster mismatch')
return {'schemaVersion': 1, 'profile': profile, 'application_id': role['applicationId'],
'persona': role['persona'], 'media_bundle': bundle_id, 'media_identity': bundle['identityId'] if bundle else 'a01',
@@ -143,13 +152,14 @@ def main():
p.add_argument('--profile', choices=sorted(catalog()['profiles']), required=True)
p.add_argument('--assets', type=Path, default=ROOT / 'app/src/main/assets')
p.add_argument('--emotion-sha', default='')
p.add_argument('--media-bundle', default='')
for flag in ('user-assets', 'mouth', 'startup'):
p.add_argument('--' + flag, choices=['true', 'false'], default='false')
p.add_argument('--output', type=Path)
p.add_argument('--report', type=Path)
a = p.parse_args()
result = selection(a.assets, a.profile, emotion_sha=a.emotion_sha, user_assets=a.user_assets == 'true',
mouth=a.mouth == 'true', startup=a.startup == 'true')
mouth=a.mouth == 'true', startup=a.startup == 'true', media_bundle=a.media_bundle or None)
if a.output:
stage(a.assets, a.output, result)
if a.report: