<commit_before>#!/usr/bin/env python
# coding: utf8
import re

stime = re.compile('\d\:\d\d\:\d\d.\d\d')


def stime_add(strtime, secodes):
    h, m, s = [float(i) for i in strtime.split(':')]
    total = h * 3600 + m * 60 + s + secodes
    s = total % 60
    total -= s
    m = total % 3600
    total -= m
    h = total / 3600
    m = m / 60
    if h < 0 or m < 0 or s < 0:
        return '0:00:00.00'
    else:
        s = '%d:%02d:%05.2f' % (h, m, s)
        return s


def change_line(line, secodes):
    for s in stime.findall(line):
        line = line.replace(s, stime_add(s, secodes))
    return line


def change_ass(f, secodes):
    with open(f, 'rb') as fp:
        lines = fp.readlines()
    for i, l in enumerate(lines):
        lines[i] = change_line(l.decode('utf8'), secodes)
    text = ''.join(lines)
    with open(f, 'w') as fp:
        fp.write(text)


if __name__ == '__main__':
    import sys
    f, secodes = sys.argv[1], sys.argv[2]
    secodes = float(secodes)
    change_ass(f, secodes)<commit_msg>update the time format of ass_editor<commit_after>#!/usr/bin/env python
# coding: utf8
import re

stime = re.compile('\d{1,2}\:\d\d\:\d\d[,.]\d\d')


def stime_add(strtime, secodes):
    strtime = strtime.replace(',', '.')
    h, m, s = [float(i) for i in strtime.split(':')]
    total = h * 3600 + m * 60 + s + secodes
    s = total % 60
    total -= s
    m = total % 3600
    total -= m
    h = total / 3600
    m = m / 60
    if h < 0 or m < 0 or s < 0:
        return '0:00:00.00'
    else:
        s = '%02d:%02d:%05.2f' % (h, m, s)
        return s


def change_line(line, secodes):
    for s in stime.findall(line):
        line = line.replace(s, stime_add(s, secodes))
    return line


def change_ass(f, secodes):
    with open(f, 'rb') as fp:
        lines = fp.readlines()
    for i, l in enumerate(lines):
        lines[i] = change_line(l.decode('utf8'), secodes)
    text = ''.join(lines)
    with open(f, 'w') as fp:
        fp.write(text)


if __name__ == '__main__':
    import sys
    f, secodes = sys.argv[1], sys.argv[2]
    secodes = float(secodes)
    change_ass(f, secodes)
{'fraction_non_alphanumeric': 0.1656441717791411, 'fraction_numerical': 0.03680981595092025, 'mean_word_length': 2.2615384615384615, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3474264', 'n_tokens_mistral': 898, 'n_tokens_neox': 840, 'n_words': 232}