aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2012-06-22 23:04:12 +0000
committerMichael Elkins <melkins@tislabs.com>2012-06-22 23:04:12 +0000
commit25a4ac351ac538fc36690f267c25a31e71471996 (patch)
tree60afa3bce42d76f71e168ad752e6a6afa83eff71
parentb7523fb848bf27899dc6dea6172e1e05e7381b4d (diff)
add __repr__ method to rpki.rcynic.validation_status_element
svn path=/trunk/; revision=4552
-rw-r--r--rpkid/rpki/rcynic.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/rpkid/rpki/rcynic.py b/rpkid/rpki/rcynic.py
index b7e493ec..b05586ff 100644
--- a/rpkid/rpki/rcynic.py
+++ b/rpkid/rpki/rcynic.py
@@ -3,8 +3,6 @@ Prototype of an iterator class to parse the output of an rcynic run.
This script will almost certainly move to the library package once
it's stable.
-$Id$
-
Copyright (C) 2010-2011 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
@@ -20,6 +18,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
+__revision__ = '$Id$'
+
import sys, os, rpki.x509, rpki.exceptions
from xml.etree.ElementTree import ElementTree
@@ -189,8 +189,12 @@ class rcynic_file_iterator(object):
class validation_status_element(object):
def __init__(self, *args, **kwargs):
+ self.attrs = []
for k,v in kwargs.iteritems():
setattr(self, k, v)
+ # attribute names are saved so that the __repr__ method can
+ # display the subset of attributes the user specified
+ self.attrs.append(k)
self._obj = None
def get_obj(self):
@@ -198,6 +202,11 @@ class validation_status_element(object):
self._obj = self.file_class(filename=self.filename, uri=self.uri)
return self._obj
+ def __repr__(self):
+ v = [self.__class__.__name__, 'id=%s' % str(id(self))]
+ v.extend(['%s=%s' % (x, getattr(self, x)) for x in self.attrs])
+ return '<%s>' % (' '.join(v),)
+
obj = property(get_obj)
class rcynic_xml_iterator(object):