From 9c8cf58e15f22753e5a21c8570f451dc8531cabf Mon Sep 17 00:00:00 2001 From: khuang6 Date: Sat, 23 Dec 2017 16:24:24 +0800 Subject: [PATCH] fix None Value error of tag_exp --- 2.1/service/oxford_learning.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/2.1/service/oxford_learning.py b/2.1/service/oxford_learning.py index b1cc513..fe8317c 100644 --- a/2.1/service/oxford_learning.py +++ b/2.1/service/oxford_learning.py @@ -236,20 +236,19 @@ def wd_sound_url_nam(self): def get_definitions(self): defs = [] defs_html = [] - if not self._defs: + if self.tag_explain and not self._defs: tag_exp = self._clean(self.tag_explain) - if tag_exp: - lis = [li for li in tag_exp.find_all('li')] - if not lis: - defs_html.append(str(tag_exp.prettify())) - defs.append(tag_exp.text) - - else: - for li in lis: - defs_html.append(str(li.prettify())) - defs.append(li.text) - self._defs = defs - self._defs_html = defs_html + lis = [li for li in tag_exp.find_all('li')] + if not lis: + defs_html.append(str(tag_exp.prettify())) + defs.append(tag_exp.text) + + else: + for li in lis: + defs_html.append(str(li.prettify())) + defs.append(li.text) + self._defs = defs + self._defs_html = defs_html return self._defs, self._defs_html @property