EOFilter like functionality in Python

4 views
Skip to first unread message

Adam Tauno Williams

unread,
Aug 24, 2010, 7:56:15 PM8/24/10
to gr...@googlegroups.com
I'm closing in on my goal of reimplementing OpenGroupware in Python; and
it's been fun so far.

One of the last features to reimplement depends on the EOFilter class.
EOFilter is sort of like a pre-cursor of LINQ. I have give it a
collection of objects [really, just about anything] and a query *string*
and it returns the objects that match the described criteria. Anyone
know of something like this in Pythong?

An EOFilter string might look like: "objectId == 10100 OR objectId ==
10003 OR objectId == 10005" and it would return all the objects in the
collection that have an attribute/property named "objectId" that has a
value of 10100, 10003, or 10005. A bit odd, but actually pretty handy.

--
Adam Tauno Williams <awil...@whitemice.org> LPIC-1, Novell CLA
<http://www.whitemiceconsulting.com>
OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

Dave Brondsema

unread,
Aug 24, 2010, 9:01:16 PM8/24/10
to gr...@googlegroups.com
Adam Tauno Williams wrote:
> I'm closing in on my goal of reimplementing OpenGroupware in Python; and
> it's been fun so far.
>
> One of the last features to reimplement depends on the EOFilter class.
> EOFilter is sort of like a pre-cursor of LINQ. I have give it a
> collection of objects [really, just about anything] and a query *string*
> and it returns the objects that match the described criteria. Anyone
> know of something like this in Pythong?
>
> An EOFilter string might look like: "objectId == 10100 OR objectId ==
> 10003 OR objectId == 10005" and it would return all the objects in the
> collection that have an attribute/property named "objectId" that has a
> value of 10100, 10003, or 10005. A bit odd, but actually pretty handy.

If the grammar of this string is really this simple, I'd just split on
'OR' and then on '==' and put it through some loops. Or, if the input
is more complex but internal-only, you could just eval() it.

Otherwise I'm guessing you probably will have to write a parser for this
mini-language. I haven't used it, but the internets point at
http://pyparsing.wikispaces.com/

--
Dave Brondsema : da...@brondsema.net
http://www.brondsema.net : personal
http://www.splike.com : programming
<><

signature.asc
Reply all
Reply to author
Forward
0 new messages