Adds decorators
[kiosk.git] / bellevue_reporter_rss_renderer.py
1 import generic_news_rss_renderer as gnrss
2 import re
3
4 class bellevue_reporter_rss_renderer(gnrss.generic_news_rss_renderer):
5     def __init__(self, name_to_timeout_dict, feed_site, feed_uris, page_title):
6         super(bellevue_reporter_rss_renderer, self).__init__(
7             name_to_timeout_dict,
8             feed_site,
9             feed_uris,
10             page_title)
11         self.debug = 1
12
13     def debug_prefix(self):
14         return "bellevue_reporter(%s)" % (self.page_title)
15
16     def get_headlines_page_prefix(self):
17         return "bellevue-reporter"
18
19     def get_details_page_prefix(self):
20         return "bellevue-reporter-details"
21
22     def should_use_https(self):
23         return True
24
25     def munge_description(self, description):
26         description = re.sub('<[^>]+>', '', description)
27         description = re.sub('Bellevue\s+Reporter\s+Bellevue\s+Reporter', '',
28                              description)
29         description = re.sub('\s*\-\s*Your local homepage\.\s*', '', description)
30         return description
31
32     def item_is_interesting_for_headlines(self, title, description, item):
33         if self.is_item_older_than_n_days(item, 10):
34             self.debug_print("%s: is too old!" % title)
35             return False
36         if (title.find("NFL") != -1 or
37             re.search("[Ll]ive [Ss]tream", title) != None or
38             re.search("[Ll]ive[Ss]tream", title) != None or
39             re.search("[Ll]ive [Ss]tream", description) != None):
40             self.debug_print("%s: looks like it's about football." % title)
41             return False
42         return True
43
44     def item_is_interesting_for_article(self, title, description, item):
45         if self.is_item_older_than_n_days(item, 10):
46             self.debug_print("%s: is too old!" % title)
47             return False
48         if (title.find(" NFL") != -1 or
49             re.search("[Ll]ive [Ss]tream", title) != None or
50             re.search("[Ll]ive[Ss]tream", title) != None or
51             re.search("[Ll]ive [Ss]tream", description) != None):
52             self.debug_print("%s: looks like it's about football." % title)
53             return False
54         return True
55
56 # Test
57 #x = bellevue_reporter_rss_renderer(
58 #    {"Fetch News" : 1,
59 #     "Shuffle News" : 1},
60 #    "www.bellevuereporter.com",
61 #    [ "/feed/" ],
62 #    "Test" )
63 #d = """
64 #<DIV style="padding:8px;
65 #     font-size:44pt;
66 #     -webkit-column-break-inside:avoid;"><P>
67 #<B>Task force will tackle issues of racial justice, police reform</B>
68 #<BR>Bellevue Reporter
69 #Bellevue Reporter - Your local homepage.
70 #Inslee names civil rights activists, pastors, and cops to panel that may forge ideas f#or new laws Task force will tackle issues of racial justice, police reform
71 #Wire Service
72 #</DIV>"""
73 #d = x.munge_description(d)
74 #print d
75 #if x.fetch_news() == 0:
76 #    print "Error fetching news, no items fetched."
77 #x.shuffle_news()