1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-22 14:11:45 +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(): for line in process.stdout.splitlines():
if b'Type =' in line: if b'Type =' in line:
return line.rstrip().decode().split(' = ')[1].upper() return line.rstrip().decode().split(' = ')[1].upper()
except FileNotFoundError: except (FileNotFoundError, CalledProcessError):
pass
except CalledProcessError:
pass pass
raise OSError(EXTRACTION_ERROR) raise OSError(EXTRACTION_ERROR)
@@ -67,7 +65,6 @@ class ComicArchive:
['tar', '-xf', self.filepath, '-C', targetdir], ['tar', '-xf', self.filepath, '-C', targetdir],
['7z', 'x', '-y', '-xr!__MACOSX', '-xr!.DS_Store', '-xr!thumbs.db', '-xr!Thumbs.db', '-o' + targetdir, self.filepath], ['7z', 'x', '-y', '-xr!__MACOSX', '-xr!.DS_Store', '-xr!thumbs.db', '-xr!Thumbs.db', '-o' + targetdir, self.filepath],
] ]
missing = []
if distro.id() == 'fedora': if distro.id() == 'fedora':
extraction_commands.append( extraction_commands.append(
@@ -78,14 +75,9 @@ class ComicArchive:
try: try:
subprocess_run(cmd, capture_output=True, check=True) subprocess_run(cmd, capture_output=True, check=True)
return targetdir return targetdir
except FileNotFoundError: except (FileNotFoundError, CalledProcessError):
missing.append(cmd[0])
except CalledProcessError:
pass pass
if missing:
raise OSError(f'Extraction failed, try downloading {missing}')
else:
raise OSError(EXTRACTION_ERROR) raise OSError(EXTRACTION_ERROR)
def addFile(self, sourcefile): def addFile(self, sourcefile):