[virt-tools-list] [virt-manager PATCH v2 3/3] osdict: adapt latest_regex() to ignore "-unknown" distros

Pavel Hrdina phrdina at redhat.com
Fri Nov 16 12:07:12 UTC 2018


On Fri, Oct 19, 2018 at 06:54:54PM +0200, Fabiano Fidêncio wrote:
> There may be case where enterprise distros decide to adopt the "unknown"
> approach in osinfo-db and there we'll be able to see different versions
> of "unknown" and in order to avoid those to be shown to the user, let's
> just ignore them when matching the regex.
> 
> This approach seems less error prone then trying to do that in the regex
> itself and that's the reason it's been taken.

So if I understand it correctly this patch should cover a case where
we will have distro-unknown, distro7-unknown, distro7.6, distro7.5,
where we should end up with distro7.6 instead of distro7-unknown right?

Regex can be a bit tricky but I think that this should work:

"distro[0-9]+(?!-unknown)"

or to match the following code exactly:

"distro[0-9]+(?!-unknown$)"

which would result in using only regex to match the OS name.

Pavel

> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  virtinst/osdict.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/virtinst/osdict.py b/virtinst/osdict.py
> index ec9aa430..98104553 100644
> --- a/virtinst/osdict.py
> +++ b/virtinst/osdict.py
> @@ -235,7 +235,7 @@ class _OSDB(object):
>          """
>          Return the latest distro name that matches the passed regex
>          """
> -        oses = [o.name for o in self.list_os() if re.match(regex, o.name)]
> +        oses = [o.name for o in self.list_os() if re.match(regex, o.name) and not o.name.endswith("-unknown")]
>          if not oses:
>              return None
>  
> -- 
> 2.19.1
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20181116/195331a2/attachment.sig>


More information about the virt-tools-list mailing list