From f4c66943e24336d5d126d3025eb3b2b308a23df1 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 09:40:08 +0200 Subject: [PATCH 01/13] =?UTF-8?q?Utworzono=20za=20pomoc=C4=85=20Colaborato?= =?UTF-8?q?ry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CopyToGitHub.ipynb | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 CopyToGitHub.ipynb diff --git a/CopyToGitHub.ipynb b/CopyToGitHub.ipynb new file mode 100644 index 0000000..c5f9b46 --- /dev/null +++ b/CopyToGitHub.ipynb @@ -0,0 +1,62 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyPHJSVlBiqzKGsES92bvEWZ", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "GbU-9zp544td", + "outputId": "f2219019-2f51-40e0-891b-49f270590a99" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "I was made in colab!\n" + ] + } + ], + "source": [ + "print(\"I was made in colab!\")" + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "4vATIZBg48_E" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file From 9772914c79f9d801af751efe5335d2a6f44bcc59 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 07:57:13 +0000 Subject: [PATCH 02/13] change statements --- statements.ipynb | 330 ++++++++++++++++++++++++----------------------- 1 file changed, 167 insertions(+), 163 deletions(-) diff --git a/statements.ipynb b/statements.ipynb index ed87a09..288e26a 100644 --- a/statements.ipynb +++ b/statements.ipynb @@ -1,27 +1,10 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "statements", - "provenance": [], - "authorship_tag": "ABX9TyNe4+V/u39BRccCO1VGUuCj", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "markdown", "metadata": { - "id": "view-in-github", - "colab_type": "text" + "colab_type": "text", + "id": "view-in-github" }, "source": [ "\"Open" @@ -29,16 +12,16 @@ }, { "cell_type": "markdown", - "source": [ - "## Learning Statements" - ], "metadata": { "id": "l1ahQlB4K7-h" - } + }, + "source": [ + "## Learning Statements" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -48,8 +31,8 @@ }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "hello world\n" ] @@ -61,51 +44,49 @@ }, { "cell_type": "markdown", - "source": [ - "### Variables" - ], "metadata": { "id": "7Wc6DUjLLUFv" - } + }, + "source": [ + "### Variables" + ] }, { "cell_type": "code", - "source": [ - "variable = 1" - ], + "execution_count": 2, "metadata": { "id": "cxJQjiczLGA-" }, - "execution_count": null, - "outputs": [] + "outputs": [], + "source": [ + "variable = 1" + ] }, { "cell_type": "code", - "source": [ - "x = 1" - ], + "execution_count": 3, "metadata": { "id": "xqu3CuI0Laia" }, - "execution_count": 1, - "outputs": [] + "outputs": [], + "source": [ + "x = 1" + ] }, { "cell_type": "code", - "source": [ - "y = 2" - ], + "execution_count": 4, "metadata": { "id": "3e-qtfRzL_0a" }, - "execution_count": 2, - "outputs": [] + "outputs": [], + "source": [ + "y = 2" + ] }, { "cell_type": "code", - "source": [ - "x + y" - ], + "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -113,65 +94,63 @@ "id": "dWpUFe6HMBu5", "outputId": "e19d8a70-812b-4690-e94b-cd31da9720a8" }, - "execution_count": 3, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "3" ] }, + "execution_count": 3, "metadata": {}, - "execution_count": 3 + "output_type": "execute_result" } + ], + "source": [ + "x + y" ] }, { "cell_type": "code", - "source": [ - "" - ], + "execution_count": null, "metadata": { "id": "_Xbv6lnGMEPY" }, - "execution_count": null, - "outputs": [] + "outputs": [], + "source": [] }, { "cell_type": "markdown", - "source": [ - "### Data Structures" - ], "metadata": { "id": "gRPDPm50MQKa" - } + }, + "source": [ + "### Data Structures" + ] }, { "cell_type": "markdown", - "source": [ - "#### Lists" - ], "metadata": { "id": "5HfnwC0lMk1Z" - } + }, + "source": [ + "#### Lists" + ] }, { "cell_type": "code", - "source": [ - "my_list = [1,2,3]" - ], + "execution_count": 5, "metadata": { "id": "0YHo8VCBMSql" }, - "execution_count": 4, - "outputs": [] + "outputs": [], + "source": [ + "my_list = [1,2,3]" + ] }, { "cell_type": "code", - "source": [ - "my_list[0]" - ], + "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -179,25 +158,25 @@ "id": "YTwRFZTdMXk8", "outputId": "3d126b2b-04c5-467f-e750-6e480f640563" }, - "execution_count": 5, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "1" ] }, + "execution_count": 6, "metadata": {}, - "execution_count": 5 + "output_type": "execute_result" } + ], + "source": [ + "my_list[0]" ] }, { "cell_type": "code", - "source": [ - "my_list[1]" - ], + "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -205,25 +184,25 @@ "id": "gyi8180ZMZJD", "outputId": "1a25a34c-3c71-4e5e-ebce-d88726c9f2eb" }, - "execution_count": 6, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "2" ] }, + "execution_count": 6, "metadata": {}, - "execution_count": 6 + "output_type": "execute_result" } + ], + "source": [ + "my_list[1]" ] }, { "cell_type": "code", - "source": [ - "my_list[2]" - ], + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -231,25 +210,25 @@ "id": "9BltrokJMd2D", "outputId": "15ba4e98-cf3d-48ed-e527-f82619aa3ff9" }, - "execution_count": 7, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "3" ] }, + "execution_count": 7, "metadata": {}, - "execution_count": 7 + "output_type": "execute_result" } + ], + "source": [ + "my_list[2]" ] }, { "cell_type": "code", - "source": [ - "type(my_list)" - ], + "execution_count": 10, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -257,157 +236,152 @@ "id": "DqLAzK6TMhJH", "outputId": "3b471454-f6ce-460d-ff70-77d5879a58ae" }, - "execution_count": 10, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "list" ] }, + "execution_count": 10, "metadata": {}, - "execution_count": 10 + "output_type": "execute_result" } + ], + "source": [ + "type(my_list)" ] }, { "cell_type": "markdown", - "source": [ - "#### Dictionary" - ], "metadata": { "id": "qAwuIQg3Mw_6" - } + }, + "source": [ + "#### Dictionary" + ] }, { "cell_type": "code", - "source": [ - "my_dict = {1:\"one\", 2: \"two\"}" - ], + "execution_count": 8, "metadata": { "id": "I4GkDdyuMynO" }, - "execution_count": 8, - "outputs": [] + "outputs": [], + "source": [ + "my_dict = {1:\"one\", 2: \"two\"}" + ] }, { "cell_type": "code", - "source": [ - "type(my_dict)" - ], + "execution_count": 9, "metadata": { - "id": "VoddwxWOM7eM", - "outputId": "2df85560-8851-46a6-ef75-b7d180e3d523", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "VoddwxWOM7eM", + "outputId": "2df85560-8851-46a6-ef75-b7d180e3d523" }, - "execution_count": 9, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "dict" ] }, + "execution_count": 9, "metadata": {}, - "execution_count": 9 + "output_type": "execute_result" } + ], + "source": [ + "type(my_dict)" ] }, { "cell_type": "code", - "source": [ - "my_dict.keys()" - ], + "execution_count": 11, "metadata": { - "id": "dKd4GW6FM_Xh", - "outputId": "a6be43ef-008c-4cab-be2c-cc1d787a1812", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "dKd4GW6FM_Xh", + "outputId": "a6be43ef-008c-4cab-be2c-cc1d787a1812" }, - "execution_count": 11, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "dict_keys([1, 2])" ] }, + "execution_count": 11, "metadata": {}, - "execution_count": 11 + "output_type": "execute_result" } + ], + "source": [ + "my_dict.keys()" ] }, { "cell_type": "code", - "source": [ - "my_dict.values()" - ], + "execution_count": 12, "metadata": { - "id": "nvXxjY59NGX_", - "outputId": "0b3a1b5e-56b6-48e2-c388-89e341779bb3", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "nvXxjY59NGX_", + "outputId": "0b3a1b5e-56b6-48e2-c388-89e341779bb3" }, - "execution_count": 12, "outputs": [ { - "output_type": "execute_result", "data": { "text/plain": [ "dict_values(['one', 'two'])" ] }, + "execution_count": 12, "metadata": {}, - "execution_count": 12 + "output_type": "execute_result" } + ], + "source": [ + "my_dict.values()" ] }, { "cell_type": "code", - "source": [ - "" - ], + "execution_count": null, "metadata": { "id": "SRdOvPg5NJnO" }, - "execution_count": null, - "outputs": [] + "outputs": [], + "source": [] }, { "cell_type": "markdown", - "source": [ - "#### Loops" - ], "metadata": { "id": "LnkEZZY4NP3p" - } + }, + "source": [ + "#### Loops" + ] }, { "cell_type": "code", - "source": [ - "for key,value in my_dict.items():\n", - " print(f\"This is my key: {key}\")\n", - " print(f\"This is my value: {value}\")" - ], + "execution_count": 13, "metadata": { - "id": "ZeEI0C4nNRLs", - "outputId": "ed0cac6f-f087-425a-8034-3dc69564b181", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "ZeEI0C4nNRLs", + "outputId": "ed0cac6f-f087-425a-8034-3dc69564b181" }, - "execution_count": 13, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "This is my key: 1\n", "This is my value: one\n", @@ -415,44 +389,74 @@ "This is my value: two\n" ] } + ], + "source": [ + "for key,value in my_dict.items():\n", + " print(f\"This is my key: {key}\")\n", + " print(f\"This is my value: {value}\")" ] }, { "cell_type": "code", - "source": [ - "for items in my_list:\n", - " print(f\"This is the value in the list: {items}\")" - ], + "execution_count": 14, "metadata": { - "id": "ZoMxJE_sNnkg", - "outputId": "e44c2e9b-db52-495e-cd1b-8f7fcfdd8f56", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "ZoMxJE_sNnkg", + "outputId": "e44c2e9b-db52-495e-cd1b-8f7fcfdd8f56" }, - "execution_count": 14, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "This is the value in the list: 1\n", "This is the value in the list: 2\n", "This is the value in the list: 3\n" ] } + ], + "source": [ + "for items in my_list:\n", + " print(f\"This is the value in the list: {items}\")" ] }, { "cell_type": "code", - "source": [ - "" - ], + "execution_count": null, "metadata": { "id": "Os7DxOI3NzZE" }, - "execution_count": null, - "outputs": [] + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "authorship_tag": "ABX9TyNe4+V/u39BRccCO1VGUuCj", + "include_colab_link": true, + "name": "statements", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.8" } - ] -} \ No newline at end of file + }, + "nbformat": 4, + "nbformat_minor": 0 +} From 0047c6193aef0fcde349bab08bf0349388ee21b7 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:29:34 +0200 Subject: [PATCH 03/13] Create main1.yml --- .github/workflows/main1.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/main1.yml diff --git a/.github/workflows/main1.yml b/.github/workflows/main1.yml new file mode 100644 index 0000000..b3a52e0 --- /dev/null +++ b/.github/workflows/main1.yml @@ -0,0 +1,27 @@ +name: Python application test with Github Actions + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + make install + - name: Lint with pylint + run: | + make lint + - name: Test with pytest + run: | + make test + - name: Format code + run: | + make format From 62bf1a3bad26b7673bb175e98d39e67b53ad51c8 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 10:33:00 +0000 Subject: [PATCH 04/13] click --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b4abfe0..f03b8c9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,5 @@ ipython==8.1.1 fire==0.4.0 fastapi==0.75.0 pydantic==1.9.0 -uvicorn==0.17.6 \ No newline at end of file +uvicorn==0.17.6 +click==8.0.2 \ No newline at end of file From 1ed5dc8cf2b4ccaa8f0f9d2c83b435a59047e3d0 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 10:35:01 +0000 Subject: [PATCH 05/13] remove main1.yml --- .github/workflows/main1.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/main1.yml diff --git a/.github/workflows/main1.yml b/.github/workflows/main1.yml deleted file mode 100644 index b3a52e0..0000000 --- a/.github/workflows/main1.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Python application test with Github Actions - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - make install - - name: Lint with pylint - run: | - make lint - - name: Test with pytest - run: | - make test - - name: Format code - run: | - make format From 6146e68410a146152764b3bce0706f7b832c75c4 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 10:39:13 +0000 Subject: [PATCH 06/13] main --- .github/workflows/main.yml | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index bc240a3..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Python application test with Github Actions - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - make install - - name: Lint with pylint - run: | - make lint - - name: Test with pytest - run: | - make test - - name: Format code - run: | - make format - From df1b6caa73abc829ad6ddac62ca39bca1ccd6115 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:40:11 +0200 Subject: [PATCH 07/13] Create main.yml --- .github/workflows/main.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..b3a52e0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: Python application test with Github Actions + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + make install + - name: Lint with pylint + run: | + make lint + - name: Test with pytest + run: | + make test + - name: Format code + run: | + make format From 770d61281caa4ea9c696f8d073e743f303a1e8d4 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:29:02 +0000 Subject: [PATCH 08/13] adding wikibot code --- test_wikibot1.py | 4 ++++ wikibot1.py | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 test_wikibot1.py create mode 100644 wikibot1.py diff --git a/test_wikibot1.py b/test_wikibot1.py new file mode 100644 index 0000000..6a1dc93 --- /dev/null +++ b/test_wikibot1.py @@ -0,0 +1,4 @@ +from mylib.bot import scrape + +def test_scrape(): + assert "Microsoft" in scrape("Microsoft") diff --git a/wikibot1.py b/wikibot1.py new file mode 100644 index 0000000..1240dac --- /dev/null +++ b/wikibot1.py @@ -0,0 +1,7 @@ +import wikipedia + +def scrape(name="Microsoft", length=1): + result = wikipedia.summary(name=name, sentences=length) + return result + +print(scrape("Wikipedia")) \ No newline at end of file From b0bfae2043fb3186455d7d557ae892de6dc5b50e Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:30:25 +0000 Subject: [PATCH 09/13] adding wikibot code --- wikibot1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wikibot1.py b/wikibot1.py index 1240dac..8226c07 100644 --- a/wikibot1.py +++ b/wikibot1.py @@ -1,7 +1,7 @@ import wikipedia def scrape(name="Microsoft", length=1): - result = wikipedia.summary(name=name, sentences=length) + result = wikipedia.summary(name sentences=length) return result print(scrape("Wikipedia")) \ No newline at end of file From 16669c779e7b455ad6a6d46dba5c8bf36ff9c6f4 Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:30:39 +0000 Subject: [PATCH 10/13] adding wikibot code --- wikibot1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wikibot1.py b/wikibot1.py index 8226c07..97b6dc4 100644 --- a/wikibot1.py +++ b/wikibot1.py @@ -1,7 +1,7 @@ import wikipedia def scrape(name="Microsoft", length=1): - result = wikipedia.summary(name sentences=length) + result = wikipedia.summary(name, sentences=length) return result print(scrape("Wikipedia")) \ No newline at end of file From 2c3ef23dc4cfcd0c67395f7d578b6f99e4d3ac8b Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:36:37 +0000 Subject: [PATCH 11/13] Wiki --- wikibot1.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wikibot1.py b/wikibot1.py index 97b6dc4..1f75a88 100644 --- a/wikibot1.py +++ b/wikibot1.py @@ -1,7 +1,16 @@ +import click import wikipedia + +@click.command() +@click.option('--name', default='Microsoft', help='Wikipedia word') def scrape(name="Microsoft", length=1): + """ + just scraping + """ result = wikipedia.summary(name, sentences=length) + click.echo(click.style(f"{result}", fg="red")) return result -print(scrape("Wikipedia")) \ No newline at end of file +if __name__=='__main__': + scrape() \ No newline at end of file From 74089a166351e62b641dcb9d67d755f4c1f618ba Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Fri, 23 Jun 2023 12:00:39 +0000 Subject: [PATCH 12/13] latest --- fire-cli.py | 1 + mylib/bot.py | 2 +- test_wikibot.py | 4 ++-- test_wikibot1.py | 10 +++++++++- wikibot.py | 5 +++-- wikibot1.py | 12 ++++++------ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/fire-cli.py b/fire-cli.py index f3668be..c6415c5 100644 --- a/fire-cli.py +++ b/fire-cli.py @@ -1,5 +1,6 @@ import fire from mylib.bot import scrape + if __name__ == "__main__": fire.Fire(scrape) diff --git a/mylib/bot.py b/mylib/bot.py index da2ef43..bdf2f50 100644 --- a/mylib/bot.py +++ b/mylib/bot.py @@ -1,5 +1,5 @@ import wikipedia -def scrape(name="Microsoft", length=1): +def scrape(name, length): result = wikipedia.summary(name, sentences=length) return result \ No newline at end of file diff --git a/test_wikibot.py b/test_wikibot.py index b587dff..dfac3b5 100644 --- a/test_wikibot.py +++ b/test_wikibot.py @@ -4,11 +4,11 @@ def test_scrape(): - assert "Microsoft" in scrape("Microsoft") + assert "Microsoft" in scrape("Microsoft", 1) def test_wikibot(): runner = CliRunner() - result = runner.invoke(cli, ["--name", "Microsoft"]) + result = runner.invoke(cli, ["--name", "Microsoft", "--length", "1"]) assert result.exit_code == 0 assert "Microsoft" in result.output diff --git a/test_wikibot1.py b/test_wikibot1.py index 6a1dc93..284b08a 100644 --- a/test_wikibot1.py +++ b/test_wikibot1.py @@ -1,4 +1,12 @@ from mylib.bot import scrape +from wikibot1 import cli +from click.testing import CliRunner def test_scrape(): - assert "Microsoft" in scrape("Microsoft") + assert "Microsoft" in scrape("Microsoft",1) + +def test_wikibot(): + runner = CliRunner() + result = runner.invoke(cli, ['--name', 'Microsoft', '--length', '1']) + assert result.exit_code == 0 + assert 'Microsoft' in result.output \ No newline at end of file diff --git a/wikibot.py b/wikibot.py index ae3526d..7994592 100644 --- a/wikibot.py +++ b/wikibot.py @@ -4,8 +4,9 @@ @click.command() @click.option("--name", help="Web page we want to scrape") -def cli(name): - result = scrape(name) +@click.option("--length", help="Web page we want to scrape") +def cli(name, length): + result = scrape(name, length) click.echo(click.style(f"{result}:", fg="blue")) diff --git a/wikibot1.py b/wikibot1.py index 1f75a88..5f3f5ab 100644 --- a/wikibot1.py +++ b/wikibot1.py @@ -1,16 +1,16 @@ import click -import wikipedia - +from mylib.bot import scrape @click.command() -@click.option('--name', default='Microsoft', help='Wikipedia word') -def scrape(name="Microsoft", length=1): +@click.option('--name', help='Wikipedia word') +@click.option('--length', help='number of sentences') +def cli(name, length): """ just scraping """ - result = wikipedia.summary(name, sentences=length) + result = scrape(name, length=length) click.echo(click.style(f"{result}", fg="red")) return result if __name__=='__main__': - scrape() \ No newline at end of file + cli() \ No newline at end of file From 1e398889620dcd8e4e7160546316f63de011bcda Mon Sep 17 00:00:00 2001 From: GrzegorzDjango <48175719+GrzegorzDjango@users.noreply.github.com> Date: Fri, 23 Jun 2023 13:19:13 +0000 Subject: [PATCH 13/13] microserv --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index eb84ad4..caff3c2 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ class Wiki(BaseModel): @app.post("/wiki") async def scrape_story(wiki: Wiki): - result = scrape(name=wiki.name) + result = scrape(name=wiki.name, length=1) payload = {"wikipage": result} json_compatible_item_data = jsonable_encoder(payload) return JSONResponse(content=json_compatible_item_data)