Corrected formatting of README.rst
This commit is contained in:
parent
3b1f2ced67
commit
ef45cadb16
1 changed files with 50 additions and 50 deletions
100
README.rst
100
README.rst
|
|
@ -43,72 +43,72 @@ tutorial
|
||||||
[42, 69]
|
[42, 69]
|
||||||
|
|
||||||
|
|
||||||
wild
|
wild
|
||||||
========
|
========
|
||||||
|
|
||||||
We also have a `wild` mode that treats the given `key` as a case insensitive
|
We also have a `wild` mode that treats the given `key` as a case insensitive
|
||||||
substring of all the keys in the document and returns any values which match.
|
substring of all the keys in the document and returns any values which match.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from nested_lookup import nested_lookup
|
from nested_lookup import nested_lookup
|
||||||
|
|
||||||
my_document = {
|
my_document = {
|
||||||
'name' : 'Russell Ballestrini',
|
'name' : 'Russell Ballestrini',
|
||||||
'email_address' : 'test1@example.com',
|
'email_address' : 'test1@example.com',
|
||||||
'other' : {
|
'other' : {
|
||||||
'secondary_email' : 'test2@example.com',
|
'secondary_email' : 'test2@example.com',
|
||||||
'EMAIL_RECOVERY' : 'test3@example.com',
|
'EMAIL_RECOVERY' : 'test3@example.com',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
results = nested_lookup(
|
results = nested_lookup(
|
||||||
key = 'mail',
|
key = 'mail',
|
||||||
document = my_document,
|
document = my_document,
|
||||||
wild = True
|
wild = True
|
||||||
)
|
)
|
||||||
|
|
||||||
print(results)
|
print(results)
|
||||||
['test1@example.com', 'test2@example.com', 'test3@example.com']
|
['test1@example.com', 'test2@example.com', 'test3@example.com']
|
||||||
|
|
||||||
|
|
||||||
output
|
output
|
||||||
========
|
========
|
||||||
|
|
||||||
There are two `output` modes:
|
There are two `output` modes:
|
||||||
- `list`: the function returns a list of values corresponding to the
|
- `list`: the function returns a list of values corresponding to the
|
||||||
matched keys.
|
matched keys.
|
||||||
- `dict`: the function returns a `dict` with the matched keys as keys and
|
- `dict`: the function returns a `dict` with the matched keys as keys and
|
||||||
their corresponding values as values.
|
their corresponding values as values.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from nested_lookup import nested_lookup
|
from nested_lookup import nested_lookup
|
||||||
|
|
||||||
my_document = {
|
my_document = {
|
||||||
'name' : 'Russell Ballestrini',
|
'name' : 'Russell Ballestrini',
|
||||||
'email_address' : 'test1@example.com',
|
'email_address' : 'test1@example.com',
|
||||||
'other' : {
|
'other' : {
|
||||||
'secondary_email' : 'test2@example.com',
|
'secondary_email' : 'test2@example.com',
|
||||||
'EMAIL_RECOVERY' : 'test3@example.com',
|
'EMAIL_RECOVERY' : 'test3@example.com',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
results = nested_lookup(
|
results = nested_lookup(
|
||||||
key = 'mail',
|
key = 'mail',
|
||||||
document = my_document,
|
document = my_document,
|
||||||
wild = True,
|
wild = True,
|
||||||
output = 'dict'
|
output = 'dict'
|
||||||
)
|
)
|
||||||
|
|
||||||
print(results)
|
print(results)
|
||||||
{'email_address': 'test1@example.com',
|
{'email_address': 'test1@example.com',
|
||||||
'secondary_email': 'test2@example.com',
|
'secondary_email': 'test2@example.com',
|
||||||
'EMAIL_RECOVERY': 'test3@example.com'}
|
'EMAIL_RECOVERY': 'test3@example.com'}
|
||||||
|
|
||||||
|
|
||||||
misc
|
misc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue