archiver/util.py
def merge_links(a, b):
    """deterministially merge two links, favoring longer field values over shorter,
    and "cleaner" values over worse ones.
    """
    longer = lambda key: a[key] if len(a[key]) > len(b[key]) else b[key]
    earlier = lambda key: a[key] if a[key] < b[key] else b[key]
    
    url = longer('url')
    longest_title = longer('title')
    cleanest_title = a['title'] if '://' not in a['title'] else b['title']
    link = {
        'timestamp': earlier('timestamp'),
        'url': url,
        'domain': domain(url),
        'base_url': base_url(url),
        'tags': longer('tags'),
        'title': longest_title if '://' not in longest_title else cleanest_title,
        'sources': list(set(a.get('sources', []) + b.get('sources', []))),
    }
    link['type'] = get_link_type(link)
    return link
deterministially merge two links, favoring longer field values over shorter,
    and "cleaner" values over worse ones.
    
deterministially merge two links, favoring longer field values over shorter,
and "cleaner" values over worse ones.
deterministially merge two links favoring longer field values over shorter and " cleaner " values over worse ones .
def merge_links(a, b):
    longer = lambda key: a[key] if len(a[key]) > len(b[key]) else b[key]
    earlier = lambda key: a[key] if a[key] < b[key] else b[key]
    url = longer('url')
    longest_title = longer('title')
    cleanest_title = a['title'] if '://' not in a['title'] else b['title']
    link = {
        'timestamp': earlier('timestamp'),
        'url': url,
        'domain': domain(url),
        'base_url': base_url(url),
        'tags': longer('tags'),
        'title': longest_title if '://' not in longest_title else cleanest_title,
        'sources': list(set(a.get('sources', []) + b.get('sources', []))),
    }
    link['type'] = get_link_type(link)
    return link
def merge_links ( a , b ) : longer = lambda key : a [ key ] if len ( a [ key ] ) > len ( b [ key ] ) else b [ key ] earlier = lambda key : a [ key ] if a [ key ] < b [ key ] else b [ key ] url = longer ( 'url' ) longest_title = longer ( 'title' ) cleanest_title = a [ 'title' ] if '://' not in a [ 'title' ] else b [ 'title' ] link = { 'timestamp' : earlier ( 'timestamp' ) , 'url' : url , 'domain' : domain ( url ) , 'base_url' : base_url ( url ) , 'tags' : longer ( 'tags' ) , 'title' : longest_title if '://' not in longest_title else cleanest_title , 'sources' : list ( set ( a . get ( 'sources' , [ ] ) + b . get ( 'sources' , [ ] ) ) ) , } link [ 'type' ] = get_link_type ( link ) return link
deterministially merge two links, favoring longer field values over shorter,
and "cleaner" values over worse ones.
deterministially merge two links favoring longer field values over shorter and " cleaner " values over worse ones .
"""deterministially merge two links, favoring longer field values over shorter,
    and "cleaner" values over worse ones.
    """
a
b