Split a Scholar author line into coauthor names.
(author_line: str, scholar_name: str = "")
| 657 | |
| 658 | |
| 659 | def _build_scholar_profile_url( |
| 660 | scholar_url: str, |
| 661 | *, |
| 662 | cstart: int = 0, |
| 663 | pagesize: Optional[int] = None, |
| 664 | hl: str = "en", |
| 665 | ) -> str: |
| 666 | """Normalize a Scholar profile URL and request a larger publication page size.""" |
| 667 | candidate = _collapse_whitespace(scholar_url) |
| 668 | if not candidate: |
| 669 | raise ValueError("empty scholar url") |
| 670 | if "://" not in candidate: |
| 671 | candidate = f"https://{candidate.lstrip('/')}" |
| 672 | |
| 673 | parsed = urlsplit(candidate) |
| 674 | if not parsed.netloc: |
| 675 | raise ValueError("invalid scholar url") |
| 676 | |
| 677 | query = dict(parse_qsl(parsed.query, keep_blank_values=True)) |
| 678 | query["hl"] = hl or query.get("hl") or "en" |
| 679 | query["cstart"] = str(max(0, int(cstart))) |
| 680 | resolved_page_size = pagesize or _get_env_int("PAPERFLOW_SCHOLAR_PAGE_SIZE", 100) |
| 681 | query["pagesize"] = str(max(20, int(resolved_page_size))) |
| 682 | |
| 683 | return urlunsplit( |
| 684 | ( |
| 685 | parsed.scheme or "https", |
| 686 | parsed.netloc, |
| 687 | parsed.path or "/citations", |
| 688 | urlencode(query), |
no test coverage detected