Improve pylint score and fix most errors.

This commit is contained in:
Frédéric Tronel
2025-10-25 16:09:11 +02:00
parent 489435a87f
commit 926ee16433

View File

@@ -75,7 +75,7 @@ def getTesseractSupportedLang(tesseract):
line = line.decode('utf8')
p = re.compile('(?P<lang>[a-z]{3})\n')
m = re.match(p,line)
if m != None:
if m is not None:
try:
lang = m.group('lang')
key = Lang(lang)
@@ -259,7 +259,7 @@ def doOCR(vobsubocr, idxs, duration, temporaries, dumpMemFD=False):
pb = tqdm(TextIOWrapper(ocr.stdout, encoding="utf-8"), total=int(duration/timedelta(seconds=1)), unit='s', desc='OCR')
for line in pb:
m = re.match(ldots,line)
if m != None:
if m is not None:
write(srtfd, '...'.encode(encoding='UTF-8'))
else:
write(srtfd, line.encode(encoding='UTF-8'))
@@ -342,7 +342,7 @@ def getCodecPrivateDataFromMKV(mkvinfo, inputFile):
p = re.compile(regExp)
for line in out.splitlines():
m = p.match(line)
if m != None:
if m is not None:
size = int(m.group('size'))
position = int(m.group('position'))
logger.debug("Found codec private data at position: %s, size: %d", position, size)
@@ -1918,13 +1918,13 @@ def parseTimestamp(ts):
minute = 0
second = 0
us = 0
if values['hour'] != None:
if values['hour'] is not None:
hour = int(values['hour'])
if values['minute'] != None:
if values['minute'] is not None:
minute = int(values['minute'])
if values['second'] != None:
if values['second'] is not None:
second = int(values['second'])
if values['us'] != None:
if values['us'] is not None:
us = int(values['us'])
if hour < 0 or hour > 23:
@@ -1963,21 +1963,21 @@ def parseTimeInterval(interval):
minute2 = 0
second2 = 0
ms2 = 0
if values['hour1'] != None:
if values['hour1'] is not None:
hour1 = int(values['hour1'])
if values['minute1'] != None:
if values['minute1'] is not None:
minute1 = int(values['minute1'])
if values['second1'] != None:
if values['second1'] is not None:
second1 = int(values['second1'])
if values['ms1'] != None:
if values['ms1'] is not None:
ms1 = int(values['ms1'])
if values['hour2'] != None:
if values['hour2'] is not None:
hour2 = int(values['hour2'])
if values['minute2'] != None:
if values['minute2'] is not None:
minute2 = int(values['minute2'])
if values['second2'] != None:
if values['second2'] is not None:
second2 = int(values['second2'])
if values['ms2'] != None:
if values['ms2'] is not None:
ms2 = int(values['ms2'])
if hour1 < 0 or hour1 > 23:
@@ -2060,7 +2060,7 @@ def ffmpegConvert(ffmpeg, ffprobe, inputFile, inputFormat, outputFile, outputFor
if line.startswith('out_time='):
ts = line.split('=')[1].strip()
ts = parseTimestamp(ts)
if ts != None:
if ts is not None:
pb.n = int(ts/timedelta(seconds=1))
pb.update()
status = ffmpeg.wait()
@@ -2229,7 +2229,7 @@ def getNearestIFrame(ffprobe, inputFile, timestamp, before=True, deltaMax=timede
delta+=timedelta(seconds=1)
continue
if iframe != None:
if iframe is not None:
its = getTSFrame(iframe)
nbFrames = 0
for frame in frames:
@@ -2378,7 +2378,7 @@ def dumpPPM(pictures, prefix, temporaries):
if magic == 'P6\n':
pattern = re.compile('^(?P<width>[0-9]+) (?P<height>[0-9]+)\n$')
m = pattern.match(dimensions)
if m != None:
if m is not None:
width = int(m['width'])
height = int(m['height'])
else:
@@ -2645,7 +2645,7 @@ def mergeMKVs(mkvmerge, inputs, outputName, concatenate=True, timestamps=None):
fds.append(fd)
set_inheritable(fd, True)
# If we pass a timestamps file associated with the considered track, use it.
if timestamps != None and partNum in timestamps:
if timestamps is not None and partNum in timestamps:
tsfd = timestamps[partNum].fileno()
lseek(tsfd, 0, SEEK_SET)
fds.append(tsfd)
@@ -2936,7 +2936,7 @@ def main():
logger.debug('Arguments: %s' % args)
if args.coarse and args.threshold != None:
if args.coarse and args.threshold is not None:
logger.error('--coarse and threshold arguments are exclusive.')
exit(-1)
@@ -2947,7 +2947,7 @@ def main():
# Flatten args.parts
intervals = []
if args.parts != None:
if args.parts is not None:
for part in args.parts:
for subpart in part:
intervals.append(subpart)
@@ -3158,13 +3158,13 @@ def main():
h264Head, h264HeadTS, mkvHead = extractAllStreams(ffmpeg=paths['ffmpeg'], ffprobe=paths['ffprobe'], inputFile=mkv, begin=ts1, end=headIFrameTS, nbFrames=nbHeadFrames-1, frameRate=frameRate, filesPrefix='part-%d-head' % (partnum), streams=streams, width=width, height=height, temporaries=temporaries, dumpMemFD=args.dump)
# If we are not at an exact boundary:
if mkvHead != None:
if mkvHead is not None:
subparts.append(mkvHead)
if h264Head != None:
if h264Head is not None:
avcconfig = getAvcConfigFromH264(h264Head)
otherAvcConfigs.append(avcconfig)
h264parts.append(h264Head)
if h264HeadTS != None:
if h264HeadTS is not None:
h264TS.append(h264HeadTS)
@@ -3228,13 +3228,13 @@ def main():
# We extract all frames between the I-frame (including it) upto the end.
h264Tail, h264TailTS, mkvTail = extractAllStreams(ffmpeg=paths['ffmpeg'], ffprobe=paths['ffprobe'], inputFile=mkv, begin=tailIFrameTS, end=ts2, nbFrames=nbTailFrames, frameRate=frameRate, filesPrefix='part-%d-tail' % (partnum), streams=streams, width=width, height=height, temporaries=temporaries, dumpMemFD=args.dump)
if mkvTail != None:
if mkvTail is not None:
subparts.append(mkvTail)
if h264Tail != None:
if h264Tail is not None:
avcconfig = getAvcConfigFromH264(h264Tail)
otherAvcConfigs.append(avcconfig)
h264parts.append(h264Tail)
if h264TailTS != None:
if h264TailTS is not None:
h264TS.append(h264TailTS)
logger.info('Merging MKV: %s', subparts)