Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better code style + bumped version #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nekos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.1.0"
__version__ = "1.1.1"

from . import dict
from . import http
Expand Down
45 changes: 20 additions & 25 deletions nekos/nekos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def img(target: str):
"wallpaper",
"ngif",
"tickle",
#"lewd", Provides 1 image
# "lewd", Provides 1 image
"feed",
"gecg",
"gasm",
Expand All @@ -37,24 +37,20 @@ def img(target: str):
]

if target is None:
raise errors.EmptyArgument(
"You have to at least define an argument in string format\nArguments: {}".format(
possible
)
)
raise errors.EmptyArgument(f"You have to at least define an argument in string format\nArguments: {possible}")


if target.lower() not in possible:
raise errors.InvalidArgument(
"You haven't added any valid arguments\nArguments: {}".format(possible)
)
raise errors.InvalidArgument(f"You haven't added any valid arguments\nArguments: {possible}")


try:
if target.lower() == "random_hentai_gif":
r = http.get("/img/Random_hentai_gif")
else:
r = http.get("/img/" + target.lower())
except Exception:
raise errors.NothingFound(noresponse)
r = http.get(f"/img/{target.lower()}")
except Exception as e:
raise errors.NothingFound(noresponse) from e

return r["url"]

Expand All @@ -65,7 +61,7 @@ def owoify(text: str):
"You have to enter a string you want to enter to API"
)

r = http.get("/owoify?text=" + urllib.parse.quote(text))
r = http.get(f"/owoify?text={urllib.parse.quote(text)}")
return r["owo"]


Expand All @@ -75,41 +71,40 @@ def spoiler(text: str):
"You have to enter a string you want to enter to API"
)

r = http.get("/spoiler?text=" + urllib.parse.quote(text))
r = http.get(f"/spoiler?text={urllib.parse.quote(text)}")
return r["owo"]


def cat():
try:
return http.get("/img/meow")["url"]
except Exception:
raise errors.NothingFound(noresponse)
except Exception as e:
raise errors.NothingFound(noresponse) from e


def textcat():
try:
return http.get("/cat")["cat"]
except Exception:
raise errors.NothingFound(noresponse)
except Exception as e:
raise errors.NothingFound(noresponse) from e


def why():
try:
return http.get("/why")["why"]
except Exception:
raise errors.NothingFound(noresponse)
except Exception as e:
raise errors.NothingFound(noresponse) from e


def fact():
try:
return http.get("/fact")["fact"]
except Exception:
raise errors.NothingFound(noresponse)
except Exception as e:
raise errors.NothingFound(noresponse) from e


def name():
try:
return http.get("/name")["name"]
except Exception:
raise errors.NothingFound(noresponse)

except Exception as e:
raise errors.NothingFound(noresponse) from e
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

version = ""
with open("nekos/__init__.py") as f:
version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE
).group(1)
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)[1]



requirements = []
Expand Down