Guest User

Untitled

a guest
Jan 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. ########################################
  2. # DO NOT CHANGE ANYTHING BELOW THIS LINE
  3. ########################################
  4.  
  5. import sys
  6.  
  7. from boardgamegeek.api import BoardGameGeek
  8.  
  9. bgg = BoardGameGeek()
  10.  
  11.  
  12. def compare(users, status):
  13. master_list = []
  14. for user in users:
  15. collection = bgg.collection(user_name=user)
  16. if status == 'all':
  17. master_list.append([item.name for item in collection.items])
  18. else:
  19. master_list.append([item.name for item in collection.items if getattr(item, status)])
  20. return [val for val in master_list[0] if val in master_list[1]]
  21.  
  22.  
  23. if __name__ == '__main__':
  24. options = [
  25. 'all',
  26. 'for_trade',
  27. 'owned',
  28. 'prev_owned',
  29. 'want',
  30. 'wishlist',
  31. ]
  32.  
  33. users = sys.argv[1:3]
  34. # if there are more than 2 args, and the 3rd arg is valid
  35. if len(sys.argv[1:4]) > 2 and sys.argv[3] in options:
  36. status = sys.argv[3]
  37. # else default to only owned games
  38. else:
  39. status = 'owned'
  40.  
  41. try:
  42. print compare(users, status)
  43. except Exception, e:
  44. print "An error occurred, please try again."
Add Comment
Please, Sign In to add comment