Edgewall Software

Ticket #79 (closed enhancement: worksforme)

Opened 9 years ago

Last modified 9 years ago

ElementTreeStream: wrap ElementTree in a Stream

Reported by: gavin@… Owned by: cmlenz
Priority: major Milestone:
Component: Template engine plugin Version: 0.3.3
Keywords: Cc:


The attached class wraps an ElementTree element to create a genshi.core.Stream. It is probably a drop-in replacement for the current ET function.

This means you can select(...) the stream. Some paths possible with Genshi do not have equivalents in ElementTree, AFAIK, partly because text nodes are just attributes of elements in ET.

As a convenience. the class also unwraps lists passed in, specifically to handle the result of element.findall(...).


ElementTreeStream.py Download (1.0 KB) - added by gavin@… 9 years ago.
Contains the ElementTreeStream? class

Change History

Changed 9 years ago by gavin@…

Contains the ElementTreeStream? class

follow-up: ↓ 2   Changed 9 years ago by cmlenz

  • milestone 0.4 deleted

Can't you just do:

et_stream = Stream(ET(tree))


in reply to: ↑ 1   Changed 9 years ago by anonymous

Replying to cmlenz:

Can't you just do: <snip>

Ah, yes you can. I didn't see that before (time pressure, excuses, etc) :-)

The major differences are that the class based solution allows you to reuse the Stream (but that's only because ET returns a generator), and that it attempts to unwrap lists, which was useful to me.

I prefer the class solution still, but then I wrote it. The original problem can be solved without it, so it's just a convenience now. Close the ticket if it's of no interest.

  Changed 9 years ago by cmlenz

  • status changed from new to closed
  • resolution set to worksforme

For a reusable stream, you can still use:


So yeah, I think this can be closed as “worksforme”.

Add/Change #79 (ElementTreeStream: wrap ElementTree in a Stream)


E-mail address and user name can be saved in the Preferences.

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'
Note: See TracTickets for help on using tickets.