Skip to content

Commit

Permalink
prep work for item changes to use contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wohnlich committed Oct 22, 2014
1 parent 9826e22 commit 6257f70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 3 additions & 5 deletions admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def get_urls(self):
return my_urls + urls

def update_view(self,request):
ids = []
for obj in GearItem.objects.all():
ids.append(obj.id)
ids = GearItem.objects.values_list('id',flat=True)
for data in fetcher.fetch_items(ids):
if data: # might be null if it can't find the id - like new items
self.update_gear(data)
Expand All @@ -37,10 +35,10 @@ def populate_view(self, request):
return render(request, 'gearitem/done.html')

def update_gear(self, gear):
print 'Updating item: %d' % data['id']
print 'Updating item: %d' % gear['id']
obj = GearItem.objects.get(id=gear['id'])
if obj.name != gear['name']:
print 'Warning: %d renamed from %s to %s' % (gear[id],obj.name,gear['name'])
print 'Warning: %d renamed from %s to %s' % (gear['id'],obj.name,gear['name'])
obj.name = gear['name']
obj.nameDescription = gear['desc']
obj.agility = gear['stats'].get('agility',0)
Expand Down
1 change: 1 addition & 0 deletions docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
113931 113891 113968 113943 113902 113982 113917 113929 113875 113865 113971 113930 113892 113966 113955 113915 113863 113985 113944 118114 113885 113899 113954 115549 115545 115546 115547 115548 113867 113919 113877 113888 113827 113826 113853 113657 113652 113849 113647 113611 113593 113608 113839 113641 113654 113851 113612 113843 116038 116314 116047 116050 116046 116037 116388 116304 116036 116039 116034 116044 116299 116041 116040 116049 116042 116035 116051 116033 116048 116045 116309 116026 116029 116279 116027 116032 116284 116025 116294 116367 115800 115796 116028 104399 105670 105683 102248 98148 105585 105584 105472 105617 105486 105637 105482 105487 105429 105602 105432 105530 105527 105623 105407 105624 105559 105454 105507 105638 105526 105508 105410 105455 105553 105451 105558 105639 105580 105483 105612 105562 104589 104588 104476 104621 104490 105840 104641 104486 104491 104433 104606 99406 104436 104534 104531 99402 104627 104411 105847 104628 104563 104458 99403 104511 104642 104530 104512 104414 104459 104557 104455 104562 104643 104584 99404 104487 104616 99405 104566 105336 105335 105223 105368 105237 105388 105809 105233 105238 105180 105754 105800 105353 105183 105281 105278 105374 105158 105375 105310 105205 105779 105258 105772 105389 105277 105259 105161 105206 105304 105202 105309 105390 105331 105762 105234 105363 105313 103962 103888 102292 103891 103887 103935 103963 103885 103889 103776 103750 99168 98614 98605 103780 103930 102301 112754 99157 103886 103749 103781 103844 103953 103838 99158 103731 103931 103934 103782 103730 103836 103732 103841 103843 103837 102302 99159 103842 102311 99167 103890
12 changes: 10 additions & 2 deletions fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@ def do_item(data):
'slot':data['inventoryType'],
'sockets':data['hasSockets'] and data['socketInfo'],
'icon':data['icon'],
'quality':data['quality']}
'quality':data['quality'],}
if 'weaponInfo' in data:
val['weapon_min'] = data['weaponInfo']['damage']['exactMin']
val['weapon_max'] = data['weaponInfo']['damage']['exactMax']
val['weapon_speed'] = data['weaponInfo']['weaponSpeed']
return val

def fetch_items(ids=[]):
import time
gear = []
if not ids:
ids = range(105847,111000)
for i in ids:
#time.sleep(1) # we should really only sleep if it hits the limit, then retry
data = json.load(urllib.urlopen('https://us.api.battle.net/wow/item/%d?apikey=%s' % (i,API_KEY)))
if 'status' in data:
continue
if data['inventoryType'] in good_inventory_slots and data['itemLevel'] >= 553:
if 'inventoryType' not in data and 'availableContexts' in data:
if 'raid-normal' in data['availableContexts']:
data = json.load(urllib.urlopen('https://us.api.battle.net/wow/item/%d/raid-normal?apikey=%s' % (i,API_KEY)))
else:
context = data['availableContexts'][0]
data = json.load(urllib.urlopen('https://us.api.battle.net/wow/item/%d/%s?apikey=%s' % (i,context,API_KEY)))
if data['inventoryType'] in good_inventory_slots:
bstats = stats(data['bonusStats'])
data['bstats'] = bstats
if data['itemClass'] == 4 and data['itemSubClass'] == 3 and 'agility' in bstats: # mail agi
Expand Down

0 comments on commit 6257f70

Please sign in to comment.