Skip to content

Commit d9b6d29

Browse files
committed
Provide missing docstrings
1 parent 2ff6b29 commit d9b6d29

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

scrapinghub/client/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ServerError(ScrapinghubAPIError):
5757

5858

5959
def wrap_http_errors(method):
60+
"""Internal helper to handle exceptions gracefully."""
6061
@wraps(method)
6162
def wrapped(*args, **kwargs):
6263
try:
@@ -93,6 +94,7 @@ def wrapped(*args, **kwargs):
9394

9495

9596
def wrap_value_too_large(method):
97+
"""Internal wrapper for ValueTooLarge exception."""
9698
@wraps(method)
9799
def wrapped(*args, **kwargs):
98100
try:

scrapinghub/client/frontiers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _get_writer(self, frontier, slot):
4141
return writer
4242

4343
def _writer_callback(self, key, response):
44+
"""Writer callback function when new batch is added."""
4445
self.newcount[key] += response.json()["newcount"]
4546

4647

@@ -305,6 +306,10 @@ def __init__(self, slot):
305306
self._slot = slot
306307

307308
def add(self, fps):
309+
"""Add new fingerprints to slot.
310+
311+
:param fps: a list of string fingerprints to add.
312+
"""
308313
origin = self._frontier._frontiers._origin
309314
writer = origin._get_writer(self._frontier.key, self.key)
310315
fps = list(fps) if not isinstance(fps, list) else fps

scrapinghub/client/projects.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,10 @@ class Settings(_MappingProxy):
174174
>>> project.settings.delete('job_runtime_limit')
175175
"""
176176
def set(self, key, value):
177+
"""Update project setting value by key.
178+
179+
:param key: a string setting key.
180+
:param value: new setting value.
181+
"""
177182
# FIXME drop the method when post-by-key is implemented on server side
178183
self.update({key: value})

scrapinghub/client/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def __str__(self):
3636

3737

3838
def parse_project_id(project_id):
39+
"""Simple check for project id.
40+
41+
:param project_id: a numeric project id, int or string.
42+
:return: a unified project id.
43+
:rtype: :class:`str`
44+
"""
3945
try:
4046
int(project_id)
4147
except ValueError:
@@ -44,6 +50,12 @@ def parse_project_id(project_id):
4450

4551

4652
def parse_job_key(job_key):
53+
"""Inner helper to parse job key.
54+
55+
:param job_key: a job key (str or tuple of 3 ints).
56+
:return: parsed job key.
57+
:rtype: :class:`JobKey`
58+
"""
4759
if isinstance(job_key, tuple):
4860
parts = job_key
4961
elif isinstance(job_key, six.string_types):
@@ -239,6 +251,7 @@ def format_iter_filters(params):
239251

240252

241253
def update_kwargs(kwargs, **params):
254+
"""Update kwargs dict with non-empty params with json-encoded values."""
242255
kwargs.update({k: json.dumps(v) if isinstance(v, dict) else v
243256
for k, v in params.items() if v is not None})
244257

0 commit comments

Comments
 (0)