def operate_file_list():
repeat_time_param_check_list = []
file_list = [";2014-05-01:7", 'a', 'b', 'c',
';2014-05-08:5', 'd', 'e', 'f',
';2014-06-01:4', 'g', 'h', 'i']
# file_list.reverse()
con_list = []
now_datetime = datetime.now()
current_data_str = now_datetime.strftime('%Y-%m-%d')
range_valid_flag = False
for line in file_list:
if line.startswith(';'):
repeat_time_param_check_list.append(line.strip())
date_valid_time = line.split(':')
data_form_str = date_valid_time[0].strip()[1:]
date_range = date_valid_time[1].strip()
festival_start_time = data_form_str
date_end = datetime.strptime(data_form_str, "%Y-%m-%d") + timedelta(days=int(date_range))
festival_end_time = date_end.strftime("%Y-%m-%d")
# print festival_start_time,festival_end_time
if festival_start_time < current_data_str < festival_end_time:
range_valid_flag = True
else:
range_valid_flag = False
elif range_valid_flag:
con_list.append(line)
if len(repeat_time_param_check_list) is not len(set(repeat_time_param_check_list)):
raise ValueError('date_param in festival_hot_words repeated, please check !')