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]
def test_unique(): assert list(unique([1, 2, 3])) == [1, 2, 3] assert list(unique([1, 2, 1, 2])) == [1, 2]
def tags(feed_or_entry): return list(unique(tag.label or tag.term for tag in feed_or_entry.get('tags', [])))
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 []
def author_names(feed_or_entry): return list(unique(remove_tags(author.name) for author in authors(feed_or_entry) if author.get('name')))