Skip to content

Commit bb43d72

Browse files
committed
Merge remote-tracking branch 'scrapinghub/master' into six
2 parents 4198d39 + 6354a96 commit bb43d72

13 files changed

+67
-96
lines changed

.readthedocs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
formats: all
3+
sphinx:
4+
configuration: docs/conf.py
5+
fail_on_warning: true
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
# For available versions, see:
10+
# https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
11+
python: "3.10" # Keep in sync with .github/workflows/main.yml
12+
python:
13+
install:
14+
- requirements: docs/requirements.txt
15+
- path: .

docs/client/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ For example, to run a new job for a given spider with custom parameters::
145145

146146

147147
Getting job information
148-
^^^^^^^^^^^^^^^^^^^^^^
148+
^^^^^^^^^^^^^^^^^^^^^^^
149149

150150
To select a specific job for a project, use ``.jobs.get(<jobKey>)``::
151151

docs/conf.py

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
import sys
2020
from datetime import datetime
2121

22-
from docutils import nodes
23-
from sphinx.util.docfields import TypedField
24-
from sphinx import addnodes
25-
2622

2723
sys.path.insert(0, os.path.abspath('..'))
2824

@@ -75,7 +71,7 @@
7571
#
7672
# This is also used if you do content translation via gettext catalogs.
7773
# Usually you set "language" from the command line for these cases.
78-
language = None
74+
language = "en"
7975

8076
# List of patterns, relative to source directory, that match files and
8177
# directories to ignore when looking for source files.
@@ -93,8 +89,7 @@
9389

9490
# The theme to use for HTML and HTML Help pages. See the documentation for
9591
# a list of builtin themes.
96-
#
97-
html_theme = 'alabaster'
92+
html_theme = "sphinx_rtd_theme"
9893

9994
# Theme options are theme-specific and customize the look and feel of a theme
10095
# further. For a list of options available for each theme, see the
@@ -165,49 +160,4 @@
165160
'Miscellaneous'),
166161
]
167162

168-
# Set Sphinx Read The Docs theme
169-
import sphinx_rtd_theme
170-
171163
html_theme = 'sphinx_rtd_theme'
172-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
173-
174-
175-
# disable cross-reference for ivar
176-
# patch taken from http://stackoverflow.com/a/41184353/1932023
177-
def patched_make_field(self, types, domain, items, env=None):
178-
# type: (List, unicode, Tuple) -> nodes.field
179-
def handle_item(fieldarg, content):
180-
par = nodes.paragraph()
181-
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
182-
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
183-
# addnodes.literal_strong))
184-
if fieldarg in types:
185-
par += nodes.Text(' (')
186-
# NOTE: using .pop() here to prevent a single type node to be
187-
# inserted twice into the doctree, which leads to
188-
# inconsistencies later when references are resolved
189-
fieldtype = types.pop(fieldarg)
190-
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
191-
typename = ''.join(n.astext() for n in fieldtype)
192-
par.extend(self.make_xrefs(self.typerolename, domain, typename,
193-
addnodes.literal_emphasis))
194-
else:
195-
par += fieldtype
196-
par += nodes.Text(')')
197-
par += nodes.Text(' -- ')
198-
par += content
199-
return par
200-
201-
fieldname = nodes.field_name('', self.label)
202-
if len(items) == 1 and self.can_collapse:
203-
fieldarg, content = items[0]
204-
bodynode = handle_item(fieldarg, content)
205-
else:
206-
bodynode = self.list_type()
207-
for fieldarg, content in items:
208-
bodynode += nodes.list_item('', handle_item(fieldarg, content))
209-
fieldbody = nodes.field_body('', bodynode)
210-
return nodes.field('', fieldname, fieldbody)
211-
212-
213-
TypedField.make_field = patched_make_field

docs/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Client interface for Scrapinghub API
33
====================================
44

5-
.. image:: https://secure.travis-ci.org/scrapinghub/python-scrapinghub.svg?branch=master
6-
:target: https://travis-ci.org/scrapinghub/python-scrapinghub
7-
85
The ``scrapinghub`` is a Python library for communicating with the `Scrapinghub API`_.
96

