16 if not os.path.exists(full_log_filename):
17 logfile = open(full_log_filename,
'w')
21 logging.basicConfig(level=logging.ERROR,
22 filename=full_log_filename,
23 format=
'%(asctime)s %(message)s')
31 text = re.sub(
r'[\.\'\"\?\,\!\:;\-\\\/\(\)]',
' ', text)
33 return len(text.split())
45 hours = int(total_sec) / (60 * 60)
46 mins = ( int(total_sec) - (hours * 60 * 60) ) / 60
47 secs = total_sec - (hours * 60 * 60) - (mins * 60)
49 return hours, mins, secs
58 def get_time_str(total_sec, pad_hour_min=True, show_hours=True, show_decimals=True):
60 hours, mins, secs = BackendUtils.break_time(total_sec)
64 result = (
'%02d:' if pad_hour_min
else '%d:') % (hours)
69 result += (
'%02d:' if pad_hour_min
else '%d:') % (mins)
73 result +=
'%s%0.2f' % (
'0' if secs < 10
else '', secs)
75 result +=
'%02d' % (int(secs))
81 chunks = time_str.split(
':')
84 raise Exception(
'Cannot convert time string "%s" to float - invalid format.' % (str(time_str)))
87 for i
in range(len(chunks)):
88 result += float(chunks[i]) * (60.0 ** (len(chunks) - i - 1))
97 return '0%s' % (num_str)
if int(num_str) < 10
else num_str
105 parts = re.split(
r'[/\s:]', date_str)
106 parts[0], parts[1], parts[2] = parts[2], parts[0], parts[1]
109 for cur_part
in parts:
110 date_str += BackendUtils.pad_num_str(cur_part)