updated tf.py to use better syntax

This commit is contained in:
ipsum 2010-04-16 20:29:12 -04:00
parent f22f4770cd
commit 3a2bd24352
1 changed files with 9 additions and 9 deletions

View File

@ -28,20 +28,20 @@ def tf(inp):
raw_data = urllib.urlopen(url).read().decode('utf-8') raw_data = urllib.urlopen(url).read().decode('utf-8')
try: try:
inv = json.JSONDecoder().decode(raw_data) inv = json.loads(raw_data)
except ValueError: except ValueError:
return '%s is not a valid profile' % inp return '%s is not a valid profile' % inp
dropped,dhats,hats = 0,0,0 dropped,dhats,hats = 0,0,0
for item in inv: for item, data in inv.iteritems():
defindex = int(inv[item]['defindex']) ind = int(data['defindex'])
if inv[item]['inventory'] == 0: if data['inventory'] == 0:
if 47<=defindex<=55 or 94<=defindex<=126 or 134<=defindex<=152: if 47<=ind<=55 or 94<=ind<=126 or 134<=ind<=152:
dhats+=1 dhats+=1
else: else:
dropped+=1 dropped+=1
else: else:
if 47<=defindex<=55 or 94<=defindex<=126 or 134<=defindex<=152: if 47<=ind<=55 or 94<=ind<=126 or 134<=ind<=152:
hats+=1 hats+=1
return '%s has had %s items and %s hats drop (%s total hats)' % (inp,dropped,dhats,dhats+hats) return '%s has had %s items and %s hats drop (%s total hats)' % (inp,dropped,dhats,dhats+hats)