コード例 #1
0
ファイル: main.py プロジェクト: sancayouth/SrtModPy
def main():
    parser = argparse.ArgumentParser(prog='SrtModPy',\
            description='Just adjusts the timing of subtitle files')
    parser.add_argument('file', help='the subtitle to be modified')
    parser.add_argument('time_amount', type=float,\
           help='the amount of time to be added or subtracted to subtitle')
    parser.add_argument('-t',\
           help='it\'s the part of time to be modified', choices=['S', 'M'], default='S')
    parser.add_argument('-o',\
           help='add or discount time to subtitle', choices=['A', 'D'], default='A')
    arg = parser.parse_args()

    time_amount = arg.time_amount
    file_ = arg.file
    time_part = arg.t
    operation = arg.o
    try:
        srt = SrtMod(file_, time_amount, time_part, operation)
        if srt.process():
			print 'subtitle file was created successfully'
			print 'file saved at: ' + os.path.splitext(file_)[0] +'(modified).srt'
        else:
            print '\nsubtitle can not be processed'
    except OverflowError:
        print 'Exception: Invalid time amount for this operation'
コード例 #2
0
ファイル: test.py プロジェクト: sancayouth/SrtModPy
 def test_file_cannot_be_processed(self):
     srt = SrtMod('lalala.srt', 1, 'm', 'd')
     result = srt.process()
     self.assertFalse(result)
コード例 #3
0
ファイル: test.py プロジェクト: sancayouth/SrtModPy
 def test_file_can_be_processed(self):
     srt = SrtMod('sub.srt', 1, 's', 'a')
     result = srt.process()
     self.assertTrue(result)
コード例 #4
0
ファイル: test.py プロジェクト: sancayouth/SrtModPy
 def test_when_file_is_load_content_must_be_greater_than_zero(self):
     srt = SrtMod('sub.srt')
     srt.process()
     self.assertGreater(len(srt.content), 0)