def engoo_date_str(reserve_time, class_holiday):
    """retrieve the date when being available to take lessen e.g.'dt_2017-04-07_00-30-00'"""
    tomorrow = datetime.date.today() + datetime.timedelta(days=1)
    weekday_dict = readAndSave.read_json('korean_holiday.json',
                                         'utf8')  # 휴일 data

    def loop_until_workday(calculating_data):
        if weekday_dict[calculating_data.strftime('%Y-%m-%d')]:  #휴일이나
            return calculating_data
        else:
            return loop_until_workday(calculating_data +
                                      datetime.timedelta(days=1))

    if not class_holiday:
        # if you don't have class on holiday
        next_day = loop_until_workday(tomorrow)
        date = next_day.strftime('%Y-%m-%d')

    else:
        date = tomorrow.strftime('%Y-%m-%d')

    return 'dt_' + date + '_' + reserve_time + '-00'
예제 #2
0
def main_function(sex_file, func):
    surveys = readAndSave.read_json(sex_file, 'utf8')

    height_list = [int(survey['104']) for survey in surveys]
    height_min, height_max = min(height_list) // 10 * 10, max(
        height_list) // 10 * 10  # 1774->1770

    hw_filtered_dict = {}
    for height in range(height_min, height_max + 10, 10):  # 10mm씩 키 검색
        print('height{}'.format(height))
        height_filtered_list = list(
            filter(partial(search_data, height=height), surveys))
        if len(height_filtered_list) == 0: continue  # 키 자료 없으면 안뽑기

        # 키 안에 있는 몸무게 데이터 접근
        weight_list = [
            float(height_filtered['510'])
            for height_filtered in height_filtered_list
        ]
        weight_min, weight_max = round(min(weight_list)), round(
            max(weight_list))
        print('weight min{}, max {}'.format(weight_min, weight_max))

        hw_filtered_dict[height] = {}
        if weight_min == weight_max:  # 자료가 하나밖에 없다면(하나만 있으면 range 문이 안돌아가므로)
            weight = weight_min
            hw_filtered_dict[height][weight] = func(height, weight,
                                                    height_filtered_list)
            continue
        for weight in range(weight_min, weight_max + 1, 1):
            # 없는 몸무게도 일단 들어가는 문제
            data = func(height, weight, height_filtered_list)
            if data:  # data 가 빈 데이터가 아니라면
                hw_filtered_dict[height][weight] = data

    return hw_filtered_dict
def already_reserve_tf(key):
    """check whether I reserved or not."""
    reserved_dict = readAndSave.read_json('Did_I_reserved.json', 'utf8')
    return key in reserved_dict
def read_reservation_info():
    """Read private info"""
    info = readAndSave.read_json('reservation_info.json', 'utf8')

    return info["teacher_num"], info["reserve_time"], info[
        "class_holiday"], info["send_to"]
def write_reserve_date(key):
    reserved_dict = readAndSave.read_json('Did_I_reserved.json', 'utf8')
    reserved_dict[key] = True
    readAndSave.save_json(reserved_dict, 'Did_I_reserved.json', 'utf8')
    return
def read_id_pw(site_name):
    """Read private info"""
    info = readAndSave.read_json('id_pass.json', 'utf8')
    id, password = info[site_name]['id'], info[site_name]['password']

    return id, password