Skip to content

Commit 0911cc6

Browse files
author
Haojun Li
committed
feat(user): Resolved some style issues
1 parent 253d162 commit 0911cc6

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

piazza_api/network.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,26 @@ def create_instructor_answer(self, post, content, revision, anonymous=False):
174174
return self._rpc.content_instructor_answer(params)
175175

176176
def mark_as_duplicate(self, duplicated_cid, master_cid, msg=''):
177-
"""Mark the post at DUPLICATED_CID as a duplicate of MASTER_CID
177+
"""Mark the post at ``duplicated_cid`` as a duplicate of ``master_cid``
178178
179179
:type duplicated_cid: int
180180
:param duplicated_cid: The numeric id of the duplicated post
181181
:type master_cid: int
182182
:param master_cid: The numeric id of an older post. This will be the
183-
post that gets kept and DUPLICATED_CID post will be concatinated
184-
as a follow up to MASTER_CID post.
185-
:returns True if it is successful. False otherwise
183+
post that gets kept and ``duplicated_cid`` post will be concatinated
184+
as a follow up to ``master_cid`` post.
185+
:type msg: string
186+
:param msg: the optional message (or reason for marking as duplicate)
187+
:returns: True if it is successful. False otherwise
186188
"""
187-
try:
188-
content_id_from = self.get_post(duplicated_cid)['id']
189-
content_id_to = self.get_post(master_cid)['id']
190-
except:
191-
return False
192-
params = {'cid_dupe': content_id_from,
193-
'cid_to': content_id_to,
194-
'msg': msg}
195-
return self._rpc.content_mark_duplicate(params) == 'OK'
189+
content_id_from = self.get_post(duplicated_cid)["id"]
190+
content_id_to = self.get_post(master_cid)["id"]
191+
params = {
192+
"cid_dupe": content_id_from,
193+
"cid_to": content_id_to,
194+
"msg": msg
195+
}
196+
return self._rpc.content_mark_duplicate(params)
196197

197198
#########
198199
# Users #

piazza_api/rpc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ def content_create(self, params):
109109
method="content.create",
110110
data=params
111111
)
112-
return self._handle_error(r, "Could not create object {}.".format(
113-
repr(params)))
112+
return self._handle_error(
113+
r,
114+
"Could not create object {}.".format(repr(params))
115+
)
114116

115117
def content_instructor_answer(self, params):
116118
"""Answer a post as an instructor.
@@ -132,11 +134,10 @@ def content_mark_duplicate(self, params):
132134
133135
:type params: dict
134136
:param params: the parameters to be passed in
135-
:returns python object containting returned data
136137
"""
137138
r = self.request(
138-
method="content.duplicate",
139-
data=params
139+
method="content.duplicate",
140+
data=params
140141
)
141142
return self._handle_error(r, "Could not create object {}.".format(
142143
repr(params)))

0 commit comments

Comments
 (0)