From d0971e4c28890a3035167f021f0cd53273171293 Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Tue, 11 Jan 2022 07:32:21 +0200 Subject: [PATCH 1/8] Update currency_converter.py --- web_programming/currency_converter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index 447595b0b646..667dc05d52ff 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -10,8 +10,9 @@ URL_BASE = "https://www.amdoren.com/api/currency.php" TESTING = os.getenv("CI", False) API_KEY = os.getenv("AMDOREN_API_KEY", "") + if not API_KEY and not TESTING: - raise KeyError("Please put your API key in an environment variable.") + raise KeyError("API key must be set as AMDOREN_API_KEY") # Currency and their description @@ -173,12 +174,12 @@ def convert_currency( - from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = API_KEY + from="USD", to="INR", amount=1.0, api_key=API_KEY ) -> str: """https://www.amdoren.com/currency-api/""" - params = locals() - params["from"] = params.pop("from_") + params = dict(from=from, to=to, amount=amount, api_key=api_key) res = requests.get(URL_BASE, params=params).json() + return str(res["amount"]) if res["error"] == 0 else res["error_message"] From 6bda71c916694571651bbe666e296db214028ab9 Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Wed, 12 Jan 2022 10:50:50 +0200 Subject: [PATCH 2/8] refactor: add types and remove reserved keyword "from" usage --- web_programming/currency_converter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index 667dc05d52ff..f464427a5091 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -174,10 +174,10 @@ def convert_currency( - from="USD", to="INR", amount=1.0, api_key=API_KEY + from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = API_KEY ) -> str: """https://www.amdoren.com/currency-api/""" - params = dict(from=from, to=to, amount=amount, api_key=api_key) + params = dict(from=from_, to=to, amount=amount, api_key=api_key) res = requests.get(URL_BASE, params=params).json() return str(res["amount"]) if res["error"] == 0 else res["error_message"] From 3ad0d0ca55c834cd3fc95c9a7e2afe78b39eab1a Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Wed, 12 Jan 2022 10:51:37 +0200 Subject: [PATCH 3/8] feat: update text --- web_programming/currency_converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index f464427a5091..15ee6f2948c8 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -12,7 +12,7 @@ API_KEY = os.getenv("AMDOREN_API_KEY", "") if not API_KEY and not TESTING: - raise KeyError("API key must be set as AMDOREN_API_KEY") + raise KeyError("API key must be set as 'AMDOREN_API_KEY' in environment variables") # Currency and their description From 2cfb919d8b6cfe736bee5b0a7c1ef8cb793aa857 Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Sun, 16 Jan 2022 08:41:42 +0200 Subject: [PATCH 4/8] Update web_programming/currency_converter.py Co-authored-by: xcodz-dot <71920621+xcodz-dot@users.noreply.github.com> --- web_programming/currency_converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index 15ee6f2948c8..050bc1e8745d 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -12,7 +12,7 @@ API_KEY = os.getenv("AMDOREN_API_KEY", "") if not API_KEY and not TESTING: - raise KeyError("API key must be set as 'AMDOREN_API_KEY' in environment variables") + raise KeyError("API key must be provided with 'AMDOREN_API_KEY' environment variable.") # Currency and their description From a42f7b0f9afd44df7e23b7b133f0350ae9d638d3 Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Sun, 16 Jan 2022 08:42:24 +0200 Subject: [PATCH 5/8] Update web_programming/currency_converter.py Co-authored-by: xcodz-dot <71920621+xcodz-dot@users.noreply.github.com> --- web_programming/currency_converter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index 050bc1e8745d..e6062eb8c3e9 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -177,7 +177,12 @@ def convert_currency( from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = API_KEY ) -> str: """https://www.amdoren.com/currency-api/""" - params = dict(from=from_, to=to, amount=amount, api_key=api_key) + params = { + "from": from_, + "to": to, + "amount": amount + "api_key": api_key + } res = requests.get(URL_BASE, params=params).json() return str(res["amount"]) if res["error"] == 0 else res["error_message"] From 9e6e69fdd943be91815eb4d4aef16ff4941ad21d Mon Sep 17 00:00:00 2001 From: Michael Currin <18750745+MichaelCurrin@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:46:34 +0200 Subject: [PATCH 6/8] fix: update currency_converter.py --- web_programming/currency_converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index e6062eb8c3e9..cd018c77e381 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -180,7 +180,7 @@ def convert_currency( params = { "from": from_, "to": to, - "amount": amount + "amount": amount, "api_key": api_key } res = requests.get(URL_BASE, params=params).json() From 81c5e4663d9ea115a4256632891a2cdd2140830b Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 17 Jan 2022 10:46:55 +0000 Subject: [PATCH 7/8] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 16244e6ad08e..550920c0fc39 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -114,6 +114,7 @@ * [Harris Corner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harris_corner.py) * [Mean Threshold](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mean_threshold.py) * [Mosaic Augmentation](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/mosaic_augmentation.py) + * [Pooling Functions](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/pooling_functions.py) ## Conversions * [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py) From 457dddf9dd00464a0ec1e4e9bf1900eac51a5c97 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Fri, 28 Jan 2022 07:46:23 +0100 Subject: [PATCH 8/8] Update currency_converter.py --- web_programming/currency_converter.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/web_programming/currency_converter.py b/web_programming/currency_converter.py index cd018c77e381..6fcc60e8feeb 100644 --- a/web_programming/currency_converter.py +++ b/web_programming/currency_converter.py @@ -12,8 +12,9 @@ API_KEY = os.getenv("AMDOREN_API_KEY", "") if not API_KEY and not TESTING: - raise KeyError("API key must be provided with 'AMDOREN_API_KEY' environment variable.") - + raise KeyError( + "API key must be provided in the 'AMDOREN_API_KEY' environment variable." + ) # Currency and their description list_of_currencies = """ @@ -177,14 +178,9 @@ def convert_currency( from_: str = "USD", to: str = "INR", amount: float = 1.0, api_key: str = API_KEY ) -> str: """https://www.amdoren.com/currency-api/""" - params = { - "from": from_, - "to": to, - "amount": amount, - "api_key": api_key - } + params = locals() + params["from"] = params.pop("from_") res = requests.get(URL_BASE, params=params).json() - return str(res["amount"]) if res["error"] == 0 else res["error_message"]