Example #1
0
def test_unique_with_key():
    first = {'a': '1', 'b': '1'}
    second = {'a': '2', 'b': '2'}
    third = {'a': '3', 'b': '1'}
    items = [first, second, third]

    assert list(unique(items, key=lambda v: v['a'])) == [first, second, third]
    assert list(unique(items, key=lambda v: v['b'])) == [first, second]
Example #2
0
def test_unique():
    assert list(unique([1, 2, 3])) == [1, 2, 3]
    assert list(unique([1, 2, 1, 2])) == [1, 2]
Example #3
0
def tags(feed_or_entry):
    return list(unique(tag.label or tag.term
                       for tag in feed_or_entry.get('tags', [])))
Example #4
0
def subscription_urls():
    try:
        with open_file_from(STORAGE_ROOT, 'subscriptions.opml', 'rb') as f:
            return list(unique(feed_url for _, _, feed_url in opml_feeds(f)))
    except OSError:
        return []
Example #5
0
def author_names(feed_or_entry):
    return list(unique(remove_tags(author.name)
                       for author in authors(feed_or_entry)
                       if author.get('name')))