def withAttribute(*args, **attrDict):
 if args:
  attrs = args[:]
 else:
  attrs = attrDict.items()
 attrs = [(k, v) for (k, v) in attrs]
 def pa(s, l, tokens):
  for (attrName, attrValue) in attrs:
   if (attrName not in tokens):
    raise ParseException(s, l, ('no matching attribute ' + attrName))
   if ((attrValue != withAttribute.ANY_VALUE) and (tokens[attrName] != attrValue)):
    raise ParseException(s, l, ("attribute '%s' has value '%s', must be '%s'" % (attrName, tokens[attrName], attrValue)))
 return pa

def withAttribute ( * args , ** attrDict ) : if args : attrs = args [ : ] else : attrs = attrDict . items ( ) attrs = [ ( k , v ) for ( k , v ) in attrs ] def pa ( s , l , tokens ) : for ( attrName , attrValue ) in attrs : if ( attrName not in tokens ) : raise ParseException ( s , l , ( 'no matching attribute ' + attrName ) ) if ( ( attrValue != withAttribute . ANY_VALUE ) and ( tokens [ attrName ] != attrValue ) ) : raise ParseException ( s , l , ( "attribute '%s' has value '%s', must be '%s'" % ( attrName , tokens [ attrName ] , attrValue ) ) ) return pa
helper to create a validating parse action to be used with start tags created with c{l{makexmltags}} or c{l{makehtmltags}} .