Skip to content

Commit

Permalink
fix None Value error of tag_exp
Browse files Browse the repository at this point in the history
  • Loading branch information
khuang6 committed Dec 23, 2017
1 parent 56afe17 commit 3338974
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions 2.1/service/oxford_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def __init__(self, markups):
return
self.markups = markups
self.bs = BeautifulSoup(self.markups)
self._defs = None
self._defs_html = None
self._defs = []
self._defs_html = []

@staticmethod
def _cls_dic(class_nm):
Expand Down Expand Up @@ -234,21 +234,22 @@ def wd_sound_url_nam(self):
return ''

def get_definitions(self):
defs = []
defs_html = []
if not self._defs:
defs = []
defs_html = []
tag_exp = self._clean(self.tag_explain)
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
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
return self._defs, self._defs_html

@property
Expand Down

0 comments on commit 3338974

Please sign in to comment.