Yield lines of TOML extracted from an iterable of text ``lines``. The lines are expected to be from a RustSec Markdown advisory file with embedded TOML metadata. For example:: >>> text = ''' ... ```toml ... [advisory] ... id = "RUST-001" ... ... [versions]
(lines)
| 180 | |
| 181 | |
| 182 | def get_toml_lines(lines): |
| 183 | """ |
| 184 | Yield lines of TOML extracted from an iterable of text ``lines``. |
| 185 | The lines are expected to be from a RustSec Markdown advisory file with |
| 186 | embedded TOML metadata. |
| 187 | |
| 188 | For example:: |
| 189 | |
| 190 | >>> text = ''' |
| 191 | ... ```toml |
| 192 | ... [advisory] |
| 193 | ... id = "RUST-001" |
| 194 | ... |
| 195 | ... [versions] |
| 196 | ... patch = [">= 1.2.1"] |
| 197 | ... ``` |
| 198 | ... # Use-after-free with objects returned by `Stream`'s `get_format_info` |
| 199 | ... |
| 200 | ... Affected versions contained a pair of use-after-free issues with the objects. |
| 201 | ... ''' |
| 202 | >>> list(get_toml_lines(text.splitlines())) |
| 203 | ['', '[advisory]', 'id = "RUST-001"', '', '[versions]', 'patch = [">= 1.2.1"]'] |
| 204 | """ |
| 205 | |
| 206 | for line in lines: |
| 207 | line = line.strip() |
| 208 | if line.startswith("```toml"): |
| 209 | continue |
| 210 | elif line.endswith("```"): |
| 211 | break |
| 212 | else: |
| 213 | yield line |
| 214 | |
| 215 | |
| 216 | def data_from_toml_lines(lines): |