ntt/eveapi — Issue #6: Rowset column have a name, row - doesn't always have an attribute with this name
Author: ave-
Created: 2012-02-22 20:52:25+00:00
State: open

While working with ContractItems API I've stumbled upon a bug - while columns attribute in rowset always contains name "rawQuantity", row doesn't.
Example XML:

<eveapi version="2">
<currentTime>2012-02-22 18:05:44</currentTime>
<result>
<rowset name="itemList" key="recordID" columns="recordID,typeID,quantity,rawQuantity,singleton,included">
<row recordID="643979193" typeID="16064" quantity="1" singleton="0" included="1"/>
</rowset>
</result>
<cachedUntil>2022-02-19 04:25:56</cachedUntil>
</eveapi>

In current implementation, attributes taken from row are not parsed, it is assumed that columns count in rowset is equal to attributes count in row (or less, but a fix for that is already implemented).
In this situation, columns in row are "shifted" and _included_ column is not even created. Instead, _rawQuality_ is filled with _singleton_ value, and _singleton_ is filled with _included_ value.

I've created a quick hack to remedy this situation (and my Python skill is quite low, so it can be very inefficient), but just by pre-filling a list with zero integer values and then re-filling it by index of column name. I don't like this kind of solution and ask for a more proper variant instead (if any).

Quick (and dirty) fix below:

# <hack>
# - check for missing attributes while columns do exist!
# very ugly hack and dunno what to do with zero values created
#
if (len(attributes)/2 < len(self.container._cols)):
hacklist=[0]*len(self.container._cols) #predef length!
for i in xrange(0, len(attributes), 2):
hacklist[self.container._cols.index(attributes[i])]=_autocast(attributes[i], attributes[i+1])
self.container.append(hacklist)
else:
# </hack>
self.container.append([_autocast(attributes[i], attributes[i+1]) for i in xrange(0, len(attributes), 2)])

P.S. I'm not a native English speaker, so some wordings may be incorrect. Feel free to ask if something is not quite understandable.