Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
New v5 (Alpha) Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kh4lidMD committed Dec 9, 2022
1 parent fe52480 commit 8fb7186
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _Learn more about Adhan in [Wikipedia](https://en.wikipedia.org/wiki/Adhan)_
- No API keys, authentication, or registration required.
- Converting the JSON responses to Python objects.
- 3 Location methods: Coordinates, City, and Address.
- More Adhan metadata made by the module, such as the number of rakat in salah, sunnan al rawatib rakat number, is hijri or secret salah, etc.

<br>

Expand Down Expand Up @@ -46,17 +47,27 @@ See the [Wiki](https://www.github.com/Kh4lidMD/AlAdhan/wiki)

# Versioning

v4.1.0 (Alpha) **Latest**
v5.0.0 (Alpha) **Latest**

- Set `threaded_wait` default argument in the `Adhan.wait` method from `True` to `False`.
- Added missing file `aladhan/exceptions.py` to the repository. which was included in the package but not in the repository.
- Changed `RateLimitException` to `RateLimitedException` (typo fix).
- Added `sunnan_al_rawatib` function to the `Adhan` object, returns a dictionary with `before` and `after` keys, each one contains the sunnan al rawatib rakat number.
- _[English Source](https://www.wikihow.com/Pray-Sunnah-Prayers)_
- _[Arabic Source](https://mawdoo3.com/%D9%85%D8%A7_%D9%87%D9%8A_%D8%B3%D9%86%D9%86_%D8%A7%D9%84%D8%B5%D9%84%D8%A7%D8%A9_%D8%A7%D9%84%D9%85%D8%A4%D9%83%D8%AF%D8%A9)_
- Added `__version__` attribute to the `aladhan` module, a version tuple like `(major, minor, patch)`.

v4.1.0 (Alpha)

- Added custom exceptions especially for the following return codes:
- 400 Bad Request error: `BadRequestException`
- 429 Rate limited error: `RateLimitedException`
- 500 Internal Server error: `ServerErrorException`
- 400 bad request error: `BadRequestException`
- 429 rate limited error: `RateLimitedException`
- 500 internal server error: `ServerErrorException`

_They're avaialble in the `aladhan.exceptions`, could be directly imported from the `aladhan` module._
- New Wiki page: [Exception Handling](https://www.github.com/Kh4lidMD/AlAdhan/wiki/Exception-Handling)

_Started to save a copy of the Wiki pages in every release._
_Started to save a copy of the Wiki pages in every release._

v4.0.0 (Alpha)

Expand Down
2 changes: 2 additions & 0 deletions aladhan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .client import Aladhan
from .location_types import City, Address, Coordinates
from .exceptions import *

__version__ = (5, 0, 0)
14 changes: 13 additions & 1 deletion aladhan/adhan.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def readable_timing(self, show_time=True, show_date=True, _24h=False, arabic=Fal
else:
return self.datetime_obj.strftime(format_)

def wait(self, callback=None, threaded_wait=True, **kwargs):
def wait(self, callback=None, threaded_wait=False, **kwargs):
"""
Wait until the salah time has passed.
Expand Down Expand Up @@ -128,5 +128,17 @@ def get_name(self, lang='en') -> str:
else:
return self.name

def sunnan_al_rawatib(self) -> dict:
"""
Returns a dictionary with the number of sunnah prayers `before` and `after` the salah.
"""

if self.name == 'Fajr': return {'before': 2,'after': 0}
elif self.name == 'Dhuhr': return {'before': 4, 'after': 2}
elif self.name == 'Asr': return {'before': 0, 'after': 0}
elif self.name == 'Maghrib': return {'before': 0, 'after': 2}
elif self.name == 'Isha': return {'before': 0, 'after': 2}


def __str__(self):
return f'{self.name} at {self.readable_timing()}'
2 changes: 1 addition & 1 deletion aladhan/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __get_endpoint_by_location(location: Union[Coordinates, Address, City], endp
@staticmethod
def __detect_exceptions(response: requests.Response, data: dict):
if response.status_code == 429:
raise RateLimitException("Rate limit exceeded.")
raise RateLimitedException("Rate limit exceeded.")
if response.status_code == 400:
raise BadRequestException(data['data'])
if response.status_code == 500:
Expand Down
3 changes: 3 additions & 0 deletions aladhan/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class RateLimitedException(Exception):pass
class BadRequestException(Exception):pass
class ServerErrorException(Exception):pass
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[metadata]
description-file = README.md
description-file = README.md
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="aladhan-api",
version="4.1.0",
version="5.0.0",
author="Khaled Mahmoud",
author_email="[email protected]",
description="A Python package to calculate Islamic prayer times for any location in the world.",
Expand Down

0 comments on commit 8fb7186

Please sign in to comment.