aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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):
eb0d
61a8790f





7476eb0d
2625ea19
61a8790f
47620697
61a8790f

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

                                   
 
    
 
                                                            













                                                                                  












                                                                           
 
          
 






                                       


                                                                   

   





                                    
              
 
                             
                    

                                          
"""
Script to generate rpki/relaxng.py.

$Id$

Copyright (C) 2009-2011  Internet Systems Consortium ("ISC")

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

Portions copyright (C) 2007--2008  American Registry for Internet Numbers ("ARIN")

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS.  IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""

import sys

format_1 = """\
# Automatically generated, do not edit.

import lxml.etree
"""

format_2 = """\
## @var %(name)s
## Parsed RelaxNG %(name)s schema
%(name)s = lxml.etree.RelaxNG(lxml.etree.fromstring('''%(rng)s'''))
"""

def filename_to_symbol(s):
  for suffix in (".rng", "-schema"):
    if s.endswith(suffix):
      s = s[:-len(suffix)]
  return s.replace("-", "_")

print format_1

for filename in sys.argv[1:]:
  print format_2 % {
    "name" : filename_to_symbol(filename),
    "rng"  : open(filename).read() }