MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / extract_iso_content

Function extract_iso_content

scripts/fetch_standards_overview.py:35–72  ·  view source on GitHub ↗
(md: str, title: str, url: str)

Source from the content-addressed store, hash-verified

33
34
35def extract_iso_content(md: str, title: str, url: str) -> str:
36 sections = []
37
38 for pat in [r'#+\s*What is [^\n]+\n(.*?)(?=\n#+\s)', r'### What is [^\n]+\n(.*?)(?=\n##)']:
39 m = re.search(pat, md, re.DOTALL)
40 if m:
41 text = _clean(m.group(1))
42 if text:
43 sections.append(f"## Overview\n\n{text}")
44 break
45
46 for pat in [r'#+\s*Why is [^\n]+\n(.*?)(?=\n#+\s)', r'### Why is [^\n]+\n(.*?)(?=\n##)']:
47 m = re.search(pat, md, re.DOTALL)
48 if m:
49 text = _clean(m.group(1))
50 if text:
51 sections.append(f"## Importance\n\n{text}")
52 break
53
54 m = re.search(r'#+\s*Benefits[^\n]*\n(.*?)(?=\n#+\s*(?:FAQ|Buy|General))', md, re.DOTALL)
55 if m:
56 text = _clean(m.group(1))
57 if text:
58 sections.append(f"## Benefits\n\n{text}")
59
60 m = re.search(r'#+\s*FAQ\s*\n(.*?)(?=\n#+\s*(?:Buy|General))', md, re.DOTALL)
61 if m:
62 text = _clean(m.group(1))
63 if text:
64 sections.append(f"## FAQ\n\n{text}")
65
66 m = re.search(r'#+\s*General information\s*\n(.*?)(?=\n#+\s*Life cycle)', md, re.DOTALL)
67 if m:
68 text = _extract_general_info(m.group(1))
69 if text:
70 sections.append(f"## General Information\n\n{text}")
71
72 return "\n\n".join(sections)
73
74
75def extract_iec_content(md: str, title: str, url: str) -> str:

Callers 1

process_standardFunction · 0.85

Calls 3

_cleanFunction · 0.85
_extract_general_infoFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected