Skip to content

Commit

Permalink
Merge pull request #8 from MarzaElise/main
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGenocides authored Sep 26, 2021
2 parents e42a103 + 2ad6c34 commit 6970802
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 54 deletions.
14 changes: 2 additions & 12 deletions holybooks/bible.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .errors import ApiError, NotFound
import aiohttp
import requests

__all__ = ("ChapterVerse", "Bible")

Expand Down Expand Up @@ -45,12 +47,6 @@ def request(
starting_verse: int,
ending_verse: int = None,
):
try:
import requests
except ImportError:
raise ImportError(
"Please Install the requests module if you want to make a sync request."
)

self = cls(book)
verse = _build_verse(starting_verse, ending_verse)
Expand Down Expand Up @@ -84,12 +80,6 @@ async def async_request(
ending_verse: int = None,
loop=None,
):
try:
import aiohttp
except ImportError:
raise ImportError(
"Please Install the aiohttp module if you want to make an async request."
)

self = cls(book)
verse = _build_verse(starting_verse, ending_verse)
Expand Down
4 changes: 3 additions & 1 deletion holybooks/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import TYPE_CHECKING
from typing import Optional, Union

if TYPE_CHECKING:
from typing import Optional, Union

__all__ = (
"ApiError",
Expand Down
50 changes: 9 additions & 41 deletions holybooks/quran.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from typing import Union, Optional
from .errors import ApiError, WrongLang, NumberError, ContentTypeError
import aiohttp
import requests
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Union, Optional


__all__ = (
"Surah",
Expand All @@ -19,12 +25,6 @@ def __init__(self, surah: int = None):

@classmethod
def request(cls, surah: int = None):
try:
import requests
except ImportError:
raise ImportError(
"Please Install the requests module if you want to make a sync request."
)

self = cls(surah)

Expand All @@ -45,12 +45,6 @@ def request(cls, surah: int = None):

@classmethod
async def async_request(cls, surah: int = None, *, loop=None):
try:
import aiohttp
except ImportError:
raise ImportError(
"Please Install the aiohttp module if you want to make an async request."
)

self = cls(surah)

Expand Down Expand Up @@ -185,13 +179,6 @@ def __init__(self, surah: int = None, *, ayah: int = None):

@classmethod
def request(cls, surah: int = None, *, ayah: int = None, loop=None):
try:
import requests
except ImportError:
raise ImportError(
"Please Install the requests module if you want to make a sync request."
)

self = cls(surah, ayah=ayah)

if not self._session:
Expand All @@ -211,12 +198,6 @@ def request(cls, surah: int = None, *, ayah: int = None, loop=None):
async def async_request(
cls, surah: int = None, *, ayah: int = None, loop=None
):
try:
import aiohttp
except ImportError:
raise ImportError(
"Please Install the aiohttp module if you want to make an async request."
)

self = cls(surah, ayah=ayah)

Expand Down Expand Up @@ -293,12 +274,6 @@ async def async_request(
request: int = None,
loop=None,
):
try:
import aiohttp
except ImportError:
raise ImportError(
"Please Install the aiohttp module if you want to make an async request."
)

self = cls(mention, surah=surah, request=request)

Expand Down Expand Up @@ -336,12 +311,6 @@ def request(
surah: Optional[Union[str, int]] = None,
request: int = None,
):
try:
import requests
except ImportError:
raise ImportError(
"Please Install the requests module if you want to make a sync request."
)

self = cls(mention, surah=surah, request=request)

Expand Down Expand Up @@ -381,15 +350,14 @@ def find(self):
if self.data is None or self.matches is None:
return None
data = []
if self.req == None:
if self.req is None:
for num in range(self.data["count"]):
data.append(self.matches[num]["text"])
return data

else:
for num in range(self.req):
data.append(self.matches[num]["text"])
return data
return data

def __enter__(self):
return self
Expand Down

0 comments on commit 6970802

Please sign in to comment.