Skip to content

Commit 9c05006

Browse files
committed
doc string formating
1 parent f415427 commit 9c05006

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

reportportal_client/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import collections
12
import json
23
import requests
34
import uuid
@@ -218,7 +219,7 @@ def log_batch(self, log_data):
218219
del log_item["attachment"]
219220

220221
if attachment:
221-
if not isinstance(attachment, dict):
222+
if not isinstance(attachment, collections.Mapping):
222223
attachment = {"data": attachment}
223224

224225
name = attachment.get("name", str(uuid.uuid4()))

reportportal_client/service_async.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ def __init__(self, queue, *handlers):
2121
self._thread = None
2222

2323
def dequeue(self, block=True):
24-
"""
25-
Dequeue a record and return item.
26-
"""
24+
"""Dequeue a record and return item."""
2725
return self.queue.get(block)
2826

2927
def start(self):
30-
"""
31-
Start the listener.
28+
"""Start the listener.
29+
3230
This starts up a background thread to monitor the queue for
3331
items to process.
3432
"""
@@ -37,17 +35,17 @@ def start(self):
3735
t.start()
3836

3937
def prepare(self, record):
40-
"""
41-
Prepare a record for handling.
38+
"""Prepare a record for handling.
39+
4240
This method just returns the passed-in record. You may want to
4341
override this method if you need to do any custom marshalling or
4442
manipulation of the record before passing it to the handlers.
4543
"""
4644
return record
4745

4846
def handle(self, record):
49-
"""
50-
Handle an item.
47+
"""Handle an item.
48+
5149
This just loops through the handlers offering them the record
5250
to handle.
5351
"""
@@ -56,15 +54,15 @@ def handle(self, record):
5654
handler(record)
5755

5856
def _monitor(self):
59-
"""
60-
Monitor the queue for items, and ask the handler
61-
to deal with them.
57+
"""Monitor the queue for items, and ask the handler to deal with them.
58+
6259
This method runs on a separate, internal thread.
6360
The thread will terminate if it sees a sentinel object in the queue.
6461
"""
65-
assert self._stop.isSet() or not self._stop_nowait.isSet(), \
66-
"invalid internal state _stop_nowait can not be set " \
67-
"if _stop is not set"
62+
err_msg = ("invalid internal state:"
63+
" _stop_nowait can not be set if _stop is not set")
64+
assert self._stop.isSet() or not self._stop_nowait.isSet(), err_msg
65+
6866
q = self.queue
6967
has_task_done = hasattr(q, 'task_done')
7068
while not self._stop.isSet():
@@ -92,8 +90,8 @@ def _monitor(self):
9290
break
9391

9492
def stop(self, nowait=False):
95-
"""
96-
Stop the listener.
93+
"""Stop the listener.
94+
9795
This asks the thread to terminate, and then waits for it to do so.
9896
Note that if you don't call this before your application exits, there
9997
may be some records still left on the queue, which won't be processed.
@@ -114,7 +112,8 @@ def stop(self, nowait=False):
114112

115113
class ReportPortalServiceAsync(object):
116114
"""Wrapper around service class to transparently provide async operations
117-
to agents."""
115+
to agents.
116+
"""
118117

119118
def __init__(self, endpoint, project, token, api_base="api/v1",
120119
error_handler=None, log_batch_size=20):
@@ -142,10 +141,11 @@ def __init__(self, endpoint, project, token, api_base="api/v1",
142141
self.listener.start()
143142

144143
def terminate(self, nowait=False):
145-
"""
146-
Finalize and stop service
147-
:param nowait: Set to True to terminate imediately and skip processing
148-
messages still in the queue
144+
"""Finalize and stop service
145+
146+
Args:
147+
nowait: set to True to terminate immediately and skip processing
148+
messages still in the queue
149149
"""
150150
logger.debug("Terminating service")
151151

@@ -175,8 +175,8 @@ def _post_log_batch(self):
175175
self.log_batch = []
176176

177177
def process_log(self, **log_item):
178-
"""
179-
Special handler for log messages.
178+
"""Special handler for log messages.
179+
180180
Accumulate incoming log messages and post them in batch.
181181
"""
182182
logger.debug("Processing log item: %s", log_item)
@@ -185,8 +185,9 @@ def process_log(self, **log_item):
185185
self._post_log_batch()
186186

187187
def process_item(self, item):
188-
"""
189-
Main item handler. Called by queue listener.
188+
"""Main item handler.
189+
190+
Called by queue listener.
190191
"""
191192
logger.debug("Processing item: %s (queue size: %s)", item,
192193
self.queue.qsize())
@@ -256,10 +257,11 @@ def finish_test_item(self, end_time, status, issue=None):
256257

257258
def log(self, time, message, level=None, attachment=None):
258259
"""Logs a message with attachment.
259-
attachment is a dict of:
260-
name: name of attachment
261-
data: file content
262-
mime: content type for attachment
260+
261+
The attachment is a dict of:
262+
name: name of attachment
263+
data: file content
264+
mime: content type for attachment
263265
"""
264266
logger.debug("log queued")
265267

0 commit comments

Comments
 (0)