From 6abccdc728b9fe7d837032b5e016877d1b5db057 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 3 Sep 2016 14:13:10 -0400 Subject: [PATCH] Move Image (and Warning and Assumption) ahead of Subpod. --- wolframalpha/__init__.py | 56 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py index 8a249b8..ef5df7d 100644 --- a/wolframalpha/__init__.py +++ b/wolframalpha/__init__.py @@ -121,6 +121,34 @@ class Result(ErrorHandler, Document): return {pod.title: pod.text for pod in self.pods} +class Assumption(Document): + @property + def text(self): + text = self.template.replace('${desc1}', self.description) + try: + text = text.replace('${word}', self.word) + except: + pass + return text[:text.index('. ') + 1] + + +class Warning(Document): + pass + + +class Image(Document): + """ + Holds information about an image included with an answer. + """ + def __init__(self, *args, **kwargs): + super(Image, self).__init__(*args, **kwargs) + self.title = self['@title'] + self.alt = self['@alt'] + self.height = self['@height'] + self.width = self['@width'] + self.src = self['@src'] + + class Subpod(Document): """ Holds a specific answer or additional information relevant to said answer. @@ -169,31 +197,3 @@ class Pod(ErrorHandler, Document): def text(self): return next(iter(self.subpods)).text - -class Assumption(Document): - @property - def text(self): - text = self.template.replace('${desc1}', self.description) - try: - text = text.replace('${word}', self.word) - except: - pass - return text[:text.index('. ') + 1] - - -class Warning(Document): - pass - - -class Image(Document): - """ - Holds information about an image included with an answer. - """ - def __init__(self, *args, **kwargs): - super(Image, self).__init__(*args, **kwargs) - self.title = self['@title'] - self.alt = self['@alt'] - self.height = self['@height'] - self.width = self['@width'] - self.src = self['@src'] -