Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Technik
protocol-translation-live
Commits
d8850508
Commit
d8850508
authored
Apr 24, 2022
by
Jakob Lerch
Browse files
execute r.json() only when needed
parent
98f9c855
Changes
1
Hide whitespace changes
Inline
Side-by-side
protocol_translation_live/pad.py
View file @
d8850508
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment