示例#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]
示例#2
0
def test_unique():
    assert list(unique([1, 2, 3])) == [1, 2, 3]
    assert list(unique([1, 2, 1, 2])) == [1, 2]
示例#3
0
文件: crawl.py 项目: drcraig/skim
def tags(feed_or_entry):
    return list(unique(tag.label or tag.term
                       for tag in feed_or_entry.get('tags', [])))
示例#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 []
示例#5
0
文件: crawl.py 项目: drcraig/skim
def author_names(feed_or_entry):
    return list(unique(remove_tags(author.name)
                       for author in authors(feed_or_entry)
                       if author.get('name')))