def find_live_by_search_query_with_selection(q, limit=25, sort="", order="desc", report_type=["fork","commit","issue_event"]): results = search.search_raw(q, limit=limit, sort=sort, order=order) if results["total_count"] == 0: print "No Repositories Matched Your Query" return False else: if results["total_count"] <= limit: print "{} Repositories Found".format(results["total_count"]) else: print "{} repositories found, showing first {}".format(results["total_count"], limit) print print "{:<5} {:^20} {:^30} {:>9} {:>9} {:>9}".format("", "user","repo","score","stars","forks") show_list = map(lambda x:{"user":x["owner"]["login"],"repo":x["name"],"stars":x["stargazers_count"],"forks":x["forks_count"]}, results["items"]) for idx, item in enumerate(show_list): print "{:<5} {:<20.20} {:<30.30} {:>9} {:>9} {:>9}".format("[{}]".format(idx), item["user"],item["repo"],score.pre_score(stars=item["stars"],forks=item["forks"]),item["stars"],item["forks"]) print choice = __get_choice_from_input(limit) results = {"items":[results["items"][choice]]} if "fork" in report_type: fork_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["forks_url"])] for item in results["items"]] fork_history.find_raws(fork_params) for item in results["items"]: with open("tmp/username.txt", "w") as out: out.write(str(item["owner"]["login"])) if "commit" in report_type: commit_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["commits_url"])] for item in results["items"]] commit_history.find_raws(commit_params) if "issue_event" in report_type: event_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["issue_events_url"])] for item in results["items"]] issue_event_history.find_raws(event_params) return True
def find_live_by_search_query(q, limit=10, sort="", order="desc", report_type=["fork","commit","issue_event"]): results = search.search_raw(q, limit=limit, sort=sort, order=order) if "fork" in report_type: fork_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["forks_url"])] for item in results["items"]] fork_history.find_raws(fork_params) if "commit" in report_type: commit_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["commits_url"])] for item in results["items"]] commit_history.find_raws(commit_params) if "issue_event" in report_type: event_params = [[item["owner"]["login"], item["name"], re.sub("{.*}", "", item["issue_events_url"])] for item in results["items"]] issue_event_history.find_raws(event_params)