Resolve a manpage source path to an external URL, or None.
(source)
| 384 | |
| 385 | |
| 386 | def manpage_url(source): |
| 387 | """Resolve a manpage source path to an external URL, or None.""" |
| 388 | parts = source.split("/") |
| 389 | section_dir = parts[-2] # e.g. "1" from "ubuntu/26.04/1/cat.1posix.gz" |
| 390 | basename = parts[-1] |
| 391 | name_with_section = basename[:-3] # remove .gz |
| 392 | name, section = name_with_section.rsplit(".", 1) |
| 393 | |
| 394 | best_match = None |
| 395 | best_len = 0 |
| 396 | for prefix, template in config.MANPAGE_URLS.items(): |
| 397 | if source.startswith(prefix + "/") and len(prefix) > best_len: |
| 398 | best_match = template |
| 399 | best_len = len(prefix) |
| 400 | |
| 401 | if best_match: |
| 402 | return best_match.format(section=section, section_dir=section_dir, name=name) |
| 403 | return None |
| 404 | |
| 405 | |
| 406 | def explain_program(program, store, distro=None, release=None): |
no outgoing calls