Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class PkgAlreadyInstalled(ManagerError):
fmt_message = 'package already installed'
class PkgConflictsWithInstalled(ManagerError):
fmt_message = 'package folders conflict with installed package {self.conflicts[0]}'
def __init__(self, conflicts: Sequence[Pkg]) -> None:
from .resolvers import Defn
super().__init__()
self.conflicts = [Defn.from_pkg(c) for c in conflicts]
class PkgConflictsWithForeign(ManagerError):
fmt_message = 'package folders conflict with {self.folders}'
def __init__(self, folders: Set[str]) -> None:
super().__init__()
self.folders = ', '.join(f"'{f}'" for f in folders)
class PkgNonexistent(ManagerError):
fmt_message = 'package does not exist'
class PkgFileUnavailable(ManagerError):
fmt_message = 'package file is not available for download'
def __init__(self, detailed_message: Optional[str] = None) -> None:
super().__init__()
def __init__(self, conflicts: Sequence[Pkg]) -> None:
from .resolvers import Defn
super().__init__()
self.conflicts = [Defn.from_pkg(c) for c in conflicts]
class PkgConflictsWithForeign(ManagerError):
fmt_message = 'package folders conflict with {self.folders}'
def __init__(self, folders: Set[str]) -> None:
super().__init__()
self.folders = ', '.join(f"'{f}'" for f in folders)
class PkgNonexistent(ManagerError):
fmt_message = 'package does not exist'
class PkgFileUnavailable(ManagerError):
fmt_message = 'package file is not available for download'
def __init__(self, detailed_message: Optional[str] = None) -> None:
super().__init__()
self.detailed_message = detailed_message
@property
def message(self) -> str:
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
self.detailed_message = detailed_message
@property
def message(self) -> str:
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
fmt_message = 'package is not installed'
class PkgSourceInvalid(ManagerError):
fmt_message = 'package source is invalid'
class PkgUpToDate(ManagerError):
fmt_message = 'package is up to date'
class PkgStrategyUnsupported(ManagerError):
fmt_message = '{self.strategy.name!r} strategy is not valid for source'
def __init__(self, strategy: Strategies) -> None:
super().__init__()
self.strategy = strategy
class InternalError(ManagerResult, Exception):
fmt_message = 'instawow encountered an error'
def __init__(self, error: Exception) -> None:
super().__init__()
def adorn_result(result: E.ManagerResult):
if isinstance(result, E.InternalError):
return self._warning_symbol
elif isinstance(result, E.ManagerError):
return self._failure_symbol
return self._success_symbol
self.new_pkg = new_pkg
class PkgRemoved(ManagerResult):
fmt_message = 'removed'
def __init__(self, old_pkg: Pkg) -> None:
super().__init__()
self.old_pkg = old_pkg
class ManagerError(ManagerResult, Exception):
pass
class PkgAlreadyInstalled(ManagerError):
fmt_message = 'package already installed'
class PkgConflictsWithInstalled(ManagerError):
fmt_message = 'package folders conflict with installed package {self.conflicts[0]}'
def __init__(self, conflicts: Sequence[Pkg]) -> None:
from .resolvers import Defn
super().__init__()
self.conflicts = [Defn.from_pkg(c) for c in conflicts]
class PkgConflictsWithForeign(ManagerError):
fmt_message = 'package folders conflict with {self.folders}'
self.conflicts = [Defn.from_pkg(c) for c in conflicts]
class PkgConflictsWithForeign(ManagerError):
fmt_message = 'package folders conflict with {self.folders}'
def __init__(self, folders: Set[str]) -> None:
super().__init__()
self.folders = ', '.join(f"'{f}'" for f in folders)
class PkgNonexistent(ManagerError):
fmt_message = 'package does not exist'
class PkgFileUnavailable(ManagerError):
fmt_message = 'package file is not available for download'
def __init__(self, detailed_message: Optional[str] = None) -> None:
super().__init__()
self.detailed_message = detailed_message
@property
def message(self) -> str:
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
fmt_message = 'package is not installed'
class PkgSourceInvalid(ManagerError):
fmt_message = 'package does not exist'
class PkgFileUnavailable(ManagerError):
fmt_message = 'package file is not available for download'
def __init__(self, detailed_message: Optional[str] = None) -> None:
super().__init__()
self.detailed_message = detailed_message
@property
def message(self) -> str:
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
fmt_message = 'package is not installed'
class PkgSourceInvalid(ManagerError):
fmt_message = 'package source is invalid'
class PkgUpToDate(ManagerError):
fmt_message = 'package is up to date'
class PkgStrategyUnsupported(ManagerError):
fmt_message = '{self.strategy.name!r} strategy is not valid for source'
def __init__(self, strategy: Strategies) -> None:
super().__init__()
async def acapture(awaitable: Awaitable[ManagerResult]) -> ManagerResult:
"Capture errors in coroutines."
try:
return await awaitable
except ManagerError as error:
return error
except Exception as error:
logger.exception('error!')
return InternalError(error)
fmt_message = 'package file is not available for download'
def __init__(self, detailed_message: Optional[str] = None) -> None:
super().__init__()
self.detailed_message = detailed_message
@property
def message(self) -> str:
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
fmt_message = 'package is not installed'
class PkgSourceInvalid(ManagerError):
fmt_message = 'package source is invalid'
class PkgUpToDate(ManagerError):
fmt_message = 'package is up to date'
class PkgStrategyUnsupported(ManagerError):
fmt_message = '{self.strategy.name!r} strategy is not valid for source'
def __init__(self, strategy: Strategies) -> None:
super().__init__()
self.strategy = strategy
class InternalError(ManagerResult, Exception):
return self.detailed_message or super().message
class PkgNotInstalled(ManagerError):
fmt_message = 'package is not installed'
class PkgSourceInvalid(ManagerError):
fmt_message = 'package source is invalid'
class PkgUpToDate(ManagerError):
fmt_message = 'package is up to date'
class PkgStrategyUnsupported(ManagerError):
fmt_message = '{self.strategy.name!r} strategy is not valid for source'
def __init__(self, strategy: Strategies) -> None:
super().__init__()
self.strategy = strategy
class InternalError(ManagerResult, Exception):
fmt_message = 'instawow encountered an error'
def __init__(self, error: Exception) -> None:
super().__init__()
self.error = error