ntt / eveapi

Python library for accessing the EVE Online API
Other
148 stars 57 forks source link

Recent fix for row data missing attributes that were defined in the rowset #7

Closed mattjwarren closed 12 years ago

mattjwarren commented 12 years ago

The fix / (commented ; hack ;) ) for row data missing attributes in the rowset seems to have broken some queries.

Running apitest to get alliances, and also a test to get killlog on a character, and getting char sheet info in apitest all return the following error;

Traceback (most recent call last): File "C:/Python27/myevetest.py", line 38, in kills_result=auth.char.Killlog(characterID=char.characterID) File "C:\Python27\lib\site-packages\eveapi.py", line 274, in call return self._root(self._path, **kw) File "C:\Python27\lib\site-packages\eveapi.py", line 362, in call return _ParseXML(response, True, store and (lambda obj: cache.store(self._host, path, kw, response, obj))) File "C:\Python27\lib\site-packages\eveapi.py", line 204, in _ParseXML obj = _Parser().Parse(response, True) File "C:\Python27\lib\site-packages\eveapi.py", line 410, in Parse p.ParseFile(data) File "C:\Python27\lib\site-packages\eveapi.py", line 485, in tag_start if col == attributes[row_idx]: IndexError: list index out of range

mattjwarren commented 12 years ago

I'm poking around for the 'correct' way to fix it, I'll update here if I figure it out.

mattjwarren commented 12 years ago

I have a 'workaround', not sure if this is how it should be done.

Snippet of code in tag_start changed to

            for hdr_idx,col in enumerate(self.container._cols):
                                    try:
                                            if col == attributes[row_idx]:
                                                    fixed.append(_autocast(col, attributes[row_idx+1]))
                                                    row_idx += 2
                                            else:
                                                    fixed.append(None)
                                    except IndexError:
                                            pass

This 'seems' to work - though this is the first time I've tried to use the eve api so not sure of the consequences of my actions - just ignoring the missing values.

ntt commented 12 years ago

Hehe, that will still mess things up, and slows things down a bit too (exceptions that are triggered are rather expensive).

Pushed a fix that ought to work. Let me know if it works so I can close this :)

mattjwarren commented 12 years ago

:P I had a feeling it wasn't quite the way to do it. I'll try the fix tomorrow and let you know :)

mattjwarren commented 12 years ago

Works ok for me, I no longer get the issue I was having when pulling from the Killlog

ntt commented 12 years ago

great. thanks :)