15 initialize_file(RSS_CACHE_FILE, "{'channels': {}}") |
15 initialize_file(RSS_CACHE_FILE, "{'channels': {}}") |
16 |
16 |
17 ################################################################################ |
17 ################################################################################ |
18 |
18 |
19 import re |
19 import re |
|
20 |
|
21 html_table = [ |
|
22 ('<p>' , '' ), |
|
23 ('</p>' , '' ), |
|
24 ('<p />', '' ), |
|
25 ('<p/>' , '' ), |
|
26 ('>' , '>'), |
|
27 ('>' , '>'), |
|
28 ('<' , '<'), |
|
29 ('"' , '"'), |
|
30 ('&' , '&'), |
|
31 ] |
|
32 |
20 def rss_remove_html(text): |
33 def rss_remove_html(text): |
21 exp = re.compile('<[^>]*>') |
34 text = re.sub(r'<[^>]*>', '', text) |
22 text = exp.sub('', text) |
35 for bad, new in html_table : |
23 notags = text.replace('<', '<').replace('>', '>') |
36 text = text.replace(bad, new) |
24 noescape = notags.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"') |
37 return text |
25 noescape = noescape.replace('<p>', '') |
|
26 noescape = noescape.replace('</p>', '') |
|
27 noescape = noescape.replace('<p />', '').replace('<p/>', '') |
|
28 return noescape |
|
29 |
|
30 """ OLD CODE: REMOVE LATER IF NEW FUNCTION (added 2005-10-12) WORKS |
|
31 def rss_remove_html(text): |
|
32 notags = text.replace('<', '<').replace('>', '>') |
|
33 noescape = notags.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"') |
|
34 noescape = noescape.replace('<p>', '') |
|
35 noescape = noescape.replace('</p>', '') |
|
36 noescape = noescape.replace('<p />', '').replace('<p/>', '') |
|
37 return noescape |
|
38 """ |
|
39 |
38 |
40 def rss_update_file(): |
39 def rss_update_file(): |
41 global RSS_CACHE |
40 global RSS_CACHE |
42 write_file(RSS_CACHE_FILE, str(RSS_CACHE)) |
41 write_file(RSS_CACHE_FILE, str(RSS_CACHE)) |
43 |
42 |