Example #1
0
def group_bookmarks(cmd_string):
    """Group all aliases under a name.
    Args:
        cmd_string (str): The command sequence entered by the user.

    Returns:
        None

    """
    url_map = urldb.load_map()
    group_name = cmd_string[0]
    urldb.update_grouplist(group_name)

    bookmark_list = cmd_string[1:]
    if not bookmark_list:
        print "You did not group anything :("
        print_usage()
        return

    if group_name not in groups:
        url_map[group_name] = []

    for bmark in bookmark_list:
        url_map[group_name].append(bmark)

    urldb.update_map(url_map)
Example #2
0
def add_bookmarks(cmd_string):
    """Store alias and corresponding URL to global dictionary.
    Args:
        cmd_string (str): The command sequence entered by the user.

    Returns:
        None

    """
    if not cmd_string:
        print "You added nothing :("
        print_usage()
        return
    # takes the form: pst::pinterest.com fb::facebook.com
    bookmarks = cmd_string
    # parse above into dict: {'pst':'pinterest.com', ...}
    url_dict = {a.strip():[b.strip()] for a, b in [_.split('::') for _ in bookmarks]}
    urldb.update_map(url_dict)

    print "Successfully added :-)."