[openlmi-tools] fix instance comparision
Peter Hatina
phatina at fedoraproject.org
Wed Nov 20 07:51:23 UTC 2013
commit cba1e691b97e90936d2dedd4380c52849c377c25
Author: Peter Hatina <phatina at redhat.com>
Date: Wed Nov 20 08:37:34 2013 +0100
fix instance comparision
openlmi-tools-03-fix-instance-comparision.patch | 49 +++++++++++++++++++++++
openlmi-tools.spec | 7 +++-
2 files changed, 55 insertions(+), 1 deletions(-)
---
diff --git a/openlmi-tools-03-fix-instance-comparision.patch b/openlmi-tools-03-fix-instance-comparision.patch
new file mode 100644
index 0000000..0e5e94e
--- /dev/null
+++ b/openlmi-tools-03-fix-instance-comparision.patch
@@ -0,0 +1,49 @@
+diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
+index 126d438..17ca570 100644
+--- a/cli/lmi/shell/LMIInstance.py
++++ b/cli/lmi/shell/LMIInstance.py
+@@ -50,6 +50,22 @@ class LMIInstance(LMIWrapperBaseObject):
+ self.__dict__["_lmi_class"] = lmi_class
+ super(LMIInstance, self).__init__(conn)
+
++ def __cmp__(self, other):
++ """
++ :param LMIInstance other: :py:class:`LMIInstance` object to compare
++ :returns: If both instances are (not) deleted: negative number, if self < other; 0
++ if self == other or positive number, if self > other. If the first or second
++ instance is deleted, -1 or 1 is returned.
++ :rtype: int
++ """
++ if not isinstance(other, LMIInstance):
++ return -1
++ if self._deleted and not other._deleted:
++ return -1
++ elif not self._deleted and other._deleted:
++ return 1
++ return cmp(self._cim_instance, other._cim_instance)
++
+ @lmi_possibly_deleted(False)
+ def __contains__(self, key):
+ """
+diff --git a/cli/lmi/shell/LMIInstanceName.py b/cli/lmi/shell/LMIInstanceName.py
+index 254ddc2..08f8eb7 100644
+--- a/cli/lmi/shell/LMIInstanceName.py
++++ b/cli/lmi/shell/LMIInstanceName.py
+@@ -33,6 +33,17 @@ class LMIInstanceName(LMIWrapperBaseObject):
+ cim_instance_name = cim_instance_name.wrapped_object
+ self._cim_instance_name = cim_instance_name
+
++ def __cmp__(self, other):
++ """
++ :param LMIInstanceName other: :py:class:`LMIInstanceName` object to compare
++ :returns: negative number, if self < other; 0 if self == other or positive
++ number, if self > other
++ :rtype: int
++ """
++ if not isinstance(other, LMIInstanceName):
++ return -1
++ return cmp(self._cim_instance_name, other._cim_instance_name)
++
+ def __contains__(self, key):
+ """
+ :param string key: key name, which will be tested for presence in keybindings
diff --git a/openlmi-tools.spec b/openlmi-tools.spec
index c770ef4..12c6c2c 100644
--- a/openlmi-tools.spec
+++ b/openlmi-tools.spec
@@ -1,6 +1,6 @@
Name: openlmi-tools
Version: 0.9
-Release: 3%{?dist}
+Release: 4%{?dist}
Summary: Set of CLI tools for Openlmi providers
License: GPLv2+
@@ -8,6 +8,7 @@ URL: http://fedorahosted.org/openlmi
Source0: http://fedorahosted.org/released/openlmi-tools/%{name}-%{version}.tar.gz
Patch0: openlmi-tools-01-fix-instance-deletion.patch
Patch1: openlmi-tools-02-fix-passing-instances-to-method-call.patch
+Patch2: openlmi-tools-03-fix-instance-comparision.patch
BuildArch: noarch
BuildRequires: automake
@@ -37,6 +38,7 @@ Summary: Documentation for %{name}
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
%build
pushd cli
@@ -88,6 +90,9 @@ install -m 644 cli/completion/_lmishell $zsh_comp_dir
%{_docdir}/%{name}-%{version}/html
%changelog
+* Wed Nov 20 2013 Peter Hatina <phatina at redhat.com> - 0.9-4
+- fix instance comparision
+
* Wed Nov 6 2013 Peter Hatina <phatina at redhat.com> - 0.9-3
- fix passing instance references to method call
More information about the scm-commits
mailing list