Ńň űătHc@sŢdZyeWn#ej oddklZnXddklZlZlZl Z l Z l Z l Z l Z ddddgZdZdefd „ƒYZd „Zdefd „ƒYZdefd „ƒYZeƒZd S(sSupport for programmatically generating markup streams from Python code using a very simple syntax. The main entry point to this module is the `tag` object (which is actually an instance of the ``ElementFactory`` class). You should rarely (if ever) need to directly import and use any of the other classes in this module. Elements can be created using the `tag` object using attribute access. For example: >>> doc = tag.p('Some text and ', tag.a('a link', href='http://example.org/'), '.') >>> doc This produces an `Element` instance which can be further modified to add child nodes and attributes. This is done by "calling" the element: positional arguments are added as child nodes (alternatively, the `Element.append` method can be used for that purpose), whereas keywords arguments are added as attributes: >>> doc(tag.br) >>> print doc

Some text and a link.

If an attribute name collides with a Python keyword, simply append an underscore to the name: >>> doc(class_='intro') >>> print doc

Some text and a link.

As shown above, an `Element` can easily be directly rendered to XML text by printing it or using the Python ``str()`` function. This is basically a shortcut for converting the `Element` to a stream and serializing that stream: >>> stream = doc.generate() >>> stream #doctest: +ELLIPSIS >>> print stream

Some text and a link.

The `tag` object also allows creating "fragments", which are basically lists of nodes (elements or text) that don't have a parent element. This can be useful for creating snippets of markup that are attached to a parent element later (for example in a template). Fragments are created by calling the `tag` object, which returns an object of type `Fragment`: >>> fragment = tag('Hello, ', tag.em('world'), '!') >>> fragment >>> print fragment Hello, world! i˙˙˙˙(tSet(tAttrstMarkupt NamespacetQNametStreamtSTARTtENDtTEXTtFragmenttElementtElementFactoryttagsrestructuredtext encBszeZdZdgZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „ZRS( s_Represents a markup fragment, which is basically just a list of element or text nodes. tchildrencCs g|_dS(sCreate a new fragment.N(R (tself((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__init__YscCstƒ||ƒS(N(R (Rtother((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__add__]scGst|i|ƒ|S(sXAppend any positional arguments as child nodes. :see: `append` (tmaptappend(Rtargs((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__call__`scCs |iƒS(N(t _generate(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__iter__hscCsd|iiS(Ns<%s>(t __class__t__name__(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__repr__kscCst|iƒƒS(N(tstrtgenerate(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__str__nscCst|iƒƒS(N(tunicodeR(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt __unicode__qscCst|iƒƒS(N(RR(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt__html__tscCs˛t|ttttttfƒo|ii|ƒnyt|t ƒo|ii |iƒnR|dj oDyt |it |ƒƒWqŽtj o|ii|ƒqŽXndS(sÇAppend an element or string as child node. :param node: the node to append; can be an `Element`, `Fragment`, or a `Stream`, or a Python string or number N(t isinstanceRR t basestringtinttfloattlongR RR textendtNoneRtitert TypeError(Rtnode((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyRws" ccs x™|iD]Ž}t|tƒo xu|iƒD] }|Vq-Wq t|tƒoxE|D] }|VqWWq t|tƒpt|ƒ}nt|dfVq WdS(Ni˙˙˙˙(Ni˙˙˙˙i˙˙˙˙( R R!R RRR"RRR'(Rtchildtevent((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyR‰s    cCst|iƒƒS(sYReturn a markup event stream for the fragment. :rtype: `Stream` (RR(R((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyR–s(Rt __module__t__doc__t __slots__RRRRRRRR RRR(((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyR Ss           cCs›g}tƒ}x|iƒD]q\}}|idƒiddƒ}|dj o=||jo0|it|ƒt|ƒfƒ|i|ƒqqWt |ƒS(Nt_t-( tsettitemstrstriptreplaceR'RRRtaddR(tkwargstattrstnamestnametvalue((s4/usr/lib64/python2.6/site-packages/genshi/builder.pyt_kwargs_to_attrsžs  cBsGeZdZddgZd„Zd„Zd„Zd„Zd„ZRS(s( Simple XML output generator based on the builder pattern. Construct XML elements by passing the tag name to the constructor: >>> print Element('strong') Attributes can be specified using keyword arguments. The values of the arguments will be converted to strings and any special XML characters escaped: >>> print Element('textarea', rows=10, cols=60)