From ba80d3cd45e91d43b4af89a77437ac12d8c932e8 Mon Sep 17 00:00:00 2001 From: DARKPOISON-yt Date: Wed, 12 Jan 2022 11:19:57 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Added=20Error=20Raise=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++++-- __main__.py | 2 +- animalapi/__init__.py | 2 ++ setup.py | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 149b0cd..e0f3c7d 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,12 @@ fact = data["fact"] ```Python import animalapi as a -data = a.dog() +data = a.animal_data("dog") img = data["image"] fact = data["fact"] +print(img) +print(fact) ``` -> Currently this package supports these animals:- ["dog","cat","panda","fox","kangaroo","raccoon","birb","red_panda","koala"] +> Currently this package supports these animals:- ["dog","cat","panda","fox","kangaroo","raccoon","bird","red_panda","koala"] diff --git a/__main__.py b/__main__.py index 9d2b59b..87fa468 100644 --- a/__main__.py +++ b/__main__.py @@ -1,3 +1,3 @@ import animalapi as a -print(a.rand_animals()) \ No newline at end of file +print(a.animal_data("dogs")) \ No newline at end of file diff --git a/animalapi/__init__.py b/animalapi/__init__.py index e072265..e324095 100644 --- a/animalapi/__init__.py +++ b/animalapi/__init__.py @@ -17,6 +17,8 @@ def animal_data(animalname): + if animalname not in aliases: + raise ValueError("That animal name is not available. Valid animals are: -\"dog","cat","panda","fox","kangaroo","raccoon","bird","red_panda","koala\"") res = requests.get(base_url + f"animal/{aliases[animalname]}") if res.status_code != 200: return "Invalid response from API" diff --git a/setup.py b/setup.py index 1365186..a6f1fc3 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = "0.0.2" +VERSION = "0.0.3" DESCRIPTION = "This is the package for api scapper that provides animal images and their facts." LONG_DESCRIPTION = "" @@ -22,7 +22,7 @@ packages= ["animalapi"], install_requires=["requests"], keywords=[], - download_url = "https://github.com/DARKPOISON-yt/animalapi/archive/refs/tags/0.0.1.tar.gz", + download_url = "https://github.com/DARKPOISON-yt/animalapi/archive/refs/tags/0.0.3.tar.gz", classifiers=[ "Development Status :: 1 - Planning", "Intended Audience :: Developers",