This repository has been archived by the owner on Jul 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from ayust/aegis
Add API changes from the Aegis Sovereignty patch.
- Loading branch information
Showing
15 changed files
with
322 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from evelink import api | ||
|
||
def parse_bookmarks(api_results): | ||
result = {} | ||
folders = api_results.find('rowset') | ||
for row in folders.findall('row'): | ||
a = row.attrib | ||
folder_id = int(a['folderID']) | ||
folder = { | ||
'id': folder_id, | ||
'name': a['folderName'], # "" = toplevel | ||
'creator_id': int(a['creatorID']), | ||
'bookmarks': {}, | ||
} | ||
bookmarks = row.find('rowset') | ||
for row in bookmarks.findall('row'): | ||
a = row.attrib | ||
bookmark_id = int(a['bookmarkID']) | ||
folder['bookmarks'][bookmark_id] = { | ||
'id': bookmark_id, | ||
'name': a['memo'], | ||
'creator_id': int(a['creatorID']), | ||
'created_ts': api.parse_ts(a['created']), | ||
'item_id': int(a['itemID']), | ||
'type_id': int(a['typeID']), | ||
'location_id': int(a['locationID']), | ||
'x': float(a['x']), | ||
'y': float(a['y']), | ||
'z': float(a['z']), | ||
'note': a['note'], | ||
} | ||
result[folder_id] = folder | ||
return result | ||
|
||
# vim: set ts=4 sts=4 sw=4 et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,57 @@ | ||
|
||
LABEL_MAP = { | ||
CONTACTS_MAP = { | ||
'allianceContactList': 'alliance', | ||
'corporateContactList': 'corp', | ||
'contactList': 'personal', | ||
} | ||
|
||
LABEL_MAP = { | ||
'contactLabels': 'personal', | ||
'corporateContactLabels': 'corp', | ||
'allianceContactLabels': 'alliance', | ||
} | ||
|
||
|
||
def parse_contact_list(api_result): | ||
result = {} | ||
result = {'labels': {}} | ||
for rowset in api_result.findall('rowset'): | ||
contact_list = result[LABEL_MAP[rowset.get('name')]] = {} | ||
for row in rowset.findall('row'): | ||
in_watchlist = (row.get('inWatchlist') == 'True' | ||
if 'inWatchlist' in row.attrib | ||
else None) | ||
contact_id = int(row.get('contactID')) | ||
contact_list[contact_id] = { | ||
'id': contact_id, | ||
'name': row.get('contactName'), | ||
'standing': float(row.get('standing')), | ||
'in_watchlist': in_watchlist | ||
} | ||
setname = rowset.get('name') | ||
|
||
if setname in CONTACTS_MAP: | ||
contact_list = result[CONTACTS_MAP[rowset.get('name')]] = {} | ||
for row in rowset.findall('row'): | ||
in_watchlist = (row.get('inWatchlist') == 'True' | ||
if 'inWatchlist' in row.attrib | ||
else None) | ||
contact_id = int(row.get('contactID')) | ||
contact_list[contact_id] = { | ||
'id': contact_id, | ||
'name': row.get('contactName'), | ||
'standing': float(row.get('standing')), | ||
'in_watchlist': in_watchlist, | ||
'label_mask': int(row.get('labelMask') or 0), | ||
'labels': {}, | ||
} | ||
elif setname in LABEL_MAP: | ||
label_list = result['labels'][LABEL_MAP[setname]] = {} | ||
for row in rowset.findall('row'): | ||
label_id = int(row.get('labelID')) | ||
label_list[label_id] = { | ||
'id': label_id, | ||
'name': row.get('name'), | ||
} | ||
for grouping in ('personal', 'corp', 'alliance'): | ||
group = result.get(grouping) | ||
if not group: | ||
continue | ||
labels = result['labels'][grouping] | ||
for contact_id in group: | ||
contact = group[contact_id] | ||
labelMask = contact['label_mask'] | ||
if labelMask: | ||
for label_id in labels: | ||
if labelMask & label_id: | ||
contact['labels'][label_id] = labels[label_id] | ||
del contact['label_mask'] | ||
|
||
return result | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from tests.compat import unittest | ||
from tests.utils import make_api_result | ||
|
||
from evelink.parsing import bookmarks as evelink_b | ||
|
||
class BookmarksTestCase(unittest.TestCase): | ||
|
||
def test_parse_bookmarks(self): | ||
api_result, _, _ = make_api_result("char/bookmarks.xml") | ||
|
||
result = evelink_b.parse_bookmarks(api_result) | ||
|
||
self.assertEqual(result, { | ||
0: { | ||
'bookmarks': { | ||
12: { | ||
'created_ts': 1436391254, | ||
'creator_id': 90000001, | ||
'id': 12, | ||
'item_id': 60014689, | ||
'location_id': 30004971, | ||
'name': 'Home Station', | ||
'note': 'Our base of residence', | ||
'type_id': 57, | ||
'x': 0.0, | ||
'y': 0.0, | ||
'z': 0.0, | ||
}, | ||
13: { | ||
'created_ts': 1436391307, | ||
'creator_id': 90000001, | ||
'id': 13, | ||
'item_id': 40314792, | ||
'location_id': 30004971, | ||
'name': 'Sun', | ||
'note': '', | ||
'type_id': 8, | ||
'x': 0.0, | ||
'y': 0.0, | ||
'z': 0.0, | ||
}, | ||
}, | ||
'creator_id': 0, | ||
'id': 0, | ||
'name': '', | ||
}, | ||
1: { | ||
'bookmarks': {}, | ||
'creator_id': 90000001, | ||
'id': 1, | ||
'name': 'A lovely empty folder', | ||
}, | ||
4: { | ||
'bookmarks': { | ||
14: { | ||
'created_ts': 1436391368, | ||
'creator_id': 90000001, | ||
'id': 14, | ||
'item_id': 0, | ||
'location_id': 30004971, | ||
'name': 'spot in Duripant solar system', | ||
'note': '', | ||
'type_id': 5, | ||
'x': -373405654941.733, | ||
'y': 42718621667.0746, | ||
'z': -1415023302173.46, | ||
}, | ||
}, | ||
'creator_id': 90000001, | ||
'id': 4, | ||
'name': 'Random crap', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.