Please the linter

- Do not use lambda
 - Replace assert with raise
 - Minor fixes
This commit is contained in:
Blallo 2021-08-25 15:48:12 -03:00
parent c48efc46d2
commit a192501570
No known key found for this signature in database
GPG key ID: 0CBE577C9B72DC3F

View file

@ -70,13 +70,16 @@ def mp3_join(named_intervals):
for (filename, start_cut, end_cut) in named_intervals: for (filename, start_cut, end_cut) in named_intervals:
# this happens only one time, and only at the first iteration # this happens only one time, and only at the first iteration
if start_cut: if start_cut:
assert startskip is None if startskip is not None:
raise Exception("error in first cut iteration")
startskip = start_cut startskip = start_cut
# this happens only one time, and only at the first iteration # this happens only one time, and only at the last iteration
if end_cut: if end_cut:
assert endskip is None if endskip is not None:
raise Exception("error in last iteration")
endskip = end_cut endskip = end_cut
assert "|" not in filename if "|" in filename:
raise Exception(f"'|' in {filename}")
files.append(filename) files.append(filename)
cmdline = [ffmpeg, "-i", "concat:%s" % "|".join(files)] cmdline = [ffmpeg, "-i", "concat:%s" % "|".join(files)]
@ -96,10 +99,13 @@ def create_mp3(
outfile: str, outfile: str,
options={}, options={},
validator: Optional[Validator] = None, validator: Optional[Validator] = None,
**kwargs **kwargs,
): ):
if validator is None: if validator is None:
validator = lambda s, e, f: True
def validator(s, e, f):
return True
intervals = [ intervals = [
(get_timefile(begin), start_cut, end_cut) (get_timefile(begin), start_cut, end_cut)
for begin, start_cut, end_cut in get_files_and_intervals(start, end) for begin, start_cut, end_cut in get_files_and_intervals(start, end)
@ -162,7 +168,7 @@ def create_mp3(
os.kill(p.pid, 15) os.kill(p.pid, 15)
try: try:
os.remove(tmp_file.name) os.remove(tmp_file.name)
except: except Exception:
pass pass
raise Exception("timeout") # TODO: make a specific TimeoutError raise Exception("timeout") # TODO: make a specific TimeoutError
if p.returncode != 0: if p.returncode != 0: