# Path: misc_utils.py
# def print_ignore(input):
# 	try:
# 		print input
# 	except UnicodeError:
# 		pass


import sys
import urllib3
import json
import requests
from app.models import *
from pprint import pprint
from date_utils import *
from trueskill_functions import *
from misc_utils import print_ignore
def parse_bracket_entrants(sub_bracket_json, sub_tournament):
	condensed_entrants = sub_bracket_json['entities']['seeds']
	# pprint(condensed_entrants)

	entrant_list = []
	for entrant in condensed_entrants:
		# pprint(entrant)
		entrant_id = str(entrant.get("entrantId"))
		participant_id = str(entrant['mutations']['entrants'][entrant_id]['participantIds'][0])
		player_id = str(entrant['mutations']['entrants'][entrant_id]['playerIds'][participant_id])
		print entrant_id, participant_id, player_id

		entrant_name = entrant['mutations']['entrants'][entrant_id].get("name")
		entrant_info = EntrantInfo(int(entrant_id), entrant_name)

		# entrant['mutations']['players'][entrant_id] returns list containing one dictionary
		entrant_info.player_tag = entrant['mutations']['players'][player_id].get("gamerTag")
		entrant_info.player_prefix = entrant['mutations']['players'][player_id].get("prefix")
		entrant_info.player_id = entrant['mutations']['players'][player_id].get("id")
		entrant_info.player_region = entrant['mutations']['players'][player_id].get("region")
		entrant_info.player_country = entrant['mutations']['players'][player_id].get("country")
		entrant_info.player_state = entrant['mutations']['players'][player_id].get("state")
		entrant_info.player_sub_seed = entrant.get("groupSeedNum")
		entrant_info.player_super_seed = entrant.get("seedNum")
		entrant_info.player_sub_placing = entrant.get("placement")
		entrant_info.player_super_placing = entrant.get("placement")
		entrant_list.append(entrant_info)

	print "\n---ENTRANTS---"
	for entrant in entrant_list:

# Path: misc_utils.py
# def print_ignore(input):
# 	try:
# 		print input
# 	except UnicodeError:
# 		pass


# Path: parsers/parse_smashgg_info.py
import sys
import urllib3
import json
import requests
from app.models import *
from pprint import pprint
from date_utils import *
from trueskill_functions import *
from misc_utils import print_ignore

def parse_bracket_entrants(sub_bracket_json, sub_tournament):
	condensed_entrants = sub_bracket_json['entities']['seeds']
	# pprint(condensed_entrants)

	entrant_list = []
	for entrant in condensed_entrants:
		# pprint(entrant)
		entrant_id = str(entrant.get("entrantId"))
		participant_id = str(entrant['mutations']['entrants'][entrant_id]['participantIds'][0])
		player_id = str(entrant['mutations']['entrants'][entrant_id]['playerIds'][participant_id])
		print entrant_id, participant_id, player_id

		entrant_name = entrant['mutations']['entrants'][entrant_id].get("name")
		entrant_info = EntrantInfo(int(entrant_id), entrant_name)

		# entrant['mutations']['players'][entrant_id] returns list containing one dictionary
		entrant_info.player_tag = entrant['mutations']['players'][player_id].get("gamerTag")
		entrant_info.player_prefix = entrant['mutations']['players'][player_id].get("prefix")
		entrant_info.player_id = entrant['mutations']['players'][player_id].get("id")
		entrant_info.player_region = entrant['mutations']['players'][player_id].get("region")
		entrant_info.player_country = entrant['mutations']['players'][player_id].get("country")
		entrant_info.player_state = entrant['mutations']['players'][player_id].get("state")
		entrant_info.player_sub_seed = entrant.get("groupSeedNum")
		entrant_info.player_super_seed = entrant.get("seedNum")
		entrant_info.player_sub_placing = entrant.get("placement")
		entrant_info.player_super_placing = entrant.get("placement")
		entrant_list.append(entrant_info)

	print "\n---ENTRANTS---"
	for entrant in entrant_list:

		print_ignore(entrant)