|
15 | 15 |
|
16 | 16 |
|
17 | 17 | def find(object_list, filter_func=None, **kwargs): |
18 | | - """Return the objects from ``object_list`` that satisfy the filters. |
| 18 | + """Filter :class:`civis.response.Response` objects. |
19 | 19 |
|
20 | 20 | Parameters |
21 | 21 | ---------- |
22 | 22 | object_list : iterable |
23 | | - An iterable of arbitrary objects, particularly those with |
24 | | - attributes that can be targeted by the filters in ``kwargs``. |
25 | | - A major use case is a list of ``civis.response.Response`` objects. |
| 23 | + An iterable of arbitrary objects, particularly those with attributes |
| 24 | + that can be targeted by the filters in `kwargs`. A major use case is |
| 25 | + an iterable of :class:`civis.response.Response` objects. |
26 | 26 | filter_func : callable, optional |
27 | | - A one-argument function. If specified, ``kwargs`` are ignored. |
28 | | - An ``object`` from the input iterable is kept in the returned list |
| 27 | + A one-argument function. If specified, `kwargs` are ignored. |
| 28 | + An `object` from the input iterable is kept in the returned list |
29 | 29 | if and only if ``bool(filter_func(object))`` is ``True``. |
30 | 30 | **kwargs |
31 | 31 | Key-value pairs for more fine-grained filtering; they cannot be used |
32 | | - in conjunction with ``filter_func``. All keys must be strings. |
33 | | - For an ``object`` from the input iterable to be included in the |
34 | | - returned list, all the ``key``s must be attributes of ``object``, plus |
35 | | - any one of the following conditions for a given ``key``: |
36 | | - - ``value`` is a one-argument function and |
| 32 | + in conjunction with `filter_func`. All keys must be strings. |
| 33 | + For an `object` from the input iterable to be included in the |
| 34 | + returned list, all the `key`s must be attributes of `object`, plus |
| 35 | + any one of the following conditions for a given `key`: |
| 36 | +
|
| 37 | + - `value` is a one-argument function and |
37 | 38 | ``bool(value(getattr(object, key)))`` is ``True`` |
38 | | - - ``value`` is ``True`` |
| 39 | + - `value` is ``True`` |
39 | 40 | - ``getattr(object, key)`` is equal to ``value`` |
40 | 41 |
|
41 | 42 | Returns |
@@ -78,9 +79,12 @@ def default_filter(o): |
78 | 79 |
|
79 | 80 |
|
80 | 81 | def find_one(object_list, filter_func=None, **kwargs): |
81 | | - """Return one object (or ``None``) from ``civis.find``. |
| 82 | + """Return one satisfying :class:`civis.response.Response` object. |
82 | 83 |
|
83 | | - The arguments are the same as those for ``civis.find``. |
| 84 | + The arguments are the same as those for :func:`civis.find`. |
| 85 | + If more than one object satisfies the filtering criteria, |
| 86 | + the first one is returned. |
| 87 | + If no satisfying objects are found, ``None`` is returned. |
84 | 88 |
|
85 | 89 | Returns |
86 | 90 | ------- |
|
0 commit comments