scripts/get_traffic.py
def get_referrers(self, url='', headers={}, repo_name=''):
        """
        Retrieves the total referrers and unique referrers of all repos in json
        and then stores it in a dict.
        """
        #JSON
        url_referrers = (url + '/traffic/popular/referrers')
        r1 = requests.get(url_referrers, headers=headers)
        referrers_json = r1.json()
        self.referrers_json[repo_name] = referrers_json
        #CSV
        for referrer in referrers_json:
            ref_name = referrer['referrer']
            try:
                tuple_in = (referrer['count'], referrer['uniques'])#curr vals
                tuple = (self.referrers[ref_name][0] + tuple_in[0],#cal new vals
                    self.referrers[ref_name][1] + tuple_in[1])
                self.referrers[ref_name] = tuple#record new vals
            except KeyError:
                tuple = self.referrers[ref_name] = (referrer['count'],
                    referrer['uniques'])
                self.referrers_lower[ref_name.lower()] = ref_name
def get_referrers(self, url='', headers={}, repo_name=''):
        #JSON
        url_referrers = (url + '/traffic/popular/referrers')
        r1 = requests.get(url_referrers, headers=headers)
        referrers_json = r1.json()
        self.referrers_json[repo_name] = referrers_json
        #CSV
        for referrer in referrers_json:
            ref_name = referrer['referrer']
            try:
                tuple_in = (referrer['count'], referrer['uniques'])#curr vals
                tuple = (self.referrers[ref_name][0] + tuple_in[0],#cal new vals
                    self.referrers[ref_name][1] + tuple_in[1])
                self.referrers[ref_name] = tuple#record new vals
            except KeyError:
                tuple = self.referrers[ref_name] = (referrer['count'],
                    referrer['uniques'])
                self.referrers_lower[ref_name.lower()] = ref_name
def get_referrers ( self , url = '' , headers = { } , repo_name = '' ) : #JSON url_referrers = ( url + '/traffic/popular/referrers' ) r1 = requests . get ( url_referrers , headers = headers ) referrers_json = r1 . json ( ) self . referrers_json [ repo_name ] = referrers_json #CSV for referrer in referrers_json : ref_name = referrer [ 'referrer' ] try : tuple_in = ( referrer [ 'count' ] , referrer [ 'uniques' ] ) #curr vals tuple = ( self . referrers [ ref_name ] [ 0 ] + tuple_in [ 0 ] , #cal new vals self . referrers [ ref_name ] [ 1 ] + tuple_in [ 1 ] ) self . referrers [ ref_name ] = tuple #record new vals except KeyError : tuple = self . referrers [ ref_name ] = ( referrer [ 'count' ] , referrer [ 'uniques' ] ) self . referrers_lower [ ref_name . lower ( ) ] = ref_name
Retrieves the total referrers and unique referrers of all repos in json
        and then stores it in a dict.
Retrieves the total referrers and unique referrers of all repos in json and then stores it in a dict .