Beispiel #1
0
    def post(self):
        username1 = self.request.get('username1')
        username2 = self.request.get('username2')

        fs1, fofs1 = comparer.get_friends(username1)
        fs2, fofs2 = comparer.get_friends(username2)

        common_fs = comparer.find_common(fs1, fs2)
        common_fs.sort()

        common_fofs = comparer.find_common(fofs1, fofs2)
        common_fofs.sort()

        # the rest of the function should be replaced with the code taken
        # from multi version
        
        common_fs_links = [profile_link % (fr, fr) for fr in common_fs]
        render_common_fs = ", ".join(common_fs_links)
        common_fofs_links = [profile_link % (fr, fr) for fr in common_fofs]
        render_common_fofs = ", ".join(common_fofs_links)
        
        template_values = {
            'username1': profile_link % (username1,username1),
            'f1_len': len(fs1),
            'fof1_len': len(fofs1),
            'username2': profile_link % (username2,username2),
            'f2_len': len(fs2),
            'fof2_len': len(fofs2),
            'common_fs_len': len(common_fs),
            'common_friends': render_common_fs,
            'common_fofs_len': len(common_fofs),
            'common_friendofs': render_common_fofs
            }
        
        path = get_page(self.request, 'results.html')
        self.response.out.write(template.render(path, template_values))
Beispiel #2
0
def comp_lj(usernames_list):
    """Given a string containing comma-separated list of usernames, find people
that follow/are followed by all given users."""

    usernames = map(str.strip, str(usernames_list).split(","))
    
    list_fs, list_fofs = [], []
    
    for un in usernames:
        friends, friend_ofs = comparer.get_friends(un)

        friends.sort()
        friend_ofs.sort()
        list_fs.append(tracked_list(friends))
        list_fofs.append(tracked_list(friend_ofs))

    return compare_multi(list_fs), compare_multi(list_fofs)