def get_attendees(self): Logger.info('Getting Attendees for Phase: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() attendees = flatten( [phase_group.get_attendees() for phase_group in phase_groups]) return attendees
def get_entrants(self): Logger.info('Getting Entrants for Phase: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() entrants = flatten( [phase_group.get_entrants() for phase_group in phase_groups]) return entrants
def get_phase_groups(self): assert ( self.id is not None), 'event id cannot be None if calling get_phase_groups' Logger.info('Getting Phase Groups for Event: {0}:{1}'.format( self.id, self.name)) data = NI.query(queries.get_event_phase_groups, {'id': self.id}) validate_data(data) try: event_data = data['data']['event'] if event_data is None: raise NoEventDataException(self.identifier) phase_groups_data = event_data['phaseGroups'] if phase_groups_data is None: raise NoPhaseGroupDataException(self.identifier) return [ PhaseGroup.parse(phase_group_data) for phase_group_data in phase_groups_data ] except AttributeError as e: raise Exception( "No phase group data pulled back for event {}".format( self.identifier))
def get_attendees(self): assert (self.id is not None), 'phase group id cannot be None when calling get_attendees' Logger.info('Getting Attendees for phase group: {0}:{1}'.format(self.id, self.display_identifier)) data = NI.paginated_query(queries.phase_group_attendees, {'id': self.id}) participants = flatten([entrant_data['entrant']['participants'] for entrant_data in data]) attendees = [Attendee.parse(participant_data) for participant_data in participants] return attendees
def get_attendees(self): assert (self.id is not None ), "tournament id cannot be None if calling get_attendees" Logger.info('Getting Attendees for Tournament: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() attendees = flatten( [phase_group.get_attendees() for phase_group in phase_groups]) return attendees
def get_sets(self): assert (self.id is not None), 'event id cannot be None if calling get_sets' Logger.info('Getting Sets for Event: {0}:{1}'.format( self.id, self.name)) phase_groups = self.get_phase_groups() sets = flatten( [phase_group.get_sets() for phase_group in phase_groups]) return sets
def get_completed_sets(self): Logger.info('Getting Completed Sets for Phase: {0}:{1}'.format( self.id, self.name)) sets = self.get_sets() complete_sets = [] for ggset in sets: if ggset.get_is_completed() is True: complete_sets.append(ggset) return complete_sets
def get_completed_sets(self): assert (self.id is not None), 'phase group id cannot be None when calling get_completed_sets' Logger.info('Getting Completed Sets for phase group: {0}:{1}'.format(self.id, self.display_identifier)) sets = self.get_sets() incomplete_sets = [] for gg_set in sets: if set.get_is_completed() is True: incomplete_sets.append(gg_set) return incomplete_sets
def get_sets(self): assert ( self.id is not None), 'phase group id cannot be None when calling get_sets' Logger.info('Getting Sets for phase group: {0}:{1}'.format( self.id, self.display_identifier)) data = NI.paginated_query(queries.phase_group_sets, {'id': self.id}) sets = [GGSet.parse(set_data) for set_data in data] return sets
def get_incomplete_sets(self): Logger.info('Getting Incomplete Sets for Phase: {0}:{1}'.format( self.id, self.name)) sets = self.get_sets() incomplete_sets = [] for ggset in sets: if ggset.get_is_completed() is False: incomplete_sets.append(ggset) return incomplete_sets
def get_entrants(self): assert (self.id is not None ), "tournament id cannot be None if calling get_entrants" Logger.info('Getting Entrants for Tournament: {0}:{1}'.format( self.id, self.name)) Logger.warning('Aggregate queries ') phase_groups = self.get_phase_groups() entrants = flatten( [phase_group.get_entrants() for phase_group in phase_groups]) return entrants
def get_entrants(self): assert (self.id is not None ), 'phase group id cannot be None when calling get_entrants' Logger.info('Getting Entrants for phase group: {0}:{1}'.format( self.id, self.display_identifier)) data = NI.paginated_query(queries.phase_group_entrants, {'id': self.id}) entrants = [ Entrant.parse(entrant_data['entrant']) for entrant_data in data ] return entrants
def get_incomplete_sets(self): assert (self.id is not None ), 'event id cannot be None if calling get_incomplete_sets' Logger.info('Getting Incomplete Sets for Event: {0}:{1}'.format( self.id, self.name)) sets = self.get_sets() incomplete_sets = [] for ggset in sets: if ggset.get_is_completed() is False: incomplete_sets.append(ggset) return incomplete_sets
def get_completed_sets(self): assert (self.id is not None ), "tournament id cannot be None if calling get_completed_sets" Logger.info('Getting Completed Sets for Tournament: {0}:{1}'.format( self.id, self.name)) sets = self.get_sets() complete_sets = [] for ggset in sets: if ggset.get_is_completed() is True: complete_sets.append(ggset) return complete_sets
def get_phase_groups(self): assert (self.id is not None ), "phase id cannot be None when calling get_phase_groups" Logger.info('Getting Phase Groups for Phase: {0}:{1}'.format( self.id, self.name)) data = NI.paginated_query(queries.phase_phase_groups, {'id': self.id}) [validate_data(phase_data) for phase_data in data] # Schema Validation [Phase.validate_data(element['data'], self.id) for element in data] phase_data = [phase_data['data']['phase'] for phase_data in data] [PhaseGroup.validate_data(element, self.id) for element in phase_data] phase_group_data = flatten( [element['phaseGroups'] for element in phase_data]) return [ PhaseGroup.parse(phase_group) for phase_group in phase_group_data ]
def init(token: str): log = Logger.get_instance() if not TokenHandler.__initialized: log.info('Checking API token: {}...'.format(token)) if not TokenHandler.__regex.match(token): raise BadTokenException(token) elif len(token) > 32: raise BadTokenException(token) TokenHandler.__token = token TokenHandler.__initialized = True log.info('Legal API Token!')
def setUp(self): Logger.init('info')
Common.dotenv() # dotenv import from smashggpy.util.Initializer import initialize token = os.environ['API_TOKEN'] # general imports from smashggpy.util.Logger import Logger from smashggpy.util.QueryFactory import QueryFactory from smashggpy.util.NetworkInterface import NetworkInterface as NI from smashggpy.util.TokenHandler import TokenHandler from smashggpy.util.QueryQueueDaemon import QueryQueueDaemon # initialize initialize(token) Logger.set_log_level('info') # assign logger singleton log = Logger.get_instance() log.debug('Env: {}'.format(os.environ)) Logger.get_instance().debug('using token: {}'.format(token)) # send query and get data back #to12_top8_phase = Phase.get(172834) #to12_melee = Event.get('tipped-off-12-presented-by-the-lab-gaming-center', 'melee-singles') #log.info(to12_melee) """ sets = to12_melee.get_sets() for ggset in sets: print("{0}: {1} {2} - {3} {4}".format(