107
.. _Scrapinghub API: https://doc.scrapinghub.com/scrapy-cloud.html#scrapycloud

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sphinx==7.2.6
2+
sphinx-rtd-theme==2.0.0

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mock
2-
vcrpy
2+
vcrpy<6 # https://github.com/kevin1024/vcrpy/issues/885
33
pytest
44
pytest-cov
55
responses

scrapinghub/client/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def request(self, *args, **kwargs):
2727

2828

2929
class ScrapinghubClient:
30-
r"""Main class to work with Scrapinghub API.
30+
"""Main class to work with Scrapinghub API.
3131
3232
:param auth: (optional) Scrapinghub APIKEY or other SH auth credentials.
3333
If not provided, it will read, respectively, from
@@ -38,7 +38,7 @@ class ScrapinghubClient:
3838
If you need full access to *Scrapy Cloud* features, you'll need to
3939
provide a Scrapinghub APIKEY through this argument or deploying ``SH_APIKEY``.
4040
:param dash_endpoint: (optional) Scrapinghub Dash panel url.
41-
:param \*\*kwargs: (optional) Additional arguments for
41+
:param kwargs: (optional) Additional arguments for
4242
:class:`~scrapinghub.hubstorage.HubstorageClient` constructor.
4343
4444
:ivar projects: projects collection,

scrapinghub/client/collections.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ def __init__(self, client, collections, type_, name):
154154
self._origin = _Collection(type_, name, collections._origin)
155155

