Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #This python script gets you attrinutes for any object
  2.  
  3. import requests
  4. import json
  5.  
  6. #Call ESI
  7. Input = input("Give type ID: ")
  8.  
  9. Url = "https://esi.tech.ccp.is/latest/universe/types/"+Input+"/?datasource=tranquility&language=en-us"
  10.  
  11. #Uncomment this to get SISI stats
  12. #Url = "https://esi.tech.ccp.is/latest/universe/types/"+Input+"/?datasource=singularity&language=en-us"
  13.  
  14. EsiResponse = requests.get(Url)
  15. NPCStats = EsiResponse.json()
  16.  
  17. #Find out what each of the dogma IDs mean
  18. try:
  19. #Load cached dogma attribute ID info
  20. attributes = json.load(open('attributes.txt'))
  21. except FileNotFoundError:
  22. #No file found. Start from scratch
  23. attributes = {}
  24.  
  25. length = len(NPCStats['dogma_attributes'])
  26.  
  27. for n in range(0, length):
  28. DogmaID = NPCStats['dogma_attributes'][n]['attribute_id']
  29. if not str(DogmaID) in attributes:
  30. #Find what this ID is for
  31. print('Getting info on dogma attribute ID', DogmaID)
  32. Url = "https://esi.tech.ccp.is/latest/dogma/attributes/"+str(DogmaID)+"/?datasource=tranquility"
  33. attributes[str(DogmaID)] = requests.get(Url).json()['display_name']
  34.  
  35. #Save the ID list
  36. with open('attributes.txt', 'w') as outfile:
  37. json.dump(attributes, outfile)
  38.  
  39. #Print the output
  40.  
  41. print('\n----')
  42. print('Type ID:', NPCStats['type_id'])
  43. print('Name:', NPCStats['name'])
  44. print('----')
  45. print('Attributes:')
  46.  
  47. for n in range(0, length):
  48. DogmaID = NPCStats['dogma_attributes'][n]['attribute_id']
  49. if attributes[str(DogmaID)]:
  50. #Print only for those that have display name for the attribute
  51. value = NPCStats['dogma_attributes'][n]['value']
  52. print( attributes[str(DogmaID)],value, sep = ': ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement