def get_stars_or_forks(gh,repos,what,org_name,Verbose=False): dates = {} # get all the data for r in repos: if Verbose: print("Fetching %s for %s : %s" % (what, org_name,r.name)) if what is 'stars': items = r.get_stargazers_with_dates() elif what is 'forks': items = r.get_forks() else: items = r.get_watchers() cc.avoid_rate_limiting(gh) for sg in items: while True: cc.avoid_rate_limiting(gh) try: if what is 'stars': d = sg.starred_at else: d = sg.created_at if d not in dates: dates[d]=0 dates[d] += 1 except: print("WTF. Failed on item, ", sg, " sleeping for 30") time.sleep(30) continue break # break out of while loop # convert all the data first_day = None last_day = None count = 0 counts={} for d in sorted(dates): if first_day is None: first_day = d day = (d - first_day).days count += dates[d] counts[day] = count last_day = day days = list(range(last_day+1)) stars = [] last_stars=0 for i in range(last_day+1): try: last_stars = counts[i] except KeyError: pass stars.append(last_stars) return(days,stars)
def get_stars_or_forks(gh, repos, what, org_name, Verbose=False): dates = {} # get all the data for r in repos: if Verbose: print("Fetching %s for %s : %s" % (what, org_name, r.name)) if what is 'stars': items = r.get_stargazers_with_dates() else: items = r.get_forks() for sg in items: cc.avoid_rate_limiting(gh) if what is 'stars': d = sg.starred_at else: d = sg.created_at if d not in dates: dates[d] = 0 dates[d] += 1 # convert all the data first_day = None last_day = None count = 0 counts = {} for d in sorted(dates): if first_day is None: first_day = d day = (d - first_day).days count += dates[d] counts[day] = count last_day = day days = list(range(last_day + 1)) stars = [] last_stars = 0 for i in range(last_day + 1): try: last_stars = counts[i] except KeyError: pass stars.append(last_stars) return (days, stars)
def avoid_rate_limiting(gh,limit=100,Verbose=False): cortx_community.avoid_rate_limiting(gh,limit,Verbose)
def avoid_rate_limiting(gh): cortx_community.avoid_rate_limiting(gh)