Skip to content

Commit f97e81f

Browse files
committed
Minor fixes in docstrings/documentation
1 parent d231d29 commit f97e81f

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

README.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ List all slots::
446446

447447
Get a frontier slot by name::
448448

449-
>>> frontier.get('example.com')
449+
>>> slot = frontier.get('example.com')
450+
>>> slot
450451
<scrapinghub.client.FrontierSlot at 0x1049d8978>
451452

452453
Add a request to the slot::
@@ -466,13 +467,17 @@ Add requests with additional parameters::
466467
>>> slot.q.add([{'fp': '/'}, {'fp': 'page1.html', 'p': 1, 'qdata': {'depth': 1}}])
467468
>>> slot.flush()
468469

469-
To list requests for a given slot::
470+
To retrieve all requests for a given slot::
470471

471-
>>> reqs = slot.q.list()
472+
>>> reqs = slot.q.iter()
472473

473-
To retrieve fingerprints for a given slot::
474+
To retrieve all fingerprints for a given slot::
475+
476+
>>> fps = slot.f.iter()
477+
478+
To list all the requests use ``list()`` method (similar for ``fingerprints``)::
474479

475-
>>> fps = [req['requests'] for req in slot.q.iter()]
480+
>>> fps = slot.q.list()
476481

477482
To delete a batch of requests::
478483

scrapinghub/client.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,9 @@ class FrontierSlot(object):
11581158
>>> data = [{'fp': 'page1.html', 'p': 1, 'qdata': {'depth': 1}}]
11591159
>>> slot.q.add('example.com', data)
11601160
1161+
- add fingerprints to a slot
1162+
>>> slot.f.add(['fp1', 'fp2'])
1163+
11611164
- flush data for a slot
11621165
>>> slot.flush()
11631166
@@ -1168,6 +1171,12 @@ class FrontierSlot(object):
11681171
[{'id': '0115a8579633600006',
11691172
'requests': [['page1.html', {'depth': 1}]]}]
11701173
1174+
- read fingerprints from a slot
1175+
>>> slot.f.iter()
1176+
<generator object jldecode at 0x103de4938>
1177+
>>> slot.f.list()
1178+
['page1.html']
1179+
11711180
- delete a batch with requests from a slot
11721181
>>> slot.q.delete('0115a8579633600006')
11731182
@@ -1220,14 +1229,14 @@ def add(self, fps):
12201229
writer.write({'fp': fp})
12211230

12221231
def iter(self, **kwargs):
1223-
"""Iterate through fingerprints."""
1232+
"""Iterate through fingerprints in the slot."""
12241233
origin = self._frontier._frontiers._origin
12251234
path = (self._frontier.key, 's', self.key, 'f')
12261235
for fp in origin.apiget(path, params=kwargs):
12271236
yield fp.get('fp')
12281237

12291238
def list(self, **kwargs):
1230-
"""List fingerprints in slot."""
1239+
"""List fingerprints in the slot."""
12311240
return list(self.iter(**kwargs))
12321241

12331242

@@ -1239,22 +1248,22 @@ def __init__(self, slot):
12391248
self._slot = slot
12401249

12411250
def add(self, fps):
1242-
"""Add requests to slot."""
1251+
"""Add requests to the queue."""
12431252
origin = self._frontier._frontiers._origin
12441253
return origin.add(self._frontier.key, self.key, fps)
12451254

12461255
def iter(self, **kwargs):
1247-
"""Iterate through batches in queue."""
1256+
"""Iterate through batches in the queue."""
12481257
origin = self._frontier._frontiers._origin
12491258
path = (self._frontier.key, 's', self.key, 'q')
12501259
return origin.apiget(path, params=kwargs)
12511260

12521261
def list(self, **kwargs):
1253-
"""List request batches in slot."""
1262+
"""List request batches in the queue."""
12541263
return list(self.iter(**kwargs))
12551264

12561265
def delete(self, ids):
1257-
"""Delete request batches from slot."""
1266+
"""Delete request batches from the queue."""
12581267
origin = self._frontier._frontiers._origin
12591268
return origin.delete(self._frontier.key, self.key, ids)
12601269

0 commit comments

Comments
 (0)