def add_kw_rule(db, c, kw=None, item_uid=None, match='word', target='title', feed_only=False, retroactive=False, stem=None, **kwargs): feed_only = bool(feed_only) retroactive = bool(retroactive) if feed_only: item_uid = int(item_uid) else: item_uid = None if match == 'word': kw = stem if not kw: return if match in ['author', 'tag', 'phrase_lc']: words = [normalize.lower(kw)] elif match in {'word', 'exactword'}: words = normalize.get_words(kw) elif match == 'all': words = [' '.join(normalize.get_words(kw))] elif match == 'phrase': words = [kw] else: return if match in ['author', 'tag']: rule_type = match else: rule_type = target + '_' + match for word in words: print >> param.log, 'ADD_KW_RULES', rule_type, item_uid, word c.execute("""insert into fm_rules (rule_type, rule_feed_uid, rule_text) values (?, (select item_feed_uid from fm_items where item_uid=?), ?)""", [rule_type, item_uid, word]); invalidate()
def __init__(self, uid, expires, rule): Rule.__init__(self, uid, expires) self.rule = normalize.lower(rule)
def test(self, item, feed, feed_uid): if self.check_expires(): return False return self.rule == normalize.lower(item['author'])