Gael: question about your patch to limit values to just entities

6 views
Skip to first unread message

Matthew Wilson

unread,
Aug 28, 2009, 1:40:17 PM8/28/09
to pytho...@googlegroups.com, Gael Pasgrimaud
Hi Gael,

I merged your patch commit 82f1b229741f9d189c8bb6927ebbba82988fef06 last week:

- return sorted(dd.items(), key=lambda t: t[1], reverse=True)
+ return sorted([(e, c) for e, c in dd.items() if isinstance(e, Entity)],
+ key=lambda t: t[1], reverse=True)

I discovered a small side effect. My Bag class has a contents
property that describes the count and type of the entities inside.
For example, this is what the contents of the pitz project are:

>>> p.contents
'(80 task entities, 4 status entities, 3 milestone entities, 2 comment
entities, 2 component entities, 2 person entities, 1 estimate
entities)'

The contents property uses the the values method on bags to count up
the type of all the entities inside. But now, after your patch, the
type attributes are skipped, so then p.contents looks like this:

>>> p.contents
'()'

I'm going to take your patch out for now and I added in some doctests
on pitz.bag.Bag.contents to verify that Bag.contents works right.

Can I add an optional parameter to Bag.values or can I add a new
method to do what you want? I am guessing that you need this for
something in pitzW.

I want to make this Bag.values method work for you and me.

--
W. Matthew Wilson
ma...@tplus1.com
http://tplus1.com

Gaël Pasgrimaud

unread,
Aug 28, 2009, 8:16:55 PM8/28/09
to pytho...@googlegroups.com
Hi,
No problem. I do this because .values() break the choose_options when
I use pitz-add.
Maybe you can just check that printed values are real entities in
choose_options.

Btw I admit that I havent try to run the tests before submiting. My
fault. I will in the futur.

--
Gael

Matthew Wilson

unread,
Aug 28, 2009, 9:00:13 PM8/28/09
to pytho...@googlegroups.com
Oh, no worries. I think there's something broken in the choose_values
method and I'll try to fix that.

Matt
Reply all
Reply to author
Forward
0 new messages