From cc17d7bed9458a20182de571bf5c0c2462cf46b0 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 09:33:01 +0200 Subject: [PATCH 01/17] Add README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..1fa4485a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# hypermodern-python From 65b76be74f49a51b5d05784a72a614df9d10bb64 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 23 Oct 2019 14:35:13 +0200 Subject: [PATCH 02/17] Add LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..a54988df --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Claudio Jolowicz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From b7d898b994ed451544abefc3085ffbfa4aeb6b11 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 10:09:45 +0200 Subject: [PATCH 03/17] Ignore /.python-version --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..183700bc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.python-version From 8093f60b4474e2c465f72f38c5f8b7506ab0c819 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 10:16:51 +0200 Subject: [PATCH 04/17] Add pyproject.toml --- pyproject.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..bf1291ec --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[tool.poetry] +name = "hypermodern-python" +version = "0.1.0" +description = "" +authors = ["Claudio Jolowicz "] + +[tool.poetry.dependencies] +python = "^3.8" + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" From 60b58bc392b8f8ab7a89cde6d1f6a5e0d7f4f21d Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 17:08:16 +0200 Subject: [PATCH 05/17] Add metadata to pyproject.toml --- pyproject.toml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bf1291ec..a5f68d7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,13 @@ [tool.poetry] name = "hypermodern-python" version = "0.1.0" -description = "" -authors = ["Claudio Jolowicz "] +description = "The hypermodern Python project" +authors = ["Claudio Jolowicz "] +license = "MIT" +readme = "README.md" +homepage = "https://github.com/cjolowicz/hypermodern-python" +repository = "https://github.com/cjolowicz/hypermodern-python" +keywords = ["hypermodern"] [tool.poetry.dependencies] python = "^3.8" From 1e108f9f640fe8d7a4ad9b3ab7793a772120bd17 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Tue, 22 Oct 2019 21:36:26 +0200 Subject: [PATCH 06/17] Support Python 3.7 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a5f68d7b..adab6c9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ repository = "https://github.com/cjolowicz/hypermodern-python" keywords = ["hypermodern"] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.7" [tool.poetry.dev-dependencies] From 42fb9656a09557017fdde347faf05e24e7cdf728 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 10:21:40 +0200 Subject: [PATCH 07/17] Add package --- src/hypermodern_python/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/hypermodern_python/__init__.py diff --git a/src/hypermodern_python/__init__.py b/src/hypermodern_python/__init__.py new file mode 100644 index 00000000..3dc1f76b --- /dev/null +++ b/src/hypermodern_python/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" From bd911fa938e579a39b8f49a3aedf506e828e06c1 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Tue, 22 Oct 2019 21:38:28 +0200 Subject: [PATCH 08/17] Add poetry.lock --- poetry.lock | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 poetry.lock diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 00000000..ddb163c6 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,7 @@ +package = [] + +[metadata] +content-hash = "669741988c507fb04697bdb0c9077fa1b2342c356df6ae6c96baa3119a96a9ea" +python-versions = "^3.7" + +[metadata.files] From 7c0658235a70d27c521d97566c8ed5fa7f056655 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 10:29:10 +0200 Subject: [PATCH 09/17] Ignore /src/*.egg-info/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 183700bc..3f43a2a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.python-version +/src/*.egg-info/ From ba022a771d83235b7ff961aa337416f486fba6db Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 10:40:45 +0200 Subject: [PATCH 10/17] Ignore __pycache__/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3f43a2a0..0a535072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.python-version /src/*.egg-info/ +__pycache__/ From b0be072530a080feb868be8cbd4e586733fbfb01 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Tue, 22 Oct 2019 21:41:35 +0200 Subject: [PATCH 11/17] Add click 7.0 --- poetry.lock | 14 ++++++++++++-- pyproject.toml | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index ddb163c6..748902ab 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,7 +1,17 @@ -package = [] +[[package]] +category = "main" +description = "Composable command line interface toolkit" +name = "click" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "7.0" [metadata] -content-hash = "669741988c507fb04697bdb0c9077fa1b2342c356df6ae6c96baa3119a96a9ea" +content-hash = "b8b75d81010ba6daf4b088e7fcb7b8256c7e3fd21675f7e10a94a192895455f8" python-versions = "^3.7" [metadata.files] +click = [ + {file = "Click-7.0-py2.py3-none-any.whl", hash = "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13"}, + {file = "Click-7.0.tar.gz", hash = "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"}, +] diff --git a/pyproject.toml b/pyproject.toml index adab6c9f..d79f3f5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ keywords = ["hypermodern"] [tool.poetry.dependencies] python = "^3.7" +click = "^7.0" [tool.poetry.dev-dependencies] From 842757d5d4ec4c1948e2c5f553d8738feab45b5c Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 16:05:44 +0200 Subject: [PATCH 12/17] Add console module --- src/hypermodern_python/console.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/hypermodern_python/console.py diff --git a/src/hypermodern_python/console.py b/src/hypermodern_python/console.py new file mode 100644 index 00000000..ad69666d --- /dev/null +++ b/src/hypermodern_python/console.py @@ -0,0 +1,10 @@ +import click + +from . import __version__ + + +@click.command() +@click.version_option(version=__version__) +def main(): + """The hypermodern Python project.""" + click.echo("Hello, world!") From d18cd4db69135b08102915e21d2795b9184ca5f3 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 16 Oct 2019 16:13:23 +0200 Subject: [PATCH 13/17] Add script to pyproject.toml --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index d79f3f5a..a0c9a986 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,6 +15,9 @@ click = "^7.0" [tool.poetry.dev-dependencies] +[tool.poetry.scripts] +hypermodern-python = "hypermodern_python.console:main" + [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" From 2e911d16750fcae6ddd16c0acee7fcfc9ee595d0 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Sun, 29 Dec 2019 12:02:02 +0100 Subject: [PATCH 14/17] Add requests 2.22.0 --- poetry.lock | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 748902ab..7179b203 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,19 @@ +[[package]] +category = "main" +description = "Python package for providing Mozilla's CA Bundle." +name = "certifi" +optional = false +python-versions = "*" +version = "2019.11.28" + +[[package]] +category = "main" +description = "Universal encoding detector for Python 2 and 3" +name = "chardet" +optional = false +python-versions = "*" +version = "3.0.4" + [[package]] category = "main" description = "Composable command line interface toolkit" @@ -6,12 +22,71 @@ optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "7.0" +[[package]] +category = "main" +description = "Internationalized Domain Names in Applications (IDNA)" +name = "idna" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "2.8" + +[[package]] +category = "main" +description = "Python HTTP for Humans." +name = "requests" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +version = "2.22.0" + +[package.dependencies] +certifi = ">=2017.4.17" +chardet = ">=3.0.2,<3.1.0" +idna = ">=2.5,<2.9" +urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26" + +[package.extras] +security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)"] +socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"] + +[[package]] +category = "main" +description = "HTTP library with thread-safe connection pooling, file post, and more." +name = "urllib3" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" +version = "1.25.7" + +[package.extras] +brotli = ["brotlipy (>=0.6.0)"] +secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] +socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] + [metadata] -content-hash = "b8b75d81010ba6daf4b088e7fcb7b8256c7e3fd21675f7e10a94a192895455f8" +content-hash = "b692c8b157a6f554c683538e7aced4c6eb40d48b4a81837e98d1b827baafc7f1" python-versions = "^3.7" [metadata.files] +certifi = [ + {file = "certifi-2019.11.28-py2.py3-none-any.whl", hash = "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3"}, + {file = "certifi-2019.11.28.tar.gz", hash = "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"}, +] +chardet = [ + {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, + {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, +] click = [ {file = "Click-7.0-py2.py3-none-any.whl", hash = "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13"}, {file = "Click-7.0.tar.gz", hash = "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"}, ] +idna = [ + {file = "idna-2.8-py2.py3-none-any.whl", hash = "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"}, + {file = "idna-2.8.tar.gz", hash = "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407"}, +] +requests = [ + {file = "requests-2.22.0-py2.py3-none-any.whl", hash = "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"}, + {file = "requests-2.22.0.tar.gz", hash = "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4"}, +] +urllib3 = [ + {file = "urllib3-1.25.7-py2.py3-none-any.whl", hash = "sha256:a8a318824cc77d1fd4b2bec2ded92646630d7fe8619497b142c84a9e6f5a7293"}, + {file = "urllib3-1.25.7.tar.gz", hash = "sha256:f3c5fd51747d450d4dcf6f923c81f78f811aab8205fda64b0aba34a4e48b0745"}, +] diff --git a/pyproject.toml b/pyproject.toml index a0c9a986..b727d26a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ keywords = ["hypermodern"] [tool.poetry.dependencies] python = "^3.7" click = "^7.0" +requests = "^2.22.0" [tool.poetry.dev-dependencies] From fa0aea99edaf7262f6f3466e0f4c20df5b0491d4 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Sun, 29 Dec 2019 12:01:02 +0100 Subject: [PATCH 15/17] Display random fact using Wikipedia API --- src/hypermodern_python/console.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hypermodern_python/console.py b/src/hypermodern_python/console.py index ad69666d..62acfd28 100644 --- a/src/hypermodern_python/console.py +++ b/src/hypermodern_python/console.py @@ -1,4 +1,7 @@ +import textwrap + import click +import requests from . import __version__ @@ -7,4 +10,10 @@ @click.version_option(version=__version__) def main(): """The hypermodern Python project.""" - click.echo("Hello, world!") + response = requests.get("https://en.wikipedia.org/api/rest_v1/page/random/summary") + + title = response.json()["title"] + extract = response.json()["extract"] + + click.secho(title, fg="green") + click.echo(textwrap.fill(extract)) From cf91826506f027773185e6e1a68bc8b911b323da Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 1 Jan 2020 21:41:47 +0100 Subject: [PATCH 16/17] Close response and avoid double parse --- src/hypermodern_python/console.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hypermodern_python/console.py b/src/hypermodern_python/console.py index 62acfd28..f0327f07 100644 --- a/src/hypermodern_python/console.py +++ b/src/hypermodern_python/console.py @@ -6,14 +6,18 @@ from . import __version__ +API_URL = "https://en.wikipedia.org/api/rest_v1/page/random/summary" + + @click.command() @click.version_option(version=__version__) def main(): """The hypermodern Python project.""" - response = requests.get("https://en.wikipedia.org/api/rest_v1/page/random/summary") + with requests.get(API_URL) as response: + data = response.json() - title = response.json()["title"] - extract = response.json()["extract"] + title = data["title"] + extract = data["extract"] click.secho(title, fg="green") click.echo(textwrap.fill(extract)) From 2438a6ac98cfc346106a2f732277caa6943e79b8 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 1 Jan 2020 21:42:40 +0100 Subject: [PATCH 17/17] Raise an exception on HTTP error codes --- src/hypermodern_python/console.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hypermodern_python/console.py b/src/hypermodern_python/console.py index f0327f07..44e24336 100644 --- a/src/hypermodern_python/console.py +++ b/src/hypermodern_python/console.py @@ -14,6 +14,7 @@ def main(): """The hypermodern Python project.""" with requests.get(API_URL) as response: + response.raise_for_status() data = response.json() title = data["title"]