Take a route and return a list of tuple for use in breadcrumb. Args: route: The route to transform. Returns: list[tuple[str, str]]: the list of tuples for the breadcrumb.
(route: str)
| 601 | |
| 602 | |
| 603 | def format_breadcrumbs(route: str) -> list[tuple[str, str]]: |
| 604 | """Take a route and return a list of tuple for use in breadcrumb. |
| 605 | |
| 606 | Args: |
| 607 | route: The route to transform. |
| 608 | |
| 609 | Returns: |
| 610 | list[tuple[str, str]]: the list of tuples for the breadcrumb. |
| 611 | """ |
| 612 | route_parts = route.lstrip("/").split("/") |
| 613 | |
| 614 | # create and return breadcrumbs |
| 615 | return [ |
| 616 | (part, "/".join(["", *route_parts[: i + 1]])) |
| 617 | for i, part in enumerate(route_parts) |
| 618 | ] |
| 619 | |
| 620 | |
| 621 | def format_library_name(library_fullname: str): |