Skip to content

Commit 2e1bc44

Browse files
committed
Merge remote-tracking branch 'scrapinghub/master' into dynamic-endpoints
2 parents 2ae756a + 6354a96 commit 2e1bc44

13 files changed

+48
-73
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 & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
import sys
2121
from datetime import datetime
2222

23-
from docutils import nodes
24-
from sphinx.util.docfields import TypedField
25-
from sphinx import addnodes
26-
2723

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

@@ -76,7 +72,7 @@
7672
#
7773
# This is also used if you do content translation via gettext catalogs.
7874
# Usually you set "language" from the command line for these cases.
79-
language = None
75+
language = "en"
8076

8177
# List of patterns, relative to source directory, that match files and
8278
# directories to ignore when looking for source files.
@@ -94,8 +90,7 @@
9490

9591
# The theme to use for HTML and HTML Help pages. See the documentation for
9692
# a list of builtin themes.
97-
#
98-
html_theme = 'alabaster'
93+
html_theme = "sphinx_rtd_theme"
9994

10095
# Theme options are theme-specific and customize the look and feel of a theme
10196
# further. For a list of options available for each theme, see the
@@ -171,44 +166,3 @@
171166

172167
html_theme = 'sphinx_rtd_theme'
173168
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
174-
175-
176-
# disable cross-reference for ivar
177-
# patch taken from http://stackoverflow.com/a/41184353/1932023
178-
def patched_make_field(self, types, domain, items, env=None):
179-
# type: (List, unicode, Tuple) -> nodes.field
180-
def handle_item(fieldarg, content):
181-
par = nodes.paragraph()
182-
par += addnodes.literal_strong('', fieldarg) # Patch: this line added
183-
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
184-
# addnodes.literal_strong))
185-
if fieldarg in types:
186-
par += nodes.Text(' (')
187-
# NOTE: using .pop() here to prevent a single type node to be
188-
# inserted twice into the doctree, which leads to
189-
# inconsistencies later when references are resolved
190-
fieldtype = types.pop(fieldarg)
191-
if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text):
192-
typename = u''.join(n.astext() for n in fieldtype)
193-
par.extend(self.make_xrefs(self.typerolename, domain, typename,
194-
addnodes.literal_emphasis))
195-
else:
196-
par += fieldtype
197-
par += nodes.Text(')')
198-
par += nodes.Text(' -- ')
199-
par += content
200-
return par
201-
202-
fieldname = nodes.field_name('', self.label)
203-
if len(items) == 1 and self.can_collapse:
204-
fieldarg, content = items[0]
205-
bodynode = handle_item(fieldarg, content)
206-
else:
207-
bodynode = self.list_type()
208-
for fieldarg, content in items:
209-
bodynode += nodes.list_item('', handle_item(fieldarg, content))
210-
fieldbody = nodes.field_body('', bodynode)
211-
return nodes.field('', fieldname, fieldbody)
212-
213-
214-
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ScrapinghubClient(object):
4141
:param dash_endpoint: (optional) Scrapy Cloud API URL.
4242
If not provided, it will be read from the ``SHUB_APIURL`` environment
4343
variable, or fall back to ``"https://app.zyte.com/api/"``.
44-
:param \*\*kwargs: (optional) Additional arguments for
44+
:param kwargs: (optional) Additional arguments for
4545
:class:`~scrapinghub.hubstorage.HubstorageClient` constructor.
4646
4747
:ivar projects: projects collection,

