Example #1
0
    def __init__(self, nhl_id, url=None, content=None):
        """
        initialize this Team object

        :param self: reference to a Team instance
        :param nhl_id: the ID of this team as known to NHL.com
        :param url: (optional) url to use to get the data for this object
        :param content: (optional) content for this object instance
        """
        self.url = ''
        self.name = ''
        self.content = {}
        self.nhl_id = nhl_id
        if url is not None:
            self.url = url
        else:
            if self.nhl_id:
                self.url = self.base_url + 'teams/{}'.format(self.nhl_id)
            else:
                self.url = self.base_url + 'teams'
        if content is not None:
            self.content = content
        else:
            self.content = get_json_data(self.url)

        if self.nhl_id and self.content and 'teams' in self.content:
            if 'name' in self.content['teams'][0]:
                self.name = self.content['teams'][0]['name']
Example #2
0
    def __init__(self, url=None, content=None):
        """
        initialize this Schedule object

        :param self: reference to a Schedule instance
        :param url: (optional) url to use to get the data for this object
        :param content: (optional) content for this object instance
        """
        self.url = ''
        self.content = {}
        if url is not None:
            self.url = url
        else:
            self.url = self.base_url + 'schedule'
        if content is not None:
            self.content = content
        else:
            self.content = get_json_data(self.url)
Example #3
0
    def __init__(self, nhl_id, url=None, content=None):
        """
        initialize this Player object

        :param self: reference to a Player instance
        :param nhl_id: the ID of this player as known to NHL.com
        :param url: (optional) url to use to get the data for this object
        :param content: (optional) content for this object instance
        """
        self.url = ''
        self.name = ''
        self.content = {}
        self.nhl_id = nhl_id
        if url is not None:
            self.url = url
        else:
            self.url = self.base_url + 'people/{}'.format(nhl_id)
        if content is not None:
            self.content = content
        else:
            self.content = get_json_data(self.url)

        if self.content and 'people' in self.content and 'fullName' in self.content['people'][0]:
            self.name = self.content['people'][0]['fullName']
Example #4
0
 def load_ext_url(self, *modifiers, **kwargs):
     """ load the values from the extra data specified """
     url = self.get_ext_url(*modifiers, **kwargs)
     self.content = get_json_data(url)