- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
from src.manifest_manager import ManifestManager, ManifestItem
|
|
|
|
# 模拟 worker 更新流程
|
|
manifest = ManifestManager("test_manifest.json")
|
|
manifest.init_manifest("test", {})
|
|
|
|
# 添加一个 item
|
|
item = manifest.add_item("test.html", "<p>Hello</p>", "Hello", "p")
|
|
print(f"After add: item.status = {item.status}, item.translation = {item.translation}")
|
|
print(f"ID in manifest: {item.global_id}")
|
|
|
|
# 模拟 get_items 获取的是同一个对象吗?
|
|
pending = manifest.get_items(status="pending")
|
|
print(f"pending[0] is item: {pending[0] is item}")
|
|
|
|
# 模拟 worker 更新
|
|
manifest.update_item(item.global_id, "你好", translation_with_placeholders="你好", status="translated")
|
|
|
|
# 检查更新是否生效
|
|
print(f"After update: item.status = {item.status}, item.translation = {item.translation}")
|
|
print(f"After update: item.translation_with_placeholders = '{item.translation_with_placeholders}'")
|
|
|
|
# 验证 get_items 能获取到更新后的状态
|
|
translated = manifest.get_items(status="translated")
|
|
print(f"Translated items count: {len(translated)}")
|
|
if translated:
|
|
print(f"translated[0].translation_with_placeholders = '{translated[0].translation_with_placeholders}'")
|
|
|
|
import os
|
|
if os.path.exists("test_manifest.json"):
|
|
os.remove("test_manifest.json")
|