Пример #1
0
 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"))
Пример #2
0
 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"))
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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)
Пример #6
0
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)
Пример #7
0
def has_long_tag(item):
    return has_tag(item, 'long')
Пример #8
0
def has_long_tag(item):
    return has_tag(item, 'long')