On 10/02/2018 07:53 AM, Pino Toscano wrote:
At some point in the future it could be a good idea to drop the _aliases
mapping altogether; it will be hard to do so, in case the users are not
informed that they are using a deprecated ID.


I had a similar thought just a few days ago!

Signed-off-by: Pino Toscano <ptosc...@redhat.com>
---
  virtinst/osdict.py | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 39422233..b78bcedd 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -192,7 +192,14 @@ class _OSDB(object):
                  return osobj
def lookup_os(self, key):
-        key = self._aliases.get(key) or key
+        try:
+            mapped_key = self._aliases[key]
+            logging.warning(_("Using a deprecated Guest osinfo %s, "
+                              "%s will be used instead"),
+                            key, mapped_key)
+            key = mapped_key
+        except KeyError:
+            pass

I kinda hate the EAFP pattern for this type of stuff so I tweaked it. I also tweaked the message to indicate the alias will be removed some day. Pushed now

Thanks,
Cole

_______________________________________________
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to