|
585 | 585 | { |
586 | 586 | "data": { |
587 | 587 | "text/plain": [ |
588 | | - "[BranchInfo(name='github_url_arg', last_commit=Commit(sha='59ade5b5268686e0360978000502ff3c63b39623', date='2025-12-05T17:34:35Z')),\n", |
| 588 | + "[BranchInfo(name='github_url_arg', last_commit=Commit(sha='875eafb3fb6de757b22a121dcd56ab0c2ffda676', date='2025-12-05T18:36:16Z')),\n", |
589 | 589 | " BranchInfo(name='main', last_commit=Commit(sha='6c84dcbfa0f637bf8b30a9ab37062fe36737985a', date='2025-11-30T09:46:33Z'))]" |
590 | 590 | ] |
591 | 591 | }, |
|
772 | 772 | "\n", |
773 | 773 | "pprint(pulls)" |
774 | 774 | ] |
| 775 | + }, |
| 776 | + { |
| 777 | + "cell_type": "markdown", |
| 778 | + "id": "1f7e1df9", |
| 779 | + "metadata": {}, |
| 780 | + "source": [ |
| 781 | + "### Использование асинхронного GitHub парсера" |
| 782 | + ] |
| 783 | + }, |
| 784 | + { |
| 785 | + "cell_type": "code", |
| 786 | + "execution_count": 24, |
| 787 | + "id": "d8de0bfc", |
| 788 | + "metadata": {}, |
| 789 | + "outputs": [ |
| 790 | + { |
| 791 | + "name": "stdout", |
| 792 | + "output_type": "stream", |
| 793 | + "text": [ |
| 794 | + "'https://github.com/OSLL/code-plagiarism/blob/main/LICENSE'\n", |
| 795 | + "'https://github.com/OSLL/code-plagiarism/tree/main/rc/webparsers/__init__.py'\n", |
| 796 | + "'https://github.com/OSLL/code-plagiarism/tree/main/rc/webparsers/async_github_parser.py'\n", |
| 797 | + "'https://github.com/OSLL/code-plagiarism/tree/main/rc/webparsers/github_parser.py'\n", |
| 798 | + "'https://github.com/OSLL/code-plagiarism/tree/main/rc/webparsers/types.py'\n" |
| 799 | + ] |
| 800 | + } |
| 801 | + ], |
| 802 | + "source": [ |
| 803 | + "import asyncio\n", |
| 804 | + "import aiohttp\n", |
| 805 | + "\n", |
| 806 | + "from webparsers.async_github_parser import AsyncGithubParser\n", |
| 807 | + "\n", |
| 808 | + "\n", |
| 809 | + "async def handle_link(gh_parser: AsyncGithubParser, link: str):\n", |
| 810 | + " async for work_info in gh_parser.get_files_generator_from_url(link):\n", |
| 811 | + " pprint(work_info.link)\n", |
| 812 | + "\n", |
| 813 | + "\n", |
| 814 | + "async def main():\n", |
| 815 | + " timeout = aiohttp.ClientTimeout(total=5)\n", |
| 816 | + " async with aiohttp.ClientSession(timeout=timeout) as session:\n", |
| 817 | + " gh_parser = AsyncGithubParser(session, token=env_config.get(\"ACCESS_TOKEN\"))\n", |
| 818 | + " tasks = []\n", |
| 819 | + " for link in [\n", |
| 820 | + " \"https://github.com/OSLL/code-plagiarism/tree/main/src/webparsers\",\n", |
| 821 | + " \"https://github.com/OSLL/code-plagiarism/blob/main/LICENSE\"\n", |
| 822 | + " ]:\n", |
| 823 | + " tasks.append(handle_link(gh_parser, link))\n", |
| 824 | + " await asyncio.gather(*tasks)\n", |
| 825 | + "\n", |
| 826 | + "\n", |
| 827 | + "await main()" |
| 828 | + ] |
775 | 829 | } |
776 | 830 | ], |
777 | 831 | "metadata": { |
|
0 commit comments