From 760a6a6a9211095db257a5506d5f0b04286234c8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 3 Sep 2016 11:20:52 -0400 Subject: [PATCH] Normalize docstrings per PEP 257. --- wolframalpha/__init__.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/wolframalpha/__init__.py b/wolframalpha/__init__.py index 4f66a8b..2fd3573 100644 --- a/wolframalpha/__init__.py +++ b/wolframalpha/__init__.py @@ -55,9 +55,9 @@ class Client(object): class Result(object): - ''' + """ Handles processing the response for the programmer. - ''' + """ def __init__(self, stream): self.tree = xmltodict.parse(stream, dict_constructor=dict)['queryresult'] self._handle_error() @@ -97,16 +97,23 @@ class Result(object): @property def results(self): - ''' Get the pods that hold the response to a simple, discrete query. ''' + """ + Get the pods that hold the response to a simple, discrete query. + """ return [pod for pod in self.pods if pod.primary or pod.title=='Result'] @property def details(self): - ''' Get a simplified set of answers with some context. ''' + """ + Get a simplified set of answers with some context. + """ return {pod.title: pod.text for pod in self.pods} + class Pod(object): - ''' Groups answers and information contextualizing those answers. ''' + """ + Groups answers and information contextualizing those answers. + """ def __init__(self, node): self.node = node self.error = node['@error'] @@ -142,11 +149,16 @@ class Pod(object): @property def text(self): - ''' Simply get the text from each subpod in this pod and return it in a list. ''' + """ + 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. ''' + """ + Holds a specific answer or additional information relevant to said answer. + """ def __init__(self, node): self.node = node self.title = node['@title'] @@ -158,6 +170,7 @@ class Subpod(object): 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): @@ -179,6 +192,7 @@ class Assumption(object): pass return text[:text.index('. ') + 1] + # Needs work. At the moment this should be considered a placeholder. class Warning(object): def __init__(self, node): @@ -190,8 +204,11 @@ class Warning(object): def __len__(self): return len(node) + class Image(object): - ''' Holds information about an image included with an answer. ''' + """ + Holds information about an image included with an answer. + """ def __init__(self, node): self.node = node self.title = node['@title']