Add Chinese covers and source-bound library edition metadata
This commit is contained in:
@@ -74,6 +74,10 @@ async def run(args):
|
||||
'total': len(entries), 'pending_batches': len(batches), 'batch_files': [f'{i:04d}.json' for i in range(len(batches))]})
|
||||
print(f'Prepared {len(entries)} complete-book units; {len(batches)} pending batches; {work}')
|
||||
return
|
||||
if args.action == 'build' and getattr(args, 'edition_config', None):
|
||||
from src.edition.localize import validate_config_assets
|
||||
for mode in ('target_only', 'bilingual'):
|
||||
validate_config_assets(args.source, args.edition_config, mode)
|
||||
structure = verify_source(args.source, work)
|
||||
metadata = json.loads((work/'agent-run.json').read_text())
|
||||
if metadata['model'] != args.model:
|
||||
@@ -114,7 +118,10 @@ async def run(args):
|
||||
for mode, prefix in [('target_only', 'translated_'), ('bilingual', 'bilingual_')]:
|
||||
copy = structure.model_copy(deep=True)
|
||||
await BackfillEngine().backfill(copy, entries, mode=mode)
|
||||
BilingualBuilder(work, args.source).build(copy, output/(prefix+args.source.name))
|
||||
built = BilingualBuilder(work, args.source).build(copy, output/(prefix+args.source.name))
|
||||
if getattr(args, 'edition_config', None):
|
||||
from src.edition.localize import localize_from_config
|
||||
localize_from_config(built, args.edition_config, mode)
|
||||
save(work/'translation-provenance.json', {'model': args.model, 'source_sha256': structure.source_sha256,
|
||||
'total': len(entries), 'accepted': len(entries), 'provider': 'agent-authored manifest'})
|
||||
print(f'Built both full-book modes: {len(entries)}/{len(entries)}; {output}')
|
||||
@@ -124,6 +131,7 @@ def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('action', choices=['prepare', 'apply', 'build']); parser.add_argument('source', type=Path)
|
||||
parser.add_argument('--work', required=True, type=Path); parser.add_argument('--result', type=Path)
|
||||
parser.add_argument('--edition-config', type=Path)
|
||||
parser.add_argument('--glossary', type=Path); parser.add_argument('--output-dir', type=Path)
|
||||
parser.add_argument('--model', default='agent/luna'); parser.add_argument('--batch-chars', type=int, default=16000)
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Prepare a cover-generation job, then package a reviewed image and Chinese metadata."""
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from src.edition.localize import prepare, localize, audit_edition
|
||||
from src.qa.headless import audit_pair
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('action', choices=['prepare', 'apply'])
|
||||
parser.add_argument('input', type=Path)
|
||||
parser.add_argument('--config', required=True, type=Path)
|
||||
parser.add_argument('--mode', required=True, choices=['target_only', 'bilingual'])
|
||||
parser.add_argument('--work', type=Path, default=Path('.work/edition'))
|
||||
parser.add_argument('--output', type=Path)
|
||||
parser.add_argument('--cover', type=Path)
|
||||
parser.add_argument('--review', type=Path)
|
||||
args = parser.parse_args()
|
||||
if args.action == 'prepare':
|
||||
print(json.dumps(prepare(args.input, args.config, args.mode, args.work), ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
if not all([args.output, args.cover, args.review]):
|
||||
parser.error('apply needs --output, --cover and --review')
|
||||
record = localize(args.input, args.output, args.config, args.mode, args.cover, args.review)
|
||||
report, _, _ = audit_pair(args.input, args.output)
|
||||
report['edition'] = audit_edition(args.output)
|
||||
args.work.mkdir(parents=True, exist_ok=True)
|
||||
(args.work/'edition-qa.json').write_text(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
print(json.dumps({'output': str(args.output), 'title': record['title'], 'issues': report['new_issues']}, ensure_ascii=False))
|
||||
return 1 if report['new_issues'] else 0
|
||||
|
||||
if __name__ == '__main__': sys.exit(main())
|
||||
Reference in New Issue
Block a user