sin = s.decode() else: sin = s sout = '' for a in sin.split('\n'): b = a.split('=') if b[0].rstrip().startswith(keys): b[1] = " '<REPLACE_ME>'" sout += '='.join(b) + '\n' if type(s) is bytes: return sout.encode() else: return sout github = GitHub(get_token) @app.route('/', methods=['GET']) def index(): session['rand'] = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10)) error = request.args.get('error', default='') success = request.args.get('success', default='') if error: return render_template(app.config['INDEX_TEMPLATE'], error=error) elif success: return render_template(app.config['INDEX_TEMPLATE'], success=success) else: return render_template(app.config['INDEX_TEMPLATE'])
#!/usr/bin/env python3 from GitHub import GitHub from GitHubAuth import GitHubAuth if __name__ == "__main__": print('username:'******'password:'******'github', repositories=['training-kit','gh-ost'], resources=['issues','pulls','comments']) # usage example: # - printing ids of all the elements data = gh.read() while data is not None: for item in data: print(item['id']) data = gh.read()
def test_bad_owner(self): obj = GitHub("gfdfgoossssdfsdfds", ["octokit.rb"], ["issues"]) self.assertTrue(type(obj.read()) is HTTPError)
def test_get_commit_succesfully(self): obj = GitHub("octokit", ["octokit.rb"], ["issues", "pull_requests", "commits"]) commit = obj.get_commit("43d0c71969e11b2cfeb529ffd0846043f6f013b5") self.assertTrue("sha" in commit)
def test_no_resource(self): obj = GitHub("octokit", ["octokit.rb"], []) self.assertIsNone(obj.read())
def test_no_owner(self): obj = GitHub("", ["octokit.rb"], ["issues"]) self.assertTrue(type(obj.read()) is HTTPError)
def test_bad_resource(self): obj = GitHub("octokit", ["octokit.rb"], ["sdfssdf"]) self.assertIsNone(obj.read())
def test_bad_repo(self): obj = GitHub("octokit", ["asddd.rb"], ["sdfssdf"]) self.assertIsNone(obj.read())
def test_get_commits(self): obj = GitHub("octokit", ["octokit.rb"], ["commits"]) self.assertTrue(len(obj.read()) > 0)
def test_get_pull_requests_next_page(self): obj = GitHub("octokit", ["octokit.rb"], ["pull_requests"]) obj.read() self.assertIsNone(obj.read())
def test_get_pull_requests(self): obj = GitHub("octokit", ["octokit.rb"], ["pull_requests"]) self.assertTrue(len(obj.read()) > 0)
def test_get_issues_next_page(self): obj = GitHub("octokit", ["octokit.rb"], ["issues"]) obj.read() self.assertTrue(len(obj.read()) > 0)
def test_get_commit_failed(self): obj = GitHub("octokit", ["octokit.rb"], ["issues", "pull_requests", "commits"]) commit = obj.get_commit("dfgndfg") self.assertTrue("sha" not in commit)