scrapinghub/client/collections.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def get(self, key, **params):
160160
"""Get item from collection by key.
161161
162162
:param key: string item key.
163-
:param \*\*params: (optional) additional query params for the request.
163+
:param params: (optional) additional query params for the request.
164164
:return: an item dictionary if exists.
165165
:rtype: :class:`dict`
166166
"""
@@ -217,7 +217,7 @@ def iter(self, key=None, prefix=None, prefixcount=None, startts=None,
217217
:param startts: UNIX timestamp at which to begin results.
218218
:param endts: UNIX timestamp at which to end results.
219219
:param requests_params: (optional) a dict with optional requests params.
220-
:param \*\*params: (optional) additional query params for the request.
220+
:param params: (optional) additional query params for the request.
221221
:return: an iterator over items list.
222222
:rtype: :class:`collections.abc.Iterable[dict]`
223223
"""
@@ -243,7 +243,7 @@ def list(self, key=None, prefix=None, prefixcount=None, startts=None,
243243
:param startts: UNIX timestamp at which to begin results.
244244
:param endts: UNIX timestamp at which to end results.
245245
:param requests_params: (optional) a dict with optional requests params.
246-
:param \*\*params: (optional) additional query params for the request.
246+
:param params: (optional) additional query params for the request.
247247
:return: a list of items where each item is represented with a dict.
248248
:rtype: :class:`list[dict]`
249249
"""

scrapinghub/client/frontiers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def add(self, fps):
319319
def iter(self, **params):
320320
"""Iterate through fingerprints in the slot.
321321
322-
:param \*\*params: (optional) additional query params for the request.
322+
:param params: (optional) additional query params for the request.
323323
:return: an iterator over fingerprints.
324324
:rtype: :class:`collections.abc.Iterable[str]`
325325
"""
@@ -331,7 +331,7 @@ def iter(self, **params):
331331
def list(self, **params):
332332
"""List fingerprints in the slot.
333333
334-
:param \*\*params: (optional) additional query params for the request.
334+
:param params: (optional) additional query params for the request.
335335
:return: a list of fingerprints.
336336
:rtype: :class:`list[str]`
337337
"""
@@ -355,7 +355,7 @@ def iter(self, mincount=None, **params):
355355
"""Iterate through batches in the queue.
356356
357357
:param mincount: (optional) limit results with min amount of requests.
358-
:param \*\*params: (optional) additional query params for the request.
358+
:param params: (optional) additional query params for the request.
359359
:return: an iterator over request batches in the queue where each
360360
batch is represented with a dict with ('id', 'requests') field.
361361
:rtype: :class:`collections.abc.Iterable[dict]`
@@ -369,7 +369,7 @@ def list(self, mincount=None, **params):
369369
"""List request batches in the queue.
370370
371371
:param mincount: (optional) limit results with min amount of requests.
372-
:param \*\*params: (optional) additional query params for the request.
372+
:param params: (optional) additional query params for the request.
373373
:return: a list of request batches in the queue where each batch
374374
is represented with a dict with ('id', 'requests') field.
375375
:rtype: :class:`list[dict]`

scrapinghub/client/jobs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def count(self, spider=None, state=None, has_tag=None, lacks_tag=None,
5757
in milliseconds.
5858
:param endts: (optional) UNIX timestamp at which to end results,
5959
in milliseconds.
60-
:param \*\*params: (optional) other filter params.
60+
:param params: (optional) other filter params.
6161
6262
:return: jobs count.
6363
:rtype: :class:`int`
@@ -156,7 +156,7 @@ def iter(self, count=None, start=None, spider=None, state=None,
156156
in millisecons.
157157
:param meta: (optional) request for additional fields, a single
158158
field name or a list of field names to return.
159-
:param \*\*params: (optional) other filter params.
159+
:param params: (optional) other filter params.
160160
161161
:return: a generator object over a list of dictionaries of jobs summary
162162
for a given filter params.
@@ -227,7 +227,7 @@ def list(self, count=None, start=None, spider=None, state=None,
227227
in milliseconds.
228228
:param meta: (optional) request for additional fields, a single
229229
field name or a list of field names to return.
230-
:param \*\*params: (optional) other filter params.
230+
:param params: (optional) other filter params.
231231
232232
:return: list of dictionaries of jobs summary for a given filter params.
233233
:rtype: :class:`list[dict]`
@@ -262,7 +262,7 @@ def run(self, spider=None, units=None, priority=None, meta=None,
262262
:param job_settings: (optional) a dictionary with job settings.
263263
:param cmd_args: (optional) a string with script command args.
264264
:param environment: (option) a dictionary with custom environment
265-
:param \*\*params: (optional) additional keyword args.
265+
:param params: (optional) additional keyword args.
266266
267267
:return: a job instance, representing the scheduled job.
268268
:rtype: :class:`Job`
@@ -334,7 +334,7 @@ def summary(self, state=None, spider=None, **params):
334334
:param state: (optional) a string state to filter jobs.
335335
:param spider: (optional) a spider name (not needed if instantiated
336336
with :class:`~scrapinghub.client.spiders.Spider`).
337-
:param \*\*params: (optional) additional keyword args.
337+
:param params: (optional) additional keyword args.
338338
:return: a list of dictionaries of jobs summary
339339
for a given filter params grouped by job state.
340340
:rtype: :class:`list[dict]`
@@ -362,7 +362,7 @@ def iter_last(self, start=None, start_after=None, count=None,
362362
:param count: (optional)
363363
:param spider: (optional) a spider name (not needed if instantiated
364364
with :class:`~scrapinghub.client.spiders.Spider`).
365-
:param \*\*params: (optional) additional keyword args.
365+
:param params: (optional) additional keyword args.
366366
:return: a generator object over a list of dictionaries of jobs summary
367367
for a given filter params.
368368
:rtype: :class:`types.GeneratorType[dict]`
@@ -512,7 +512,7 @@ def close_writers(self):
512512
def start(self, **params):
513513
"""Move job to running state.
514514
515-
:param \*\*params: (optional) keyword meta parameters to update.
515+
:param params: (optional) keyword meta parameters to update.
516516
:return: a previous string job state.
517517
:rtype: :class:`str`
518518
@@ -526,7 +526,7 @@ def start(self, **params):
526526
def finish(self, **params):
527527
"""Move running job to finished state.
528528
529-
:param \*\*params: (optional) keyword meta parameters to update.
529+
:param params: (optional) keyword meta parameters to update.
530530
:return: a previous string job state.
531531
:rtype: :class:`str`
532532
@@ -540,7 +540,7 @@ def finish(self, **params):
540540
def delete(self, **params):
541541
"""Mark finished job for deletion.
542542
543-
:param \*\*params: (optional) keyword meta parameters to update.
543+
:param params: (optional) keyword meta parameters to update.
544544
:return: a previous string job state.
545545
:rtype: :class:`str`
546546
@@ -555,7 +555,7 @@ def update(self, state, **params):
555555
"""Update job state.
556556
557557
:param state: a new job state.
558-
:param \*\*params: (optional) keyword meta parameters to update.
558+
:param params: (optional) keyword meta parameters to update.
559559
:return: a previous string job state.
560560
:rtype: :class:`str`
561561

scrapinghub/client/logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def log(self, message, level=logging.INFO, ts=None, **other):
5555
:param message: a string message.
5656
:param level: (optional) logging level, default to INFO.
5757
:param ts: (optional) UNIX timestamp in milliseconds.
58-
:param \*\*other: other optional kwargs.
58+
:param other: other optional kwargs.
5959
"""
6060
self._origin.log(message, level=level, ts=ts, **other)
6161

scrapinghub/hubstorage/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(self, auth=None, endpoint=None, connection_timeout=None,
9292
self.use_msgpack = MSGPACK_AVAILABLE and use_msgpack
9393
if use_msgpack != self.use_msgpack:
9494
logger.warning('Messagepack is not available, please ensure that '
95-
'msgpack-python library is properly installed.')
95+
'msgpack library is properly installed.')
9696

9797
def request(self, is_idempotent=False, **kwargs):
9898
"""

tox.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ deps =
1313
msgpack: -r{toxinidir}/requirements.txt
1414
pypy-msgpack: -r{toxinidir}/requirements-pypy.txt
1515
commands = py.test --cov=scrapinghub --cov-report=xml {posargs: scrapinghub tests}
16+
17+
[testenv:docs]
18+
changedir = docs
19+
deps =
20+
-r docs/requirements.txt
21+
commands =
22+
sphinx-build -W -b html . {envtmpdir}/html

0 commit comments

Comments
 (0)