Grouped Pod and Subpod classes.

master
Isaac Smith 8 years ago
parent 13c2f7700d
commit 7d3453ec9a
  1. 26
      wolframalpha/__init__.py

@ -127,6 +127,19 @@ class Pod(object):
''' Simply get the text from each subpod in this pod and return it in a list. '''
return [subpod.text for subpod in self.subpods]
class Subpod(object):
''' Holds a specific answer or additional information relevant to said answer. '''
def __init__(self, node):
self.node = node
self.title = node['@title']
self.text = node['plaintext']
self.img = node['img']
# Allow images to be accessed in a consistent way,
# as a list, regardless of how many there are.
if type(self.img) != list:
self.img = [self.img]
self.img = list(map(Image, self.img))
# Needs work. At the moment this should be considered a placeholder.
class Assumption(object):
def __init__(self, node):
@ -159,19 +172,6 @@ class Warning(object):
def __len__(self):
return len(node)
class Subpod(object):
''' Holds a specific answer or additional information relevant to said answer. '''
def __init__(self, node):
self.node = node
self.title = node['@title']
self.text = node['plaintext']
self.img = node['img']
# Allow images to be accessed in a consistent way,
# as a list, regardless of how many there are.
if type(self.img) != list:
self.img = [self.img]
self.img = list(map(Image, self.img))
class Image(object):
''' Holds information about an image included with an answer. '''
def __init__(self, node):

Loading…
Cancel
Save