156156
def get(self, key, **params):
157-
r"""Get item from collection by key.
157+
"""Get item from collection by key.
158158
159159
:param key: string item key.
160-
:param \*\*params: (optional) additional query params for the request.
160+
:param params: (optional) additional query params for the request.
161161
:return: an item dictionary if exists.
162162
:rtype: :class:`dict`
163163
"""
@@ -206,15 +206,15 @@ def count(self, *args, **kwargs):
206206

207207
def iter(self, key=None, prefix=None, prefixcount=None, startts=None,
208208
endts=None, requests_params=None, **params):
209-
r"""A method to iterate through collection items.
209+
"""A method to iterate through collection items.
210210
211211
:param key: a string key or a list of keys to filter with.
212212
:param prefix: a string prefix to filter items.
213213
:param prefixcount: maximum number of values to return per prefix.
214214
:param startts: UNIX timestamp at which to begin results.
215215
:param endts: UNIX timestamp at which to end results.
216216
:param requests_params: (optional) a dict with optional requests params.
217-
:param \*\*params: (optional) additional query params for the request.
217+
:param params: (optional) additional query params for the request.
218218
:return: an iterator over items list.
219219
:rtype: :class:`collections.abc.Iterable[dict]`
220220
"""
@@ -227,7 +227,7 @@ def iter(self, key=None, prefix=None, prefixcount=None, startts=None,
227227

228228
def list(self, key=None, prefix=None, prefixcount=None, startts=None,
229229
endts=None, requests_params=None, **params):
230-
r"""Convenient shortcut to list iter results.
230+
"""Convenient shortcut to list iter results.
231231
232232
Please note that :meth:`list` method can use a lot of memory and for a
233233
large amount of logs it's recommended to iterate through it
@@ -240,7 +240,7 @@ def list(self, key=None, prefix=None, prefixcount=None, startts=None,
240240
:param startts: UNIX timestamp at which to begin results.
241241
:param endts: UNIX timestamp at which to end results.
242242
:param requests_params: (optional) a dict with optional requests params.
243-
:param \*\*params: (optional) additional query params for the request.
243+
:param params: (optional) additional query params for the request.
244244
:return: a list of items where each item is represented with a dict.
245245
:rtype: :class:`list[dict]`
246246
"""

scrapinghub/client/frontiers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ def add(self, fps):
314314
writer.write({'fp': fp})
315315

316316
def iter(self, **params):
317-
r"""Iterate through fingerprints in the slot.
317+
"""Iterate through fingerprints in the slot.
318318
319-
:param \*\*params: (optional) additional query params for the request.
319+
:param params: (optional) additional query params for the request.
320320
:return: an iterator over fingerprints.
321321
:rtype: :class:`collections.abc.Iterable[str]`
322322
"""
@@ -326,9 +326,9 @@ def iter(self, **params):
326326
yield fp.get('fp')
327327

328328
def list(self, **params):
329-
r"""List fingerprints in the slot.
329+
"""List fingerprints in the slot.
330330
331-
:param \*\*params: (optional) additional query params for the request.
331+
:param params: (optional) additional query params for the request.
332332
:return: a list of fingerprints.
333333
:rtype: :class:`list[str]`
334334
"""
@@ -349,10 +349,10 @@ def add(self, fps):
349349
return origin.add(self._frontier.key, self.key, fps)
350350

351351
def iter(self, mincount=None, **params):
352-
r"""Iterate through batches in the queue.
352+
"""Iterate through batches in the queue.
353353
354354
:param mincount: (optional) limit results with min amount of requests.
355-
:param \*\*params: (optional) additional query params for the request.
355+
:param params: (optional) additional query params for the request.
356356
:return: an iterator over request batches in the queue where each
357357
batch is represented with a dict with ('id', 'requests') field.
358358
:rtype: :class:`collections.abc.Iterable[dict]`
@@ -363,10 +363,10 @@ def iter(self, mincount=None, **params):
363363
return origin.apiget(path, params=params)
364364

365365
def list(self, mincount=None, **params):
366-
r"""List request batches in the queue.
366+
"""List request batches in the queue.
367367
368368
:param mincount: (optional) limit results with min amount of requests.
369-
:param \*\*params: (optional) additional query params for the request.
369+
:param params: (optional) additional query params for the request.
370370
:return: a list of request batches in the queue where each batch
371371
is represented with a dict with ('id', 'requests') field.
372372
:rtype: :class:`list[dict]`

scrapinghub/client/jobs.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, client, project_id, spider=None):
4343

4444
def count(self, spider=None, state=None, has_tag=None, lacks_tag=None,
4545
startts=None, endts=None, **params):
46-
r"""Count jobs with a given set of filters.
46+
"""Count jobs with a given set of filters.
4747
4848
:param spider: (optional) filter by spider name.
4949
:param state: (optional) a job state, a string or a list of strings.
@@ -55,7 +55,7 @@ def count(self, spider=None, state=None, has_tag=None, lacks_tag=None,
5555
in milliseconds.
5656
:param endts: (optional) UNIX timestamp at which to end results,
5757
in milliseconds.
58-
:param \*\*params: (optional) other filter params.
58+
:param params: (optional) other filter params.
5959
6060
:return: jobs count.
6161
:rtype: :class:`int`
@@ -138,7 +138,7 @@ def cancel(self, keys=None, count=None, **params):
138138
def iter(self, count=None, start=None, spider=None, state=None,
139139
has_tag=None, lacks_tag=None, startts=None, endts=None,
140140
meta=None, **params):
141-
r"""Iterate over jobs collection for a given set of params.
141+
"""Iterate over jobs collection for a given set of params.
142142
143143
:param count: (optional) limit amount of returned jobs.
144144
:param start: (optional) number of jobs to skip in the beginning.
@@ -154,7 +154,7 @@ def iter(self, count=None, start=None, spider=None, state=None,
154154
in millisecons.
155155
:param meta: (optional) request for additional fields, a single
156156
field name or a list of field names to return.
157-
:param \*\*params: (optional) other filter params.
157+
:param params: (optional) other filter params.
158158
159159
:return: a generator object over a list of dictionaries of jobs summary
160160
for a given filter params.
@@ -209,7 +209,7 @@ def iter(self, count=None, start=None, spider=None, state=None,
209209
def list(self, count=None, start=None, spider=None, state=None,
210210
has_tag=None, lacks_tag=None, startts=None, endts=None,
211211
meta=None, **params):
212-
r"""Convenient shortcut to list iter results.
212+
"""Convenient shortcut to list iter results.
213213
214214
:param count: (optional) limit amount of returned jobs.
215215
:param start: (optional) number of jobs to skip in the beginning.
@@ -225,7 +225,7 @@ def list(self, count=None, start=None, spider=None, state=None,
225225
in milliseconds.
226226
:param meta: (optional) request for additional fields, a single
227227
field name or a list of field names to return.
228-
:param \*\*params: (optional) other filter params.
228+
:param params: (optional) other filter params.
229229
230230
:return: list of dictionaries of jobs summary for a given filter params.
231231
:rtype: :class:`list[dict]`
@@ -248,7 +248,7 @@ def list(self, count=None, start=None, spider=None, state=None,
248248
def run(self, spider=None, units=None, priority=None, meta=None,
249249
add_tag=None, job_args=None, job_settings=None, cmd_args=None,
250250
environment=None, **params):
251-
r"""Schedule a new job and returns its job key.
251+
"""Schedule a new job and returns its job key.
252252
253253
:param spider: a spider name string
254254
(not needed if job is scheduled via :attr:`Spider.jobs`).
@@ -260,7 +260,7 @@ def run(self, spider=None, units=None, priority=None, meta=None,
260260
:param job_settings: (optional) a dictionary with job settings.
261261
:param cmd_args: (optional) a string with script command args.
262262
:param environment: (option) a dictionary with custom environment
263-
:param \*\*params: (optional) additional keyword args.
263+
:param params: (optional) additional keyword args.
264264
265265
:return: a job instance, representing the scheduled job.
266266
:rtype: :class:`Job`
@@ -327,12 +327,12 @@ def get(self, job_key):
327327
return Job(self._client, str(job_key))
328328

329329
def summary(self, state=None, spider=None, **params):
330-
r"""Get jobs summary (optionally by state).
330+
"""Get jobs summary (optionally by state).
331331
332332
:param state: (optional) a string state to filter jobs.
333333
:param spider: (optional) a spider name (not needed if instantiated
334334
with :class:`~scrapinghub.client.spiders.Spider`).
335-
:param \*\*params: (optional) additional keyword args.
335+
:param params: (optional) additional keyword args.
336336
:return: a list of dictionaries of jobs summary
337337
for a given filter params grouped by job state.
338338
:rtype: :class:`list[dict]`
@@ -353,14 +353,14 @@ def summary(self, state=None, spider=None, **params):
353353

354354
def iter_last(self, start=None, start_after=None, count=None,
355355
spider=None, **params):
356-
r"""Iterate through last jobs for each spider.
356+
"""Iterate through last jobs for each spider.
357357
358358
:param start: (optional)
359359
:param start_after: (optional)
360360
:param count: (optional)
361361
:param spider: (optional) a spider name (not needed if instantiated
362362
with :class:`~scrapinghub.client.spiders.Spider`).
363-
:param \*\*params: (optional) additional keyword args.
363+
:param params: (optional) additional keyword args.
364364
:return: a generator object over a list of dictionaries of jobs summary
365365
for a given filter params.
366366
:rtype: :class:`types.GeneratorType[dict]`
@@ -508,9 +508,9 @@ def close_writers(self):
508508
self._job.close_writers()
509509

510510
def start(self, **params):
511-
r"""Move job to running state.
511+
"""Move job to running state.
512512
513-
:param \*\*params: (optional) keyword meta parameters to update.
513+
:param params: (optional) keyword meta parameters to update.
514514
:return: a previous string job state.
515515
:rtype: :class:`str`
516516
@@ -522,9 +522,9 @@ def start(self, **params):
522522
return self.update(state='running', **params)
523523

524524
def finish(self, **params):
525-
r"""Move running job to finished state.
525+
"""Move running job to finished state.
526526
527-
:param \*\*params: (optional) keyword meta parameters to update.
527+
:param params: (optional) keyword meta parameters to update.
528528
:return: a previous string job state.
529529
:rtype: :class:`str`
530530
@@ -536,9 +536,9 @@ def finish(self, **params):
536536
return self.update(state='finished', **params)
537537

538538
def delete(self, **params):
539-
r"""Mark finished job for deletion.
539+
"""Mark finished job for deletion.
540540
541-
:param \*\*params: (optional) keyword meta parameters to update.
541+
:param params: (optional) keyword meta parameters to update.
542542
:return: a previous string job state.
543543
:rtype: :class:`str`
544544
@@ -550,10 +550,10 @@ def delete(self, **params):
550550
return self.update(state='deleted', **params)
551551

552552
def update(self, state, **params):
553-
r"""Update job state.
553+
"""Update job state.
554554
555555
:param state: a new job state.
556-
:param \*\*params: (optional) keyword meta parameters to update.
556+
:param params: (optional) keyword meta parameters to update.
557557
:return: a previous string job state.
558558
:rtype: :class:`str`
559559

0 commit comments

Comments
 (0)