From e1ae854faf8e6c249e1174fc2bf2917e4aaeb1d2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 3 Sep 2016 14:59:58 -0400 Subject: [PATCH] Return iterables throughout for consistency. --- CHANGES.rst | 4 ++-- setup.py | 1 - wolframalpha/__init__.py | 5 ++--- wolframalpha/test_client.py | 3 ++- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index bd1f5a2..a08177e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,8 +7,8 @@ * ``Client.query`` now accepts keyword arguments and parameters passed directly to Wolfram|Alpha as URL parameters. -* ``Result.pods`` now returns an iterator and not - a list. +* ``Result.pods`` and ``Pod.subpods`` now returns + an iterator and not a list. * ``Pod`` objects are no longer iterable. To access the subpods of a pod, simply use the ``Pod.subpod`` property. diff --git a/setup.py b/setup.py index 0a10a24..f68239e 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,6 @@ setup_params = dict( install_requires=[ 'six', 'xmltodict', - 'jaraco.functools', ], extras_require={ }, diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py index 452db83..3d3ac63 100644 --- a/wolframalpha/__init__.py +++ b/wolframalpha/__init__.py @@ -3,7 +3,6 @@ import itertools from six.moves import urllib, map import xmltodict -from jaraco.functools import compose from . import compat @@ -122,7 +121,7 @@ class Subpod(Document): Holds a specific answer or additional information relevant to said answer. """ _attr_types = dict( - img=compose(list, Image.from_doc), + img=Image.from_doc, ) @@ -141,7 +140,7 @@ class Pod(ErrorHandler, Document): _attr_types = dict( position=float, numsubpods=int, - subpod=compose(list, Subpod.from_doc), + subpod=Subpod.from_doc, ) def __init__(self, *args, **kwargs): super(Pod, self).__init__(*args, **kwargs) diff --git a/wolframalpha/test_client.py b/wolframalpha/test_client.py index 7889bf1..bd41a83 100644 --- a/wolframalpha/test_client.py +++ b/wolframalpha/test_client.py @@ -71,7 +71,8 @@ def test_pod_attributes(temp_result): pod = next(temp_result.pods) assert isinstance(pod.position, float) assert isinstance(pod.id, six.text_type) - assert isinstance(pod.subpod[0].img[0].height, int) + img = next(next(pod.subpod).img) + assert isinstance(img.height, int) def test_invalid_app_id():