Skip to content

Commit

Permalink
0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoSa-2000 committed May 10, 2023
1 parent 7c23455 commit ccb9625
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
6 changes: 4 additions & 2 deletions animegifs/animegifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def get_gif(self, category: str) -> str:
gif: gif (url) -> str
"""
if type(category) is int:
raise errors.CategoryIntegral
raise errors.CategoryIntegral(category)
elif category.lower() in gifs_dict:
gif = gifs_dict[category.lower()]
elif category.lower() not in gifs_dict:
raise errors.CategoryError(category)
else:
raise errors.CategoryError
raise errors.CategoryUnknown(category)
return gif

36 changes: 32 additions & 4 deletions animegifs/distutils/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
class CategoryIntegral:
"""Category can't be an integral."""
class CategoryIntegral(Exception):
"""
Category can't be an integral, only a string.
You can check valid categories at: https://github.com/MarcoSa-2000/animegifs
"""

class CategoryError:
"""Not a valid category. You can check valid categories at: https://github.com/MarcoSa-2000/animegifs"""
def __init__(self, category, error="Category can't be an integral."):
self.category = category
self.error = error
super().__init__(self.error)

class CategoryError(Exception):
"""
Not a valid category. Category must be a string.
You can check valid categories at: https://github.com/MarcoSa-2000/animegifs
"""

def __init__(self, category, error="Not a valid category."):
self.category = category
self.error = error
super().__init__(self.error)

class CategoryUnknown(Exception):
"""
This is a not handled error, probably the category type is neither an int nor a str.
Make sure to check category is a string and is a valid category.
You can check valid categories at: https://github.com/MarcoSa-2000/animegifs
"""

def __init__(self, category, error="Not a valid category."):
self.category = category
self.error = error
super().__init__(self.error)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
long_description = "\n" + fh.read()

LONG_DESCRIPTION = long_description
VERSION = '0.5.1'
VERSION = '0.5.2'

setup(
name='animegifs',
Expand Down

0 comments on commit ccb9625

Please sign in to comment.