MCPcopy
hub / github.com/qazbnm456/awesome-web-security / parse_entries

Function parse_entries

scripts/ci/archive.py:66–92  ·  view source on GitHub ↗

Return list of dicts: each has line ranges for in-place edit.

(path: Path)

Source from the content-addressed store, hash-verified

64
65
66def parse_entries(path: Path) -> list[dict]:
67 """Return list of dicts: each has line ranges for in-place edit."""
68 text = path.read_text(encoding="utf-8")
69 lines = text.split("\n")
70 entries: list[dict] = []
71 current: dict | None = None
72 for idx, line in enumerate(lines):
73 if line.startswith(" - id:"):
74 if current is not None:
75 current["end_line"] = idx - 1
76 entries.append(current)
77 m = ENTRY_START_RE.match(line)
78 current = {"start_line": idx, "fields": {}, "field_lines": {}, "raw": lines}
79 current["fields"]["id"] = m.group(1).strip()
80 current["field_lines"]["id"] = idx
81 continue
82 if current is None:
83 continue
84 m = FIELD_RE.match(line)
85 if m:
86 key, val = m.group(1), m.group(2)
87 current["fields"][key] = yaml_decode(val)
88 current["field_lines"][key] = idx
89 if current is not None:
90 current["end_line"] = len(lines) - 1
91 entries.append(current)
92 return entries
93
94
95def write_archive_url(path: Path, entry: dict, archive_url: str) -> None:

Callers 3

load_entry_indexFunction · 0.90
write_statusFunction · 0.90
mainFunction · 0.85

Calls 1

yaml_decodeFunction · 0.85

Tested by

no test coverage detected