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

Function process_standard

scripts/fetch_standards_overview.py:141–174  ·  view source on GitHub ↗
(entry: dict)

Source from the content-addressed store, hash-verified

139
140
141def process_standard(entry: dict) -> bool:
142 entry_id = entry["id"]
143 title = entry["title"]["en"]
144 source_url = entry["source_url"]
145 safe_id = re.sub(r'[^\w\-.]', '_', entry_id)
146 output_path = FULLTEXT_DIR / f"{safe_id}.md"
147
148 print(f" Fetching: {title}")
149
150 try:
151 md = fetch_and_convert(source_url)
152 except Exception as e:
153 print(f" ERROR: {e}")
154 return False
155
156 if "iso.org" in source_url:
157 content = extract_iso_content(md, title, source_url)
158 elif "iec.ch" in source_url:
159 content = extract_iec_content(md, title, source_url)
160 else:
161 print(f" SKIP: unknown domain")
162 return False
163
164 if not content or len(content) < 100:
165 print(f" WARNING: insufficient content ({len(content)} chars)")
166 return False
167
168 result = f"# {title}\n\n"
169 result += f"**Source:** [{source_url}]({source_url})\n\n---\n\n"
170 result += content + "\n"
171
172 output_path.write_text(result, encoding="utf-8")
173 print(f" OK: {output_path.name} ({len(content)} chars)")
174 return True
175
176
177def main():

Callers 1

mainFunction · 0.85

Calls 3

fetch_and_convertFunction · 0.85
extract_iso_contentFunction · 0.85
extract_iec_contentFunction · 0.85

Tested by

no test coverage detected