Beispiel #1
0
 def eval(self, s, tag=0):
     # XXX is this just a hack? inside a tag set, there may be sexp
     # with labels like "name" that are meant to be simple key-value
     # pairs and *not* the spki Name objects.  the tag flag tells eval
     # to inpret names in a tag context rather than the normal
     # context.
     name = s[0]
     if not sexp.atom(name):
         # not sure we actually see this case
         name = self.eval(name)
     if tag:
         if name == '*':
             func = 'TagExpr'
         else:
             func = None
     else:
         func = name_to_impl(name)
     if name == 'tag':
         tag = 1
     args = []
     try:
         for elt in s[1:]:
             if sexp.atom(elt):
                 args.append(elt)
             else:
                 args.append(self.eval(elt, tag))
     except IndexError:
         pass
     if self.impls.has_key(func):
         try:
             return apply(self.impls[func], tuple(args))
         except TypeError, err:
             print "Type error in eval:", err, func, `args`
             raise
Beispiel #2
0
def _cleanup(elts):
    """Decode b64 encoding uses in test/sexps.py"""
    from pisces.spkilib import sexp
    clean = []
    for elt in elts:
        if not sexp.atom(elt):
            elt = _cleanup(elt)
        if elt[0] == '|':
            elt = sexp.b64_to_str(elt)
        clean.append(elt)
    return clean