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


import sys
import urllib3
import json
import requests
import challonge
from app.models import *
from bs4 import BeautifulSoup
from pprint import pprint
from date_utils import *
from trueskill_functions import *
from misc_utils import print_ignore
	sub_bracket_info.host = sub_bracket['subdomain']

	# Inherited from parent tournament header
	sub_bracket_info.parent = tournament_info.name
	sub_bracket_info.bracket_type = tournament_info.bracket_type
	sub_bracket_info.game_type = tournament_info.game_type
	print sub_bracket_info

	sub_tournament = import_sub_tournament_info(sub_bracket_info)
	# Process bracket entrants and sets, passing bracket object info
	entrant_list = process_entrants(sub_bracket_info, sub_tournament)
	process_sets(sub_bracket_info, entrant_list, sub_tournament)

def process_entrants(sub_bracket_info, sub_tournament):
	entrants = challonge.participants.index(sub_bracket_info.id)
	# pprint(entrants)

	entrant_list = []
	for entrant in entrants:
		entrant_info = EntrantInfo(entrant['display-name'])
		entrant_info.id = int(entrant['id'])
		entrant_info.account_name = entrant['name']
		entrant_info.sub_seed = entrant['seed']
		entrant_info.super_seed = entrant['seed']
		entrant_info.sub_placing = entrant['final-rank'] # If tournament not finished, None. have to parse
		entrant_info.super_placing = entrant['final-rank'] # If tournament not finished, None. have to parse
		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/challonge_parse.py
import sys
import urllib3
import json
import requests
import challonge
from app.models import *
from bs4 import BeautifulSoup
from pprint import pprint
from date_utils import *
from trueskill_functions import *
from misc_utils import print_ignore

	sub_bracket_info.host = sub_bracket['subdomain']

	# Inherited from parent tournament header
	sub_bracket_info.parent = tournament_info.name
	sub_bracket_info.bracket_type = tournament_info.bracket_type
	sub_bracket_info.game_type = tournament_info.game_type
	print sub_bracket_info

	sub_tournament = import_sub_tournament_info(sub_bracket_info)
	# Process bracket entrants and sets, passing bracket object info
	entrant_list = process_entrants(sub_bracket_info, sub_tournament)
	process_sets(sub_bracket_info, entrant_list, sub_tournament)

def process_entrants(sub_bracket_info, sub_tournament):
	entrants = challonge.participants.index(sub_bracket_info.id)
	# pprint(entrants)

	entrant_list = []
	for entrant in entrants:
		entrant_info = EntrantInfo(entrant['display-name'])
		entrant_info.id = int(entrant['id'])
		entrant_info.account_name = entrant['name']
		entrant_info.sub_seed = entrant['seed']
		entrant_info.super_seed = entrant['seed']
		entrant_info.sub_placing = entrant['final-rank'] # If tournament not finished, None. have to parse
		entrant_info.super_placing = entrant['final-rank'] # If tournament not finished, None. have to parse
		entrant_list.append(entrant_info)

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

		print_ignore(entrant)