summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2004-11-01 19:39:12 +0000
committerNarayan Desai <desai@mcs.anl.gov>2004-11-01 19:39:12 +0000
commit9d37273b46ca395dd8b4dc6be38f77d1e4061098 (patch)
tree628d9624f7e6e6b0e704660016b8b895dd15c285 /src/lib
parent9677bd2cc9f2d0fbcfe50a3eab1013edfc5b4d43 (diff)
downloadbcfg2-9d37273b46ca395dd8b4dc6be38f77d1e4061098.tar.gz
bcfg2-9d37273b46ca395dd8b4dc6be38f77d1e4061098.tar.bz2
bcfg2-9d37273b46ca395dd8b4dc6be38f77d1e4061098.zip
add __str__ method
add fix __cmp__ method (Logical change 1.137) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@619 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Metadata.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/Server/Metadata.py b/src/lib/Server/Metadata.py
index dfcf04b27..541a1e30d 100644
--- a/src/lib/Server/Metadata.py
+++ b/src/lib/Server/Metadata.py
@@ -34,11 +34,21 @@ class Metadata(object):
return False
return True
+ def __str__(self):
+ return "Image:%s, classes:%s, b:%s, attr:%s, host:%s" % (self.image, self.classes,
+ self.bundles, self.attributes, self.hostname)
+
def __cmp__(self, other):
fields = ['image', 'classes', 'bundles', 'attributes', 'hostname']
- sum1 = [x for x in range(len(fields)) if getattr(self, fields[x])][0]
- sum2 = [x for x in range(len(fields)) if getattr(other, fields[x])][0]
- return sum1 < sum2
+ try:
+ most1 = [x for x in range(len(fields)) if getattr(self, fields[x])][0]
+ except:
+ most1 = 0
+ try:
+ most2 = [x for x in range(len(fields)) if getattr(other, fields[x])][0]
+ except:
+ most2 = 0
+ return most1 < most2
class Profile(object):
def __init__(self, xml):