拆分报告渲染函数的第一阶段,把 34 个无外层依赖的辅助函数搬到 report_render。
同一份真实盘包在屏蔽与不屏蔽 PyJHora 下新旧渲染 sha 都一致,各 24 项且退出码 0。指定 pytest 233 通过、3 跳过。 Co-Authored-By: Grok (agent loop)
This commit is contained in:
co-authored by
Grok (agent loop)
parent
32b238cf86
commit
dbba127e71
@@ -0,0 +1,49 @@
|
||||
"""Helpers moved unchanged out of render_pl9_markdown (phase 1)."""
|
||||
|
||||
def _unwrap(raw_value):
|
||||
# 兼容 packet 字段的 response_envelope 升级:
|
||||
# 真实数据可能直接是 list/dict,也可能被包成 {"result": ..., "response_envelope": {...}}。
|
||||
if (
|
||||
isinstance(raw_value, dict)
|
||||
and 'result' in raw_value
|
||||
and 'response_envelope' in raw_value
|
||||
):
|
||||
return raw_value.get('result')
|
||||
return raw_value
|
||||
|
||||
def _envelope_list(raw_value):
|
||||
raw_value = _unwrap(raw_value)
|
||||
if isinstance(raw_value, list):
|
||||
return raw_value
|
||||
if isinstance(raw_value, tuple):
|
||||
return list(raw_value)
|
||||
# 期望 list 时,即使只有 result 键也解包,避免 nested planets 被空渲染成 '-'。
|
||||
if isinstance(raw_value, dict) and 'result' in raw_value:
|
||||
nested = raw_value.get('result')
|
||||
if isinstance(nested, list):
|
||||
return nested
|
||||
if isinstance(nested, tuple):
|
||||
return list(nested)
|
||||
return []
|
||||
|
||||
def _envelope_dict(raw_value):
|
||||
raw_value = _unwrap(raw_value)
|
||||
return raw_value if isinstance(raw_value, dict) else {}
|
||||
|
||||
def _bool_text(value):
|
||||
return '是' if value else '否'
|
||||
|
||||
def _source_dict(*candidates):
|
||||
for candidate in candidates:
|
||||
if isinstance(candidate, dict) and candidate:
|
||||
return candidate
|
||||
return {}
|
||||
|
||||
def _has_executed_payload(value) -> bool:
|
||||
if value in (None, '', [], {}):
|
||||
return False
|
||||
if isinstance(value, dict):
|
||||
status = str(value.get('status') or value.get('execution_status') or '').strip().lower()
|
||||
if status in {'blocked', 'missing', 'not_found', 'parameter_sensitive'}:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user