descr = descr + " (%s)" % source
return descr
+ def munge_description_internal(self, descr):
+ if len(descr) > 450:
+ descr = descr[:450]
+ descr = re.sub(r"\<[^\>]*$", "", descr)
+ descr = descr + " [...]"
+ descr += "</A></LI></UL></OL></P>"
+ return descr
+
def munge_description(self, description):
soup = BeautifulSoup(description)
for a in soup.findAll('a'):
del a['href']
descr = str(soup)
- if len(descr) > 400:
- descr = descr[:400]
- descr = descr + " [...]"
- return descr
+ return munge_description_internal(descr)
def find_image(self, item):
return None
#if x.fetch_news() == 0:
# print("Error fetching news, no items fetched.")
#x.shuffle_news()
+#
+#descr = "this is a lot of really long text about nothign in particular. It's pretty interesting, don't you think? I hope that the munge description method works by both truncating it and remembering to close any open <LI>items as well as making sure not to truncate in the middle of a <A HREF=\"whatever\" these are a bunch of useless arguments to the A tag that make it really long so that the truncate will happen in the middle of it. I'm getting kind of tired of typing shit so I'm going to revert to copy pasta now. Sorry if you were getting into this story. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.</A></LI> Out!"
+#d = x.munge_description_internal(descr)
+#print(d)
+