Skip to content

Commit

Permalink
Merge pull request #18 from uKaigo/add/noresults-desc
Browse files Browse the repository at this point in the history
Describe NoResults errors
  • Loading branch information
AndyTempel authored May 12, 2021
2 parents 33989b2 + ca0e7dd commit 2bf8567
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ksoftapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__author__ = 'AndyTempel'
__license__ = 'GNU'
__copyright__ = 'Copyright 2018-2020 AndyTempel'
__version__ = '0.4.1'
__version__ = '0.4.2a'

import logging
from collections import namedtuple
Expand All @@ -19,7 +19,7 @@

VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial')

version_info = VersionInfo(major=0, minor=4, micro=1, releaselevel='alpha', serial=0)
version_info = VersionInfo(major=0, minor=4, micro=2, releaselevel='alpha', serial=0)

try:
from logging import NullHandler
Expand Down
4 changes: 2 additions & 2 deletions ksoftapi/apis/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ async def info(self, user_id: int) -> BanInfo:
"""
r = await self._client.http.get('/bans/info', params={'user': user_id})

if 'code' in r and r['code'] == 404:
raise NoResults
if r.get('code', 200) == 404:
raise NoResults(r['message'])

return BanInfo(r)

Expand Down
8 changes: 4 additions & 4 deletions ksoftapi/apis/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def random_image(self, tag: str, nsfw: bool = False) -> Image:
r = await self._client.http.get('/images/random-image', params={'tag': tag, 'nsfw': nsfw})

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

return Image(r)

Expand Down Expand Up @@ -92,7 +92,7 @@ async def random_reddit(self, subreddit: str, remove_nsfw: bool = False, span: s
params={'remove_nsfw': remove_nsfw, 'span': span})

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

return RedditImage(r)

Expand Down Expand Up @@ -123,7 +123,7 @@ async def get_image(self, snowflake: str) -> Image:
r = await self._client.http.get('/images/image/{}'.format(snowflake))

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

return Image(r)

Expand All @@ -143,7 +143,7 @@ async def search_tags(self, search: str) -> TagCollection:
r = await self._client.http.get('/images/tags/{}'.format(search))

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

return TagCollection(r)

Expand Down
4 changes: 2 additions & 2 deletions ksoftapi/apis/kumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def gis(self, location: str, fast: bool = False, more: bool = False, map_z
'include_map': include_map})

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

result = r['data']
if isinstance(result, list):
Expand Down Expand Up @@ -67,7 +67,7 @@ async def geoip(self, ip: str):
r = await self._client.http.get('/kumo/geoip', params={'ip': ip})

if r.get('code', 200) == 404:
raise NoResults
raise NoResults(r['message'])

result = r['data']
return IPInfo(result)
Expand Down
4 changes: 2 additions & 2 deletions ksoftapi/apis/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def lyrics(self, query: str, text_only: bool = False, clean_up: bool = Tru
results = r['data']

if not results:
raise NoResults
raise NoResults('Song not found.')

return [LyricResult(lr) for lr in results]

Expand Down Expand Up @@ -82,6 +82,6 @@ async def recommendations(self, tracks: list, provider: str, youtube_token: str
results = r['tracks']

if not results:
raise NoResults
raise NoResults('No recommendations.')

return [Recommendation(r) for r in results]

0 comments on commit 2bf8567

Please sign in to comment.