Exemplo n.º 1
0
    def get_phase_groups(self):
        assert (self.id is not None
                ), "tournament id cannot be None if calling get_phase_groups"

        phase_groups = []
        data = NI.query(queries.get_tournament_phase_groups, {'id': self.id})
        validate_data(data)

        tournament_data = data['data']['tournament']
        if tournament_data is None:
            raise NoTournamentDataException(self.slug)

        event_data = tournament_data['events']
        if event_data is None:
            raise NoEventDataException(self.slug)

        phase_groups_data = [event['phaseGroups'] for event in event_data]
        for phase_group in phase_groups_data:
            if phase_group is None:
                raise NoPhaseGroupDataException(self.slug)
            [
                phase_groups.append(PhaseGroup.parse(phase_group_data))
                for phase_group_data in phase_group
            ]

        return phase_groups
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    def get(id: int):
        assert (id is not None), "PhaseGroup.get cannot have None for id parameter"
        data = NI.query(queries.phase_group_by_id, {'id': id})
        validate_data(data)
        PhaseGroup.validate_data(data['data'])

        base_data = data['data']['phaseGroup']
        return PhaseGroup.parse(base_data)
Exemplo n.º 5
0
 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
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
    def get(slug: str):
        assert (slug is not None), "Tournament.get must have a slug parameter"
        data = NI.query(queries.get_tournament_by_slug, {'slug': slug})
        validate_data(data)

        try:
            tournament_data = data['data']['tournament']
            if tournament_data is None:
                raise NoTournamentDataException(slug)

            return Tournament.parse(tournament_data)
        except AttributeError as e:
            raise NoTournamentDataException(slug)
Exemplo n.º 8
0
    def get_by_id(id: int):
        assert (id
                is not None), "Tournament.get_by_id must have an id parameter"
        data = NI.query(queries.get_tournament, {'id': id})
        validate_data(data)

        try:
            tournament_data = data['data']['tournament']
            if tournament_data is None:
                raise NoTournamentDataException(id)

            return Tournament.parse(tournament_data)
        except AttributeError as e:
            raise NoTournamentDataException(id)
Exemplo n.º 9
0
    def get_by_id(id: int):
        assert (
            id
            is not None), "Event.get_by_id cannot have None for id parameter"
        data = NI.query(queries.get_event_by_id, {'id': id})
        validate_data(data)

        try:
            event_data = data['data']['event']
            if event_data is None:
                raise NoEventDataException(id)

            return Event.parse(event_data)
        except AttributeError as e:
            raise NoEventDataException(id)
Exemplo n.º 10
0
    def get_events(self):
        assert (
            self.id
            is not None), "tournament id cannot be None if calling get_events"
        data = NI.query(queries.get_tournament_events, {'id': self.id})
        validate_data(data)

        tournament_data = data['data']['tournament']
        if tournament_data is None:
            raise NoTournamentDataException(self.slug)

        base_data = tournament_data['events']
        if base_data is None:
            raise NoEventDataException(self.slug)

        return [Event.parse(event_data) for event_data in base_data]
Exemplo n.º 11
0
    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
        ]
Exemplo n.º 12
0
    def get(tournament_slug: str, event_slug: str):
        assert (tournament_slug is not None
                ), 'Event.get cannot have None for tournament_slug parameter'
        assert (
            event_slug
            is not None), 'Event.get cannot have None for event_slug parameter'
        slug = "tournament/{0}/event/{1}".format(tournament_slug, event_slug)
        data = NI.query(queries.get_event_by_slugs, {"slug": slug})
        validate_data(data)

        try:
            event_data = data['data']['event']
            if event_data is None:
                raise NoEventDataException('{}:{}'.format(
                    tournament_slug, event_slug))

            return Event.parse(event_data)
        except AttributeError as e:
            raise NoEventDataException('{}:{}'.format(tournament_slug,
                                                      event_slug))
Exemplo n.º 13
0
 def get(id: int):
     assert (id is not None), 'Stream cannot have a None id'
     data = NI.query(queries.stream_by_id, {'id': id})
     base_data = data['data']['stream']
     return Stream.parse(base_data)