def main_csv_reader(args): path_to_coffee = args.path_to_coffee path_to_matched = args.matched_json all_people_list = flat_list(list(read_csv_file(path_to_coffee))) matched_in_this_session = [] error = False if path_to_matched: try: matched_people_json = read_json_file(path_to_matched) tuple_list = create_tuple_list(all_people_list, matched_people_json) sorted_people_list = sort_tuple_list(tuple_list) except: raise ('Only use the program generated matched_people.json file') else: write_json_file() matched_people_json = read_json_file('matched_people.json') sorted_people_list = all_people_list unmatched_people = [] for person in sorted_people_list: if person not in matched_in_this_session: individual_match_list = invidual_preproc(person, all_people_list, matched_people_json, matched_in_this_session) if individual_match_list: matched_pair = coffee_roulette(person, individual_match_list) if matched_pair is not None: for person in matched_pair: matched_in_this_session.append(person) else: error = True break else: unmatched_people.append(person) else: pass if error is False: create_today_matched(matched_in_this_session) if unmatched_people: create_today_unmatched(unmatched_people) updated_json = update_current_json(matched_people_json, matched_in_this_session) summary = "\n{} Matches".format(date.today()) summary = create_matched_people_string(matched_in_this_session, summary) summary_messsage, alone = make_summary(matched_in_this_session, unmatched_people, summary, "") summary += alone write_json_file(updated_json) write_txt_file(summary) print(summary_messsage)
def write_to_local(): global id_user_will_be_reply reset_some_file() util.delete_file_by_type(keys_obj['info_dir_path'],'jpeg') if len(status_list.show()) > 0: cur_status = status_list.pop_oldest() util.write_txt_file(keys_obj['info_dir_path']+keys_obj['last_weibo_id_file_name'],str(cur_status['id'])) id_user_will_be_reply = str(cur_status['id']) cur_status['user']['fids'] = city_position.get_somebody_friends_ids(cur_status['user']['id'])['ids'] writer = InfoWriter() writer.write_info(cur_status)
def write_to_local(): global id_user_will_be_reply reset_some_file() util.delete_file_by_type(keys_obj['info_dir_path'], 'jpeg') if len(status_list.show()) > 0: cur_status = status_list.pop_oldest() util.write_txt_file( keys_obj['info_dir_path'] + keys_obj['last_weibo_id_file_name'], str(cur_status['id'])) id_user_will_be_reply = str(cur_status['id']) cur_status['user']['fids'] = city_position.get_somebody_friends_ids( cur_status['user']['id'])['ids'] writer = InfoWriter() writer.write_info(cur_status)
def reset_some_file(): util.write_txt_file( keys_obj['info_dir_path'] + keys_obj['weibo_file_name'], '') util.write_txt_file( keys_obj['info_dir_path'] + keys_obj['user_name_file_name'], '') util.write_txt_file( keys_obj['info_dir_path'] + keys_obj['friends_ids_file_name'], '')
def reset_some_file(): util.write_txt_file(keys_obj['info_dir_path']+keys_obj['weibo_file_name'],'') util.write_txt_file(keys_obj['info_dir_path']+keys_obj['user_name_file_name'],'') util.write_txt_file(keys_obj['info_dir_path']+keys_obj['friends_ids_file_name'],'')