Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
axu2 committed Aug 5, 2024
1 parent 9e09898 commit 3e90dd6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions kindlecomicconverter/comicarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ def type(self):
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)
Expand All @@ -67,7 +65,6 @@ def extract(self, 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],
]
missing = []

if distro.id() == 'fedora':
extraction_commands.append(
Expand All @@ -78,15 +75,10 @@ def extract(self, targetdir):
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']:
Expand Down

0 comments on commit 3e90dd6

Please sign in to comment.