On 7/1/14, 9:38 AM, Werner wrote:
Hi,

The next challenge is the Py3 doesn't have dict.sort nor cmp, most of
the time it is just replace it with sorted, but the following is a bit
different.

How best change line 737 in ReportDesigner to be compatible with Py2 and
Py3?

elements.sort(rw._elementSort)

I think it should be:

elements = sorted(elements, key=new_elementSort method)

But I don't understand how the current _elementSort works.

The current _elementSort is a cmp() function, accepting 2 elements (x and y) and then returning -1 if x<y, 0 if x==y, or 1 if y>x.

The positions dict has keys on element names mapped to relative positions (for consistent output ordering in the rfxml so that simply opening and saving the report doesn't result in a diff).

If the positions are equal, that last line simply runs the default string comparison, which is a catch-all in case a newly-added element was forgotten about.

Paul

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to