1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

simplify code

This commit is contained in:
Alex Xu
2024-08-04 21:29:50 -07:00
parent 9e09898986
commit 3e90dd66c3

View File

@@ -52,9 +52,7 @@ class ComicArchive:
for line in process.stdout.splitlines():
if b'Type =' in line:
return line.rstrip().decode().split(' = ')[1].upper()
except FileNotFoundError:
pass
except CalledProcessError:
except (FileNotFoundError, CalledProcessError):
pass
raise OSError(EXTRACTION_ERROR)
@@ -67,7 +65,6 @@ class ComicArchive:
['tar', '-xf', self.filepath, '-C', targetdir],
['7z', 'x', '-y', '-xr!__MACOSX', '-xr!.DS_Store', '-xr!thumbs.db', '-xr!Thumbs.db', '-o' + targetdir, self.filepath],
]
missing = []
if distro.id() == 'fedora':
extraction_commands.append(
@@ -78,15 +75,10 @@ class ComicArchive:
try:
subprocess_run(cmd, capture_output=True, check=True)
return targetdir
except FileNotFoundError:
missing.append(cmd[0])
except CalledProcessError:
except (FileNotFoundError, CalledProcessError):
pass
if missing:
raise OSError(f'Extraction failed, try downloading {missing}')
else:
raise OSError(EXTRACTION_ERROR)
raise OSError(EXTRACTION_ERROR)
def addFile(self, sourcefile):
if self.type in ['RAR', 'RAR5']: