Skip to content

Commit 2512258

Browse files
committed
Fix category
1 parent 4e30a0d commit 2512258

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

jokeapi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
import urllib
33
import json
44
from jokeapi.main import Jokes
5+
print("Sv443's JokeAPI")

jokeapi/main.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
import urllib
33
import simplejson as json
44
import re
5+
from yaml import load, dump
6+
try:
7+
from yaml import CLoader as Loader, CDumper as Dumper
8+
except ImportError:
9+
from yaml import Loader, Dumper
510

11+
import xml.etree.ElementTree
612

713
class Jokes:
814
def __init__(self):
915
self.http = urllib3.PoolManager()
10-
print("Sv443's JokeAPI")
1116

1217
def build_request(
1318
self,
@@ -148,11 +153,6 @@ def send_request(self, request, response_format, return_headers, auth_token, use
148153
except:
149154
print(data)
150155
raise
151-
else:
152-
data = str(data)[2:-1].replace(r'\n', '\n').replace('\\', '')
153-
if len(' '.join(re.split("error", data.lower().replace("\n", "NEWLINECHAR"))[0:][1:]).replace(
154-
'<', '').replace('/', '').replace(' ', '').replace(':', '').replace('>', '').replace('NEWLINECHAR', '\n')) == 4:
155-
return [Exception(f"API returned an error. Full response: \n\n {data}")]
156156

157157
headers = str(r.headers).replace(r'\n', '').replace(
158158
'\n', '').replace(r'\\', '').replace(r"\'", '')[15:-1]
@@ -164,7 +164,9 @@ def send_request(self, request, response_format, return_headers, auth_token, use
164164
if auth_token:
165165
returns.append({"Token-Valid": bool(int(re.split(r"Token-Valid", headers)[1][4]))})
166166

167-
return returns
167+
if len(returns) > 1:
168+
return returns
169+
return returns[0]
168170

169171
def get_joke(
170172
self,

0 commit comments

Comments
 (0)