File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9191 rb'<details[^>]*id="v\d+"[^>]*>.*?</details>' ,
9292 re .DOTALL ,
9393)
94- VERSION_NUMBER_PATTERN = re .compile (rb"<summary>\s*([0-9.]+)" )
94+ VERSION_NUMBER_PATTERN = re .compile (
95+ rb"<summary>.*?([0-9]+(?:\.[0-9]+)+)" ,
96+ re .DOTALL ,
97+ )
9598VERSION_DATE_PATTERN = re .compile (rb'href="#v\d+"\s+title="([^"]+)"' )
99+ VERSION_DOWNLOADS_PATTERN = re .compile (
100+ rb'<i\s+class="i-download"[^>]*></i>\s*([\d,]+)' ,
101+ )
96102VERSION_STATUS_PATTERN = re .compile (
97103 rb"<dt>\s*Status\s*</dt>.*?<span[^>]*title=\"([^\"]+)\"" ,
98104 re .DOTALL ,
@@ -400,7 +406,9 @@ def parse_version_events(body: bytes) -> list[VersionEvent]:
400406 details = details_match .group (0 )
401407 version_match = VERSION_NUMBER_PATTERN .search (details )
402408 date_match = VERSION_DATE_PATTERN .search (details )
403- downloads_match = DOWNLOADS_PATTERN .search (details )
409+ downloads_match = VERSION_DOWNLOADS_PATTERN .search (details )
410+ if downloads_match is None :
411+ downloads_match = DOWNLOADS_PATTERN .search (details )
404412 if version_match is None or date_match is None or downloads_match is None :
405413 msg = "version card markup did not contain version, date, and downloads"
406414 raise RuntimeError (msg )
Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ def test_parse_version_events() -> None:
152152 html = b"""
153153 <details open id="v0162">
154154 <summary>
155- 0.16.2
155+ <span class="version-string">0.16.2</span>
156+ <li class="show-on-collapse"><i class="i-download"></i> 1,828</li>
156157 <a href="#v0162" title="Saturday 23rd, May 2026 - 15:22">
157158 May 23rd, 2026
158159 </a>
@@ -166,9 +167,6 @@ def test_parse_version_events() -> None:
166167 <li><i class="i-macos"></i> macOS <span>Apple Silicon</span></li>
167168 <li><i class="i-windows"></i> Windows</li>
168169 <li><i class="i-linux"></i> Linux</li>
169- <div class="dl-row">
170- <div class="dl-col"><dt>Downloads</dt><dd>1,828</dd></div>
171- </div>
172170 <div class="dl-row">
173171 <div class="dl-col">
174172 <dt>Status</dt><dd><span title="Approved"></span></dd>
You can’t perform that action at this time.
0 commit comments