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

Function check_iec

scripts/check_standards_versions.py:143–197  ·  view source on GitHub ↗

Check IEC webstore page for newer version signal. IEC webstore does NOT mark old publication pages as superseded. Detection strategy: 1. Check for explicit "more recent version" text (rare but possible) 2. Compare page title year against our stored version year 3. Check for

(standard: dict)

Source from the content-addressed store, hash-verified

141
142
143def check_iec(standard: dict) -> dict | None:
144 """Check IEC webstore page for newer version signal.
145
146 IEC webstore does NOT mark old publication pages as superseded.
147 Detection strategy:
148 1. Check for explicit "more recent version" text (rare but possible)
149 2. Compare page title year against our stored version year
150 3. Check for "Withdrawn" status
151 """
152 status, html = fetch_page(standard["url"], max_bytes=15000)
153 if status != 200:
154 return {"type": "error", "detail": f"HTTP {status}"}
155
156 # Signal 1: "A more recent version of this publication exists"
157 if "more recent version" in html.lower():
158 newer_match = re.search(
159 r"more recent version.*?:\s*(IEC[^<\"]+)",
160 html, re.IGNORECASE | re.DOTALL
161 )
162 new_ver = newer_match.group(1).strip() if newer_match else "unknown"
163 link_match = re.search(
164 r'more recent version.*?href="(/en/publication/\d+)"',
165 html, re.IGNORECASE | re.DOTALL
166 )
167 new_url = f"https://webstore.iec.ch{link_match.group(1)}" if link_match else ""
168 return {
169 "type": "newer_version",
170 "signal": f"A more recent version exists: {new_ver}",
171 "new_version": new_ver,
172 "new_url": new_url,
173 }
174
175 # Signal 2: Page title contains a DIFFERENT year than our stored version
176 # e.g. our data says "IEC 60068-2-78:2012" but page title says "IEC 60068-2-78:2025"
177 title_match = re.search(r'<title>([^<]+)</title>', html)
178 if title_match:
179 page_title = title_match.group(1)
180 # Extract year from page title
181 page_year_match = re.search(r':(\d{4})', page_title)
182 our_year_match = re.search(r':(\d{4})', standard["number"])
183 if page_year_match and our_year_match:
184 page_year = int(page_year_match.group(1))
185 our_year = int(our_year_match.group(1))
186 if page_year > our_year:
187 return {
188 "type": "newer_version",
189 "signal": f"Page shows {page_title.strip()} but we have {standard['number']}",
190 "new_version": page_title.strip().replace(" | IEC", ""),
191 }
192
193 # Signal 3: "Withdrawn" status
194 if re.search(r"status.*?withdrawn", html, re.IGNORECASE):
195 return {"type": "withdrawn", "signal": "Status: Withdrawn"}
196
197 return None
198
199
200def check_astm(standard: dict) -> dict | None:

Callers

nothing calls this directly

Calls 2

fetch_pageFunction · 0.85
searchMethod · 0.45

Tested by

no test coverage detected