mrmiguez / pymods

process MODS records from Python
https://pypi.python.org/pypi/pymods
MIT License
18 stars 0 forks source link

Element comparison errors when sorting NamedTuples #14

Open mrmiguez opened 5 years ago

mrmiguez commented 5 years ago

Some pymods.Record functions that return sorted lists of NamedTuples including lxml elements cause comparison error when there is a repeated element.

Given the structure:

<name>
  <namePart>Cash</namePart>
</name>
<name>
  <namePart>Cash</namePart>
</name>

pymods will create the tuples: Name('Cash', '', '', '', '', '', lxml.Element pointer A) Name('Cash', '', '', '', '', '', lxml.Element pointer B)

The only unique tuple element for sorting is the element pointer, but comparisons between lxml.Elements is not allowed:

TypeError: '<' not supported between instances of 'lxml.etree._Element' and 'lxml.etree._Element'

Really there's no reason for any pymods.Record function or property to return a sorted list. Removing the sort()'s would easily fix this.