def evaluate_opt_args(): p_log_this() # d_glbls.print_arg_ns() # optional args(ConfArgParser): if d_glbls.arg_ns.in_file == d_glbls.arg_ns.in_file: fn_in_file = d_glbls.arg_ns.in_file if p_utils.p_file_exists (fn_in_file, print_message = False): f_in_file = p_utils.p_file_open(fn_in_file, mode = 'r') time_stamp_list, runs_cnt = make_time_stamp_list(f_in_file) # print 'runs = ', runs_cnt; # print time_stamp_list day_ts_list, days_cnt, times_cnt = make_day_ts_list(time_stamp_list) print '\nday_ts_list = ', days_cnt, 'times = ', times_cnt fn_out_file = d_glbls.arg_ns.out_file f_out_file = p_utils.p_file_open(fn_out_file, mode = 'w') day_act = None day_before = None day_act_str = '' day_before_str = '' one_day = datetime.timedelta(days=1) for day_ts in sorted(time_stamp_list): Y_a = int(day_ts [:4]) M_a = int(day_ts [5:7]) D_a = int(day_ts [8:10]) day_act = datetime.date(Y_a, M_a, D_a) day_act_str = day_ts [:10] # print Y_a, M_a, D_a, if not day_before: day_before = day_act day_before_str = day_act_str mins = int(day_ts [-8:-6])*60 + int(day_ts [-5:-3]) if (day_act == day_before): # data_str = (day_ts [:10] + ' 00:00:00 ; ' + day_ts ) # data_str = data_str + ' ; ' + day_ts [-8:-6] + day_ts [-5:-3] # data_str = data_str + ' ; ' + str(mins) + '\n' data_str = make_data_str(day_ts, mins) else: if (((day_act - day_before) == one_day) and (mins < 600)): # Tage an denen ich nach Mitternacht noch programmiert habe data_str = (day_before_str [:10] + ' 00:00:00 ; ' + day_ts ) data_str = data_str + ' ; ' + day_ts [-8:-6] + day_ts [-5:-3] data_str = data_str + ' ; ' + str(mins + (24 * 60)) + ' ; +\n' else: day_before = day_act day_before_str = day_act_str print data_str = make_data_str(day_ts, mins) f_out_file.write(data_str) # python will convert \n to os.linesep print data_str, f_out_file.close() else: print fn_in_file + ' does not exist'
def main(): p_log_this() evaluate_opt_args()