Skip to content

Commit 8622554

Browse files
committed
change debug param into kwarg
1 parent f7e2804 commit 8622554

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pybpsapi.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,29 @@ def getpng(self, url: str) -> list | None:
105105

106106

107107
class CircularChecker:
108-
def __init__(self, category, url: str = "https://bpsapi.rajtech.me/", cache_method='sqlite', debug: bool = False,
109-
**kwargs):
108+
def __init__(self, category, url: str = "https://bpsapi.rajtech.me/", cache_method='sqlite', **kwargs):
110109
self.url = url
111110
self.category = category
112111
self._cache = []
113112

114113
json = requests.get(self.url + "categories").json()
115114

116115
if json['http_status'] == 200:
117-
self.categories = json['data']
116+
categories = json['data']
118117
else:
119118
raise ConnectionError("Invalid API Response. API says there are no categories.")
120119

121-
if debug:
120+
if kwargs.get("debug"):
122121
self.set_cache = self._set_cache
123122
self.refresh_cache = self._refresh_cache
124123

125-
if type(category) == int:
126-
category = int(category)
127-
if not 1 < category < 100:
124+
# If category id is passed
125+
if type(self.category) is int:
126+
if not 1 < self.category < 100:
128127
raise ValueError("Invalid category Number")
129-
128+
# If category name is passed
130129
else:
131-
if category not in self.categories:
130+
if self.category not in categories:
132131
raise ValueError("Invalid category Name")
133132

134133
self.cache_method = cache_method

0 commit comments

Comments
 (0)