Edgewall Software

Opened 9 years ago

Closed 9 years ago

#79 closed enhancement (worksforme)

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(...).

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by gavin@…

Contains the ElementTreeStream? class

comment:1 follow-up: Changed 9 years ago by cmlenz

  • Milestone 0.4 deleted

Can't you just do:

et_stream = Stream(ET(tree))


comment:2 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.

comment:3 Changed 9 years ago by cmlenz

  • Resolution set to worksforme
  • Status changed from new to closed

For a reusable stream, you can still use:


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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain cmlenz.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.