Skip to content

Commit

Permalink
util.py refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 15, 2024
1 parent c393a7c commit 54fb8c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
11 changes: 2 additions & 9 deletions apio/managers/unpacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@
from tarfile import open as tarfile_open
from time import mktime
from zipfile import ZipFile

import click

from apio import util


class UnsupportedArchiveType(util.ApioException):
"""DOC: TODO"""

MESSAGE = "Can not unpack file '{0}'"


class ArchiveBase:
"""DOC: TODO"""

Expand Down Expand Up @@ -137,7 +129,8 @@ def __init__(self, archpath: Path, dest_dir=Path(".")):

# -- Archive type not known!! Raise an exception!
if not self._unpacker:
raise UnsupportedArchiveType(archpath)
click.secho(f"Can not unpack file '{archpath}'")
raise util.ApioException()

def start(self) -> bool:
"""Start unpacking the file"""
Expand Down
12 changes: 2 additions & 10 deletions apio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,10 @@


class ApioException(Exception):
"""DOC: TODO"""

MESSAGE = None

def __str__(self): # pragma: no cover
if self.MESSAGE:
return self.MESSAGE.format(*self.args)

return Exception.__str__(self)
"""Apio error"""


class AsyncPipe(Thread): # pragma: no cover
class AsyncPipe(Thread):
"""DOC: TODO"""

def __init__(self, outcallback=None):
Expand Down

0 comments on commit 54fb8c0

Please sign in to comment.