def run(argv=None): """Main code body :returns None """ known_args, extra = parse_command_line_args(argv) # set parameters for github object gh = GitHub(owner=known_args.owner, repositories=known_args.repositories.split(','), resources=known_args.resources.split(',')) # read until data is depleted data = gh.read() while data is not None: # do something with the data write_to_file(data=data) # read next batch of data data = gh.read()
def test_data(self): """Test the api output of github.py""" with open('tests/actual_data.json', 'r') as json_file: expected_dict_output = json.load(json_file) gh = GitHub(owner='moby', repositories=['moby', 'toolkit', 'tool'], resources=['issues', 'commits', 'pull_requests']) actual_dict_outut = gh.read() # check if matched self.assertEqual(actual_dict_outut['data'], expected_dict_output)
from github import GitHub if __name__ == "__main__": owner = "moby" repo = ["buildkit", "tool"] resources = ["issues", "commits", "pulls"] gh = GitHub(owner, repo, resources) data = gh.read() while data is not None: print(data) # here do something with data (save in db) print("############## GOING TO NEXT PAGE ################") data = gh.read()