49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
|
|
from .lineage_model import CodexEntry, SegmentLineage
|
||
|
|
|
||
|
|
|
||
|
|
def summarize_lineage(entry: CodexEntry) -> str:
|
||
|
|
lines = []
|
||
|
|
|
||
|
|
lines.append("=" * 70)
|
||
|
|
lines.append("CODEX LINEAGE REPORT")
|
||
|
|
lines.append("=" * 70)
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
lines.append("[Source Information]")
|
||
|
|
lines.append(f" File: {entry.source_file}")
|
||
|
|
lines.append(f" Type: {entry.source_type}")
|
||
|
|
lines.append(f" Version: {entry.version}")
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
lines.append("[Epoch]")
|
||
|
|
lines.append(f" Major: v{entry.epoch.major}")
|
||
|
|
if entry.epoch.minor > 0:
|
||
|
|
lines.append(f" Minor: {entry.epoch.minor}")
|
||
|
|
lines.append(f" Stability: {entry.epoch.stability}")
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
lines.append("[Contributor]")
|
||
|
|
lines.append(f" Name: {entry.contributor.name}")
|
||
|
|
lines.append(f" Contributions: {entry.contributor.contribution_count}")
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
lines.append("[Segments]")
|
||
|
|
lines.append(f" Total: {len(entry.segments)}")
|
||
|
|
for seg in entry.segments:
|
||
|
|
lines.append(f" - {describe_segment(seg)}")
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
if entry.timestamp:
|
||
|
|
lines.append("[Metadata]")
|
||
|
|
lines.append(f" Timestamp: {entry.timestamp}")
|
||
|
|
lines.append("")
|
||
|
|
|
||
|
|
lines.append(f"Origin: {entry.origin}")
|
||
|
|
lines.append("=" * 70)
|
||
|
|
|
||
|
|
return "\n".join(lines)
|
||
|
|
|
||
|
|
|
||
|
|
def describe_segment(segment: SegmentLineage) -> str:
|
||
|
|
return f"{segment.segment_id}: lines {segment.start_line}-{segment.end_line} ({segment.start_byte}-{segment.end_byte} bytes)"
|