Python 3 Support using six.iteritems() function.
modified: README.rst modified: nested_lookup.py new file: requirements.txt modified: setup.py
This commit is contained in:
parent
0e4c30b4fb
commit
c50bc0b355
4 changed files with 13 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
nested_lookup
|
nested_lookup
|
||||||
#############
|
#############
|
||||||
|
|
||||||
.. image:: https://img.shields.io/badge/pypi-0.0.2-green.svg
|
.. image:: https://img.shields.io/badge/pypi-0.0.3-green.svg
|
||||||
:target: https://pypi.python.org/pypi/nested-lookup
|
:target: https://pypi.python.org/pypi/nested-lookup
|
||||||
|
|
||||||
.. image:: https://img.shields.io/badge/coverage-100%-green.svg
|
.. image:: https://img.shields.io/badge/coverage-100%-green.svg
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
from six import iteritems
|
||||||
|
|
||||||
def nested_lookup(key, document):
|
def nested_lookup(key, document):
|
||||||
"""Lookup a key in a nested document, return a list of values"""
|
"""Lookup a key in a nested document, return a list of values"""
|
||||||
return list(_nested_lookup(key, document))
|
return list(_nested_lookup(key, document))
|
||||||
|
|
@ -10,7 +12,7 @@ def _nested_lookup(key, document):
|
||||||
yield result
|
yield result
|
||||||
|
|
||||||
if isinstance(document, dict):
|
if isinstance(document, dict):
|
||||||
for k, v in document.items():
|
for k, v in iteritems(document):
|
||||||
if k == key:
|
if k == key:
|
||||||
yield v
|
yield v
|
||||||
elif isinstance(v, dict):
|
elif isinstance(v, dict):
|
||||||
|
|
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# https://pythonhosted.org/six/#six.iteritems
|
||||||
|
six
|
||||||
8
setup.py
8
setup.py
|
|
@ -2,9 +2,14 @@
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
from pip.req import parse_requirements
|
||||||
|
|
||||||
|
# get list of requirement strings from requirements.txt
|
||||||
|
requires = map(lambda ir : str(ir.req), parse_requirements('requirements.txt'))
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = 'nested-lookup',
|
name = 'nested-lookup',
|
||||||
version = '0.0.2',
|
version = '0.0.3',
|
||||||
description = 'lookup a key in a deeply nested document of dicts and lists',
|
description = 'lookup a key in a deeply nested document of dicts and lists',
|
||||||
keywords = 'nested document dictionary dict list lookup schema json xml yaml',
|
keywords = 'nested document dictionary dict list lookup schema json xml yaml',
|
||||||
long_description = open('README.rst').read(),
|
long_description = open('README.rst').read(),
|
||||||
|
|
@ -18,6 +23,7 @@ setup(
|
||||||
|
|
||||||
py_modules = ['nested_lookup'],
|
py_modules = ['nested_lookup'],
|
||||||
include_package_data = True,
|
include_package_data = True,
|
||||||
|
install_requires = requires,
|
||||||
)
|
)
|
||||||
|
|
||||||
# setup keyword args: http://peak.telecommunity.com/DevCenter/setuptools
|
# setup keyword args: http://peak.telecommunity.com/DevCenter/setuptools
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue