Esempio n. 1
0
def get_headline_data():
    """Get the headline JSON object for the specified week."""
    week = request.args.get('week', '', type=str)
    data = None
    if week == '' or week == "curr_week":
        data = database.get_headline_JSON_obj(database.get_datestamp())
    else:
        data = database.get_headline_JSON_obj(week)
    return jsonify(result=data)
Esempio n. 2
0
def get_headline_data():
	"""Get the headline JSON object for the specified week."""
	week=request.args.get('week', '', type=str)
	data = None
	if week == '' or week == "curr_week":
		data = database.get_headline_JSON_obj(database.get_datestamp())
	else:
		data = database.get_headline_JSON_obj(week)
	return jsonify(result=data)
def parse_poll_str_list(poll_str_list):
	"""Called by parse_poll_data.
	Organizes the poll data into a list of dictionaries containing poll data.
	"""
	poll_dict_list = []
	datestamp = database.get_datestamp()
	for poll_str in poll_str_list:
		poll_list = poll_str.split(', ')
		poll_dict = {}
		for curr_poll_str in poll_list:
			curr_poll_list = curr_poll_str.split()
			if len(curr_poll_list) == 2:
				can_name = curr_poll_list[0]
				poll_num = int(curr_poll_list[1])
				poll_dict[can_name] = poll_num
		poll_dict_list.append({datestamp : poll_dict})
	return poll_dict_list
def parse_poll_str_list(poll_str_list):
    """Called by parse_poll_data.
	Organizes the poll data into a list of dictionaries containing poll data.
	"""
    poll_dict_list = []
    datestamp = database.get_datestamp()
    for poll_str in poll_str_list:
        poll_list = poll_str.split(", ")
        poll_dict = {}
        for curr_poll_str in poll_list:
            curr_poll_list = curr_poll_str.split()
            if len(curr_poll_list) == 2:
                can_name = curr_poll_list[0]
                poll_num = int(curr_poll_list[1])
                poll_dict[can_name] = poll_num
        poll_dict_list.append({datestamp: poll_dict})
    return poll_dict_list