byroot / pysrt

Python parser for SubRip (srt) files
GNU General Public License v3.0
446 stars 67 forks source link

IOError: [Errno 2] No such file or directory #67

Closed juanpabloaj closed 7 years ago

juanpabloaj commented 7 years ago

If I use pysrt with a not existed file I get this error message

$ srt -i shift 3s hello.txt
Traceback (most recent call last):
  File "/Users/pablo/.envs/pysrt/bin/srt", line 9, in <module>
    load_entry_point('pysrt', 'console_scripts', 'srt')()
  File "/Users/pablo/src/pysrt/pysrt/commands.py", line 216, in main
    SubRipShifter().run(sys.argv[1:])
  File "/Users/pablo/src/pysrt/pysrt/commands.py", line 136, in run
    self.create_backup()
  File "/Users/pablo/src/pysrt/pysrt/commands.py", line 176, in create_backup
    shutil.copy2(self.arguments.file, backup_file)
  File "/Users/pablo/opt/src/homebrew/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/Users/pablo/opt/src/homebrew/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'hello.txt'

This changes fix the error message, but I use the print of python 2.7 ... this print don't work in python 3.x

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 71.458% when pulling dbeac0e71a3a8efd1a99586bb91080285c4fa19c on juanpabloaj:no-file-message into 331b344656052a8444ba5b85974972defe0d028f on byroot:master.

byroot commented 7 years ago

You can do this in a way that is compatible with both versions: http://python-future.org/compatible_idioms.html#print

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.4%) to 71.311% when pulling 1274f48c561dc6ddfaa7d351df637100d0be368a on juanpabloaj:no-file-message into 331b344656052a8444ba5b85974972defe0d028f on byroot:master.

juanpabloaj commented 7 years ago

ok @byroot now I added a print valid for python2 and python3

byroot commented 7 years ago

Thanks