mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 14:13:33 -07:00
Convert ProcessResult to NamedTuple
This commit is contained in:
parent
51fb55495d
commit
7937b6df0a
1 changed files with 6 additions and 15 deletions
|
@ -5,28 +5,19 @@ import requests
|
||||||
from core import logger
|
from core import logger
|
||||||
|
|
||||||
|
|
||||||
class ProcessResult:
|
class ProcessResult(typing.NamedTuple):
|
||||||
def __init__(self, message: str, status_code: int):
|
status_code: int
|
||||||
self.message = message
|
message: str
|
||||||
self.status_code = status_code
|
|
||||||
|
|
||||||
def __iter__(self) -> typing.Tuple[int, str]:
|
|
||||||
return self.status_code, self.message
|
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
def __bool__(self) -> bool:
|
||||||
return not bool(self.status_code)
|
return not bool(self.status_code)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return 'Processing {0}: {1}'.format(
|
status = 'succeeded' if bool(self) else 'failed'
|
||||||
'succeeded' if bool(self) else 'failed',
|
return f'Processing {self.message}: {status}'
|
||||||
self.message,
|
|
||||||
)
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return '<ProcessResult {0}: {1}>'.format(
|
return f'<ProcessResult {self.status_code}: {self.message}>'
|
||||||
self.status_code,
|
|
||||||
self.message,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def command_complete(url, params, headers, section):
|
def command_complete(url, params, headers, section):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue