mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
feat: add richer results
This commit is contained in:
parent
f8a73a5a92
commit
3691fa9a51
2 changed files with 13 additions and 1 deletions
|
@ -331,6 +331,8 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
||||||
name = r.name
|
name = r.name
|
||||||
|
|
||||||
url = None
|
url = None
|
||||||
|
revision = None
|
||||||
|
gitref = None
|
||||||
if isinstance(version, GetVersionError):
|
if isinstance(version, GetVersionError):
|
||||||
kw = version.kwargs
|
kw = version.kwargs
|
||||||
kw['name'] = name
|
kw['name'] = name
|
||||||
|
@ -344,10 +346,14 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
||||||
version_str = apply_list_options(version, conf)
|
version_str = apply_list_options(version, conf)
|
||||||
if isinstance(version_str, RichResult):
|
if isinstance(version_str, RichResult):
|
||||||
url = version_str.url
|
url = version_str.url
|
||||||
|
gitref = version_str.gitref
|
||||||
|
revision = version_str.revision
|
||||||
version_str = version_str.version
|
version_str = version_str.version
|
||||||
elif isinstance(version, RichResult):
|
elif isinstance(version, RichResult):
|
||||||
version_str = version.version
|
version_str = version.version
|
||||||
url = version.url
|
url = version.url
|
||||||
|
gitref = version.gitref
|
||||||
|
revision = version.revision
|
||||||
else:
|
else:
|
||||||
version_str = version
|
version_str = version
|
||||||
|
|
||||||
|
@ -356,7 +362,7 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version_str = substitute_version(version_str, conf)
|
version_str = substitute_version(version_str, conf)
|
||||||
return Result(name, version_str, conf, url)
|
return Result(name, version_str, conf, url, gitref, revision)
|
||||||
except (ValueError, re.error) as e:
|
except (ValueError, re.error) as e:
|
||||||
logger.exception('error occurred in version substitutions', name=name)
|
logger.exception('error occurred in version substitutions', name=name)
|
||||||
return e
|
return e
|
||||||
|
|
|
@ -45,6 +45,8 @@ if sys.version_info[:2] >= (3, 10):
|
||||||
@dataclass(kw_only=True)
|
@dataclass(kw_only=True)
|
||||||
class RichResult:
|
class RichResult:
|
||||||
version: str
|
version: str
|
||||||
|
gitref: Optional[str] = None
|
||||||
|
revision: Optional[str] = None
|
||||||
url: Optional[str] = None
|
url: Optional[str] = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -53,6 +55,8 @@ else:
|
||||||
@dataclass
|
@dataclass
|
||||||
class RichResult:
|
class RichResult:
|
||||||
version: str
|
version: str
|
||||||
|
gitref: Optional[str] = None
|
||||||
|
revision: Optional[str] = None
|
||||||
url: Optional[str] = None
|
url: Optional[str] = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -142,6 +146,8 @@ class Result(NamedTuple):
|
||||||
version: str
|
version: str
|
||||||
conf: Entry
|
conf: Entry
|
||||||
url: Optional[str]
|
url: Optional[str]
|
||||||
|
gitref: Optional[str]
|
||||||
|
revision: Optional[str]
|
||||||
|
|
||||||
class BaseWorker:
|
class BaseWorker:
|
||||||
'''The base class for defining `Worker` classes for source plugins.
|
'''The base class for defining `Worker` classes for source plugins.
|
||||||
|
|
Loading…
Add table
Reference in a new issue