feat: add richer results
This commit is contained in:
parent
f8a73a5a92
commit
3691fa9a51
|
@ -331,6 +331,8 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
|||
name = r.name
|
||||
|
||||
url = None
|
||||
revision = None
|
||||
gitref = None
|
||||
if isinstance(version, GetVersionError):
|
||||
kw = version.kwargs
|
||||
kw['name'] = name
|
||||
|
@ -344,10 +346,14 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
|||
version_str = apply_list_options(version, conf)
|
||||
if isinstance(version_str, RichResult):
|
||||
url = version_str.url
|
||||
gitref = version_str.gitref
|
||||
revision = version_str.revision
|
||||
version_str = version_str.version
|
||||
elif isinstance(version, RichResult):
|
||||
version_str = version.version
|
||||
url = version.url
|
||||
gitref = version.gitref
|
||||
revision = version.revision
|
||||
else:
|
||||
version_str = version
|
||||
|
||||
|
@ -356,7 +362,7 @@ def _process_result(r: RawResult) -> Union[Result, Exception]:
|
|||
|
||||
try:
|
||||
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:
|
||||
logger.exception('error occurred in version substitutions', name=name)
|
||||
return e
|
||||
|
|
|
@ -45,6 +45,8 @@ if sys.version_info[:2] >= (3, 10):
|
|||
@dataclass(kw_only=True)
|
||||
class RichResult:
|
||||
version: str
|
||||
gitref: Optional[str] = None
|
||||
revision: Optional[str] = None
|
||||
url: Optional[str] = None
|
||||
|
||||
def __str__(self):
|
||||
|
@ -53,6 +55,8 @@ else:
|
|||
@dataclass
|
||||
class RichResult:
|
||||
version: str
|
||||
gitref: Optional[str] = None
|
||||
revision: Optional[str] = None
|
||||
url: Optional[str] = None
|
||||
|
||||
def __str__(self):
|
||||
|
@ -142,6 +146,8 @@ class Result(NamedTuple):
|
|||
version: str
|
||||
conf: Entry
|
||||
url: Optional[str]
|
||||
gitref: Optional[str]
|
||||
revision: Optional[str]
|
||||
|
||||
class BaseWorker:
|
||||
'''The base class for defining `Worker` classes for source plugins.
|
||||
|
|
Loading…
Reference in New Issue