Fix ruff warning about imports and IOError instead of OSError.
This commit is contained in:
+35
-25
@@ -3,30 +3,40 @@
|
||||
|
||||
# Standard modules
|
||||
import argparse
|
||||
import re
|
||||
from sys import exit
|
||||
from datetime import datetime,timedelta
|
||||
import logging
|
||||
from functools import cmp_to_key
|
||||
from subprocess import Popen, PIPE
|
||||
from os import read, write, lseek, set_inheritable, memfd_create, SEEK_SET, close, unlink,\
|
||||
fstat, ftruncate
|
||||
import os.path
|
||||
from enum import IntEnum, unique
|
||||
from shutil import copyfile, which, move
|
||||
from dataclasses import dataclass, field
|
||||
from math import floor, ceil, log
|
||||
from io import BytesIO, TextIOWrapper
|
||||
import json
|
||||
import logging
|
||||
import os.path
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime, timedelta
|
||||
from enum import IntEnum, unique
|
||||
from functools import cmp_to_key
|
||||
from io import BytesIO, TextIOWrapper
|
||||
from math import ceil, floor, log
|
||||
from os import (
|
||||
SEEK_SET,
|
||||
close,
|
||||
fstat,
|
||||
ftruncate,
|
||||
lseek,
|
||||
memfd_create,
|
||||
read,
|
||||
set_inheritable,
|
||||
unlink,
|
||||
write,
|
||||
)
|
||||
from shutil import copyfile, move, which
|
||||
from subprocess import PIPE, Popen
|
||||
from sys import exit
|
||||
from typing import IO
|
||||
from typeguard import typechecked
|
||||
|
||||
# Third party libraries
|
||||
import coloredlogs
|
||||
from tqdm import tqdm
|
||||
import hexdump
|
||||
from iso639 import Lang
|
||||
from iso639.exceptions import InvalidLanguageValue
|
||||
from tqdm import tqdm
|
||||
from typeguard import typechecked
|
||||
|
||||
# Local modules
|
||||
# TODO: create local modules for MP4, MKV
|
||||
@@ -361,7 +371,7 @@ def do_ocr(vobsubocr:str, idxs: list[tuple[str,str,str,str]], duration:timedelta
|
||||
while pos < srt_length:
|
||||
pos+=write(outfd, buf[pos:])
|
||||
temporaries.append(dump_srt)
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', srtname)
|
||||
return None
|
||||
|
||||
@@ -2734,7 +2744,7 @@ def dump_ppm(pictures: bytes, prefix: str, temporaries: list[IO[bytes]]) -> None
|
||||
nb_bytes+=write(outfd, pictures[pos+nb_bytes:pos+length])
|
||||
pos+=length
|
||||
picture+=1
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', filename)
|
||||
|
||||
@typechecked
|
||||
@@ -2871,7 +2881,7 @@ def extract_all_streams(ffmpeg_path:str, ffprobe_path:str, input_file:IO[bytes],
|
||||
pos = 0
|
||||
while pos < len(sound_bytes):
|
||||
pos+=write(outfd, sound_bytes[pos:])
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', tmpname)
|
||||
return None
|
||||
|
||||
@@ -2907,7 +2917,7 @@ def extract_all_streams(ffmpeg_path:str, ffprobe_path:str, input_file:IO[bytes],
|
||||
mkv_filename = f'{files_prefix}.mkv'
|
||||
try:
|
||||
mkv_output = open(mkv_filename,'wb+')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', mkv_filename)
|
||||
return None
|
||||
|
||||
@@ -2928,7 +2938,7 @@ def extract_all_streams(ffmpeg_path:str, ffprobe_path:str, input_file:IO[bytes],
|
||||
h264_filename = f'{files_prefix}.h264'
|
||||
try:
|
||||
h264_output = open(h264_filename,'wb+')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', h264_filename)
|
||||
return None
|
||||
|
||||
@@ -2957,7 +2967,7 @@ def extract_all_streams(ffmpeg_path:str, ffprobe_path:str, input_file:IO[bytes],
|
||||
h264_ts_filename = f'{files_prefix}-ts.txt'
|
||||
try:
|
||||
h264_ts_output = open(h264_ts_filename,'w+', encoding='utf8')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', h264_ts_filename)
|
||||
return None
|
||||
|
||||
@@ -2992,7 +3002,7 @@ def merge_mkvs(mkvmerge_path:str, inputs: list[IO[bytes]], output_name:str,
|
||||
fds = []
|
||||
try:
|
||||
out = open(output_name, 'wb+')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', output_name)
|
||||
return None
|
||||
|
||||
@@ -3175,7 +3185,7 @@ def remux_srt_subtitles(mkvmerge_path:str, input_file: IO[bytes], output_filenam
|
||||
|
||||
try:
|
||||
out = open(output_filename, 'w', encoding='utf8')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', output_filename)
|
||||
return None
|
||||
|
||||
@@ -3289,7 +3299,7 @@ def do_coarse_processing(ffmpeg_path:str, ffprobe_path:str, mkvmerge_path:str,
|
||||
|
||||
try:
|
||||
internal_mkv = open(internal_mkv_name, 'wb+')
|
||||
except IOError:
|
||||
except OSError:
|
||||
logger.error('Impossible to create file: %s', internal_mkv_name)
|
||||
exit(-1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user