Commit d8850508 authored by Jakob Lerch's avatar Jakob Lerch
Browse files

execute r.json() only when needed

parent 98f9c855
......@@ -37,10 +37,11 @@ class Etherpad(Pad):
r = requests.get(self.main_url + "/api/1/getText?apikey=" + self.api_key +
"&padID=" + self.pad_id)
if not r.json()["code"] == 0:
raise Exception(r.json()["message"])
r_json = r.json()
if not r_json["code"] == 0:
raise Exception(r_json["message"])
return r.json()["data"]["text"]
return r_json["data"]["text"]
def write(self, string: str) -> None:
r = requests.post(
......@@ -48,16 +49,18 @@ class Etherpad(Pad):
"&padID=" + self.pad_id,
data={"text": string})
if not r.json()["code"] == 0:
raise Exception(r.json()["message"])
r_json = r.json()
if not r_json["code"] == 0:
raise Exception(r_json["message"])
def append(self, string: str) -> None:
string = quote(string)
r = requests.get(self.main_url + "/api/1.2.13/appendText?apikey=" + self.api_key +
"&padID=" + self.pad_id + "&text=" + string)
if not r.json()["code"] == 0:
raise Exception(r.json()["message"])
r_json = r.json()
if not r_json["code"] == 0:
raise Exception(r_json["message"])
class HedgedocNote(Pad):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment