# HG changeset patch # User athomas # Date 1181150170 0 # Node ID df5b79f27e9d1bd8c6f2ba5991ceeda78761e06b # Parent 317a7f4e3c69cf1f8d0ac0ea1506d3253f4ee489 More flexible transformation attribute set and delete. Attribute selections are now marked explicitly in the transform stream. diff --git a/genshi/filters/transform.py b/genshi/filters/transform.py --- a/genshi/filters/transform.py +++ b/genshi/filters/transform.py @@ -51,8 +51,8 @@ from genshi.core import Stream, Attrs, QName, TEXT, START, END, _ensure from genshi.path import Path -__all__ = ['Transformer', 'StreamBuffer', 'InjectorTransformation', 'ENTER', - 'EXIT', 'INSIDE', 'OUTSIDE'] +__all__ = ['Transformer', 'StreamBuffer', 'AttributeBuffer', + 'InjectorTransformation', 'ENTER', 'EXIT', 'INSIDE', 'OUTSIDE'] class TransformMark(str): @@ -76,6 +76,10 @@ """Stream augmentation mark indicating that a match occurred outside a selected element.""" +ATTRIBUTE = TransformMark('ATTRIBUTE') +"""Stream augmentation mark indicating that a an element attribute was +selected.""" + EXIT = TransformMark('EXIT') """Stream augmentation mark indicating that a selected element is being exited.""" @@ -129,7 +133,7 @@ taken when using buffers, to ensure that buffers are cleared between transforms: - >>> emphasis = Transformer('body//em').setattr('class', 'emphasis') + >>> emphasis = Transformer('body//em').attr('class', 'emphasis') >>> print html | emphasis