Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 79c9779659b7a3b98209f26008bff46d9f871a08
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Jan 31 15:45:18 2014 +0100
fix LMIInstance(Name) unicode representation
---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 24 +++++++++++++++++-------
cli/lmi/shell/LMIInstanceName.py | 14 ++++++++------
2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index eb00439..430fb91 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -136,20 +136,30 @@ class LMIInstance(LMIWrapperBaseObject):
@lmi_possibly_deleted("")
def __str__(self):
"""
- Returns a string of serialized :py:class:`CIMInstanceName` object.
+ Returns a string containing object path.
**NOTE:** If the method :py:meth:`.LMIInstance.delete` was called, this method
will not execute its code and will return an empty string. If the shell uses
exceptions, :py:exc:`.LMIDeletedObjectError` will be raised.
- :returns: string of serialized :py:class:`CIMInstanceName` object
+ :returns: string containing object path
:raises: :py:exc:`.LMIDeletedObjectError`
"""
- return "%s(classname=\"%s\", %s)" % ( \
- self.__class__.__name__, \
- self.classname, \
- str(self._cim_instance.path) \
- )
+ return unicode(self).encode("utf-8")
+
+ @lmi_possibly_deleted(u"")
+ def __unicode__(self):
+ """
+ Returns an unicode string containing object path.
+
+ **NOTE:** If the method :py:meth:`.LMIInstance.delete` was called, this method
+ will not execute its code and will return an empty string. If the shell uses
+ exceptions, :py:exc:`.LMIDeletedObjectError` will be raised.
+
+ :returns: unicode string containing object path
+ :raises: :py:exc:`.LMIDeletedObjectError`
+ """
+ return unicode(self._cim_instance.path)
@lmi_possibly_deleted("")
def __repr__(self):
diff --git a/cli/lmi/shell/LMIInstanceName.py b/cli/lmi/shell/LMIInstanceName.py
index 51e0a13..01b0e33 100644
--- a/cli/lmi/shell/LMIInstanceName.py
+++ b/cli/lmi/shell/LMIInstanceName.py
@@ -71,13 +71,15 @@ class LMIInstanceName(LMIWrapperBaseObject):
def __str__(self):
"""
- :returns: string of serialized object
+ :returns: string containing object path
"""
- return "%s(classname=\"%s\", %s)" % ( \
- self.__class__.__name__, \
- self.classname, \
- str(self._cim_instance_name) \
- )
+ return unicode(self).encode("utf-8")
+
+ def __unicode__(self):
+ """
+ :returns: unicode string containing object path
+ """
+ return unicode(self._cim_instance_name)
def __repr__(self):
"""