def test_has_tags(self): # no tags in item is false. self.assertFalse(has_tag({}, "sometag")) # tag in item self.assertTrue(has_tag({"tags": {"sometag": 1}}, "sometag")) # tag not in item self.assertFalse(has_tag({"tags": {"anothertag": 1}}, "sometag"))
def find_items_with_comments_tag(items): uids = [] for uid, item in items.iteritems(): if has_tag(item, "comments"): uids.append((uid, item.get('given_url', ''))) return uids
def check_for_match(uid, item, kword, kword_tag, uids, item_key): item_value = item.get(item_key, None) if not item_value: return word_exp = re.compile(r'\b%s\b' % kword, flags=re.IGNORECASE) match = word_exp.search(item_value.lower()) if match: if not has_tag(item, kword_tag): uids.append(uid)
def has_long_tag(item): return has_tag(item, 'long')