def test_Pep8(self): text = self.text GP = gs.Github_Profile() gf.get_pep8_errs(text, GP) assert GP.pep8['E1'] == 1 assert GP.pep8['E2'] == 1 assert GP.pep8['E5'] == 1 assert GP.pep8['E7'] == 1 assert GP.pep8['W2'] == 3
def pickle_repo(repo): """ Basic function that scrapes repo data using the Github API and saves it locally as a pickled file, to be used by test_classify() above. """ GP = gs.Github_Profile() url = 'https://api.github.com/repos/%s' % repo repo_path = 'GP_%s.pkl' % (repo.replace('/', '_')) r = gf.get_request(url) if r.ok: item = json.loads(r.text or r.content) gs.get_features(item, GP) joblib.dump(GP, repo_path)
def get_features(item): """ Top-level function that scrapes features for each python file and stores it in a Github_Profile class. """ GP = gs.Github_Profile() contents_url = '%s/contents' % item['url'] # scrape readme gf.get_readme_length(contents_url, GP) # scrape file-by-file stats digest_repo(contents_url, GP) # scrape commit history gf.get_repo_commit_history(item, GP) # scrape stargazers GP.n_stars = item['stargazers_count'] # scrape forks GP.n_forks = item['forks_count'] return GP
def test_readme(self): GP = gs.Github_Profile() url = 'https://api.github.com/repos/silburt/DeepMoon/contents' gf.get_readme_length(url, GP) assert GP.readme_lines == 99