def _set_siteinfo(self):
        """
        capture API sitematrix data in data attribute
        """
        data = self._load_response('siteinfo').get('query')

        mostviewed = data.get('mostviewed')
        self.data['mostviewed'] = []
        for item in mostviewed[1:]:
            if item['ns'] == 0:
                self.data['mostviewed'].append(item)

        general = data.get('general')

        self.params.update({'title': general.get('sitename')})
        self.params.update({'lang': general.get('lang')})
        self.data['site'] = general.get('wikiid')

        info = {}
        for item in general:
            ginfo = general.get(item)
            if ginfo:
                info[item] = ginfo
        self.data['info'] = info

        siteviews = data.get('siteviews')
        if siteviews:
            values = [x for x in siteviews.values() if x]
            if values:
                self.data['siteviews'] = int(sum(values) / len(values))
            else:
                self.data['siteviews'] = 0

        stats = data.get('statistics')
        for item in stats:
            self.data[item] = stats[item]
def _set_siteinfo ( self ) : data = self . _load_response ( 'siteinfo' ) . get ( 'query' ) mostviewed = data . get ( 'mostviewed' ) self . data [ 'mostviewed' ] = [ ] for item in mostviewed [ 1 : ] : if item [ 'ns' ] == 0 : self . data [ 'mostviewed' ] . append ( item ) general = data . get ( 'general' ) self . params . update ( { 'title' : general . get ( 'sitename' ) } ) self . params . update ( { 'lang' : general . get ( 'lang' ) } ) self . data [ 'site' ] = general . get ( 'wikiid' ) info = { } for item in general : ginfo = general . get ( item ) if ginfo : info [ item ] = ginfo self . data [ 'info' ] = info siteviews = data . get ( 'siteviews' ) if siteviews : values = [ x for x in siteviews . values ( ) if x ] if values : self . data [ 'siteviews' ] = int ( sum ( values ) / len ( values ) ) else : self . data [ 'siteviews' ] = 0 stats = data . get ( 'statistics' ) for item in stats : self . data [ item ] = stats [ item ]
capture API sitematrix data in data attribute