Codebase list sugar-read-activity / a55a0cc
Replace BeautifulSoup with ElementTree - removes dependency on BeautifulSoup 3, - avoids BeautifulSoup 4 which is not available on Fedora 18, - ElementTree already used elsewhere in activity and toolkit, - test case; open an EPUB file and use the edit toolbar find entry. Reported-by: György Balló <ballogyor@gmail.com> James Cameron 6 years ago
1 changed file(s) with 15 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2020 import widgets
2121 import math
2222 import os.path
23 import BeautifulSoup
23 import xml.etree.ElementTree as etree
2424
2525 import threading
2626
6161 return False
6262
6363 def _searchfile(self, fileobj):
64 soup = BeautifulSoup.BeautifulSoup(fileobj)
65 body = soup.find('body')
66 tags = body.findChildren(True)
67 for tag in tags:
68 if tag.string is not None:
69 if tag.string.lower().find(self.obj._text.lower()) > -1:
64 tree = etree.parse(fileobj)
65 root = tree.getroot()
66
67 body = None
68 for child in root:
69 if child.tag.endswith('body'):
70 body = child
71
72 if body is None:
73 return False
74
75 for child in body.iter():
76 if child.text is not None:
77 if child.text.lower().find(self.obj._text.lower()) > -1:
7078 return True
7179
7280 return False