Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rowset column have a name, row - doesn't always have an attribute with this name #6

Closed
ave- opened this issue Feb 22, 2012 · 1 comment

Comments

@ave-
Copy link

ave- commented Feb 22, 2012

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.

@ntt
Copy link
Owner

ntt commented Feb 23, 2012

Perfectly clear :) Just pushed a fix.
Thanks!

@ntt ntt closed this as completed Feb 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants