Skip to content

Commit 2cadd06

Browse files
committed
Merge branch 'master' into debian
2 parents 44e6f65 + aa0b457 commit 2cadd06

18 files changed

+113
-23
lines changed

CONTRIBUTING.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ Guidelines for Contributing to github3.py
33

44
#. Read the README_
55

6+
#. Please do **not** use the issue tracker for questions.
7+
8+
#. Please use GitHub's search feature to look for already reported issues
9+
before reporting your own.
10+
611
#. Regardless of the magnitude your pull request (a couple lines to a couple
712
hundred lines), please add your name to the AUTHORS.rst_ file under the
813
heading Contributors.

HISTORY.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
History/Changelog
22
-----------------
33

4+
0.8.2: 2014-02-11
5+
~~~~~~~~~~~~~~~~~
6+
7+
- Fix bug in ``GitHub#search_users`` (and ``github3.search_users``). Thanks
8+
@abesto
9+
10+
- Expose the stargazers count for repositories. Thanks @seveas
11+
12+
0.8.1: 2014-01-26
13+
~~~~~~~~~~~~~~~~~
14+
15+
- Add documentation for using Two Factor Authentication
16+
17+
- Fix oversight where ``github3.login`` could not be used for 2FA
18+
419
0.8.0: 2014-01-03
520
~~~~~~~~~~~~~~~~~
621

MANIFEST.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ include README.rst
22
include LICENSE
33
include HISTORY.rst
44
include AUTHORS.rst
5+
include CONTRIBUTING.rst
6+
include tox.ini
7+
include report_issue.py
58
prune *.pyc
6-
recursive-include github3/
7-
recursive-include docs/
9+
recursive-include docs *.rst *.py Makefile
10+
recursive-include tests *.py *.json
11+
recursive-include tests/json *
12+
recursive-include images *.png
813
prune docs/_build

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ requests>=2.0.0,<=3.0.0
22
uritemplate.py==0.2.0
33
#coverage==3.5.2
44
mock==1.0.1
5-
pytest==2.3.5
5+
pytest>=2.3.5
66
wheel==0.21.0
77
git+git://github.com/sigmavirus24/betamax

docs/examples/two_factor_auth.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Using Two Factor Authentication with github3.py
2+
===============================================
3+
4+
GitHub recently added support for Two Factor Authentication to ``github.com``
5+
and shortly thereafter added support for it on ``api.github.com``. In version
6+
0.8, github3.py also added support for it and you can use it right now.
7+
8+
To use Two Factor Authentication, you must define your own function that will
9+
return your one time authentication code. You then provide that function when
10+
logging in with github3.py.
11+
12+
For example:
13+
14+
.. code::
15+
16+
import github3
17+
18+
try:
19+
# Python 2
20+
prompt = raw_input
21+
except NameError:
22+
# Python 3
23+
prompt = input
24+
25+
def my_two_factor_function():
26+
code = ''
27+
while not code:
28+
# The user could accidentally press Enter before being ready,
29+
# let's protect them from doing that.
30+
code = prompt('Enter 2FA code: ')
31+
return code
32+
33+
g = github3.login('sigmavirus24', 'my_password',
34+
two_factor_callback=my_two_factor_function)
35+
36+
Then each the API tells github3.py it requires a Two Factor Authentication
37+
code, github3.py will call ``my_two_factor_function`` which prompt you for it.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ More Examples
4444
.. toctree::
4545
:maxdepth: 2
4646

47+
examples/two_factor_auth
4748
examples/oauth
4849
examples/gist
4950
examples/git

github3/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
66
See http://github3py.rtfd.org/ for documentation.
77
8-
:copyright: (c) 2012-2013 by Ian Cordasco
8+
:copyright: (c) 2012-2014 by Ian Cordasco
99
:license: Modified BSD, see LICENSE for more details
1010
1111
"""
1212

1313
__title__ = 'github3'
1414
__author__ = 'Ian Cordasco'
1515
__license__ = 'Modified BSD'
16-
__copyright__ = 'Copyright 2012-2013 Ian Cordasco'
17-
__version__ = '0.8.0'
16+
__copyright__ = 'Copyright 2012-2014 Ian Cordasco'
17+
__version__ = '0.8.2'
1818
__version_info__ = tuple(int(i) for i in __version__.split('.'))
1919

2020
from github3.api import *

github3/api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def authorize(login, password, scopes, note='', note_url='', client_id='',
3434
client_secret)
3535

3636

37-
def login(username=None, password=None, token=None, url=None):
37+
def login(username=None, password=None, token=None, url=None,
38+
two_factor_callback=None):
3839
"""Construct and return an authenticated GitHub session.
3940
4041
This will return a GitHubEnterprise session if a url is provided.
@@ -43,14 +44,16 @@ def login(username=None, password=None, token=None, url=None):
4344
:param str password: password for the login
4445
:param str token: OAuth token
4546
:param str url: (optional), URL of a GitHub Enterprise instance
47+
:param func two_factor_callback: (optional), function you implement to
48+
provide the Two Factor Authentication code to GitHub when necessary
4649
:returns: :class:`GitHub <github3.github.GitHub>`
4750
4851
"""
4952
g = None
5053

5154
if (username and password) or token:
5255
g = GitHubEnterprise(url) if url is not None else GitHub()
53-
g.login(username, password, token)
56+
g.login(username, password, token, two_factor_callback)
5457

5558
return g
5659

github3/github.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,11 @@ def login(self, username=None, password=None, token=None,
857857
two_factor_callback=None):
858858
"""Logs the user into GitHub for protected API calls.
859859
860-
:param str username: (optional)
861-
:param str password: (optional)
862-
:param str token: (optional)
860+
:param str username: login name
861+
:param str password: password for the login
862+
:param str token: OAuth token
863+
:param func two_factor_callback: (optional), function you implement to
864+
provide the Two Factor Authentication code to GitHub when necessary
863865
"""
864866
if username and password:
865867
self._session.basic_auth(username, password)
@@ -1250,7 +1252,7 @@ def search_users(self, query, sort=None, order=None, per_page=None,
12501252
'Accept': 'application/vnd.github.v3.full.text-match+json'
12511253
}
12521254

1253-
url = self._build_url('search', 'repositories')
1255+
url = self._build_url('search', 'users')
12541256
return SearchIterator(number, url, UserSearchResult, self, params,
12551257
etag, headers)
12561258

github3/repos/repo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ def __init__(self, repo, session=None):
124124
#: Size of the repository.
125125
self.size = repo.get('size', 0)
126126

127+
# The number of stargazers
128+
#: Number of users who starred the repository
129+
self.stargazers = repo.get('stargazers_count', 0)
130+
127131
# SSH url e.g. git@github.com/sigmavirus24/github3.py
128132
#: URL to clone the repository via SSH.
129133
self.ssh_url = repo.get('ssh_url', '')

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
kwargs['tests_require'] = ['mock == 1.0.1', 'betamax >=0.1.6', 'pytest']
2222
if sys.version_info < (3, 0):
2323
kwargs['tests_require'].append('unittest2==0.5.1')
24-
packages.append('tests')
2524

2625
if sys.argv[-1] in ("submit", "publish"):
2726
os.system("python setup.py bdist_wheel sdist upload")
@@ -45,7 +44,7 @@
4544
class PyTest(TestCommand):
4645
def finalize_options(self):
4746
TestCommand.finalize_options(self)
48-
self.test_args = ['-q', 'tests/']
47+
self.test_args = []
4948
self.test_suite = True
5049

5150
def run_tests(self):
@@ -66,8 +65,6 @@ def run_tests(self):
6665
author_email="graffatcolmingov@gmail.com",
6766
url="https://github3py.readthedocs.org",
6867
packages=packages,
69-
package_data={'': ['LICENSE', 'AUTHORS.rst']},
70-
include_package_data=True,
7168
install_requires=requires,
7269
classifiers=[
7370
'Development Status :: 5 - Production/Stable',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"http_interactions": [{"request": {"body": "", "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.0"}, "method": "GET", "uri": "https://api.github.com/search/repositories?q=tom+followers%3A%3E1000&per_page=100"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA7WYW4+jNhSA/0qE1PahmXCHgLTaXqQ+terDTl9aVZEBJ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ZrgzK41Cnt1UGntMbjITbFhTTukimWM8gUESS5FHFzcCltugouxdk4vu8Ep79P/wESGA2ohSUAAA==", "encoding": "utf-8"}, "headers": {"status": "200 OK", "x-ratelimit-remaining": "4", "x-github-media-type": "github.v3; param=full; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0D684:4E6C:5CB8CBD:52BD02E5", "content-encoding": "gzip", "vary": "Accept-Encoding", "server": "GitHub.com", "cache-control": "no-cache", "x-ratelimit-limit": "5", "access-control-allow-credentials": "true", "date": "Fri, 27 Dec 2013 04:32:38 GMT", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1388118818"}, "url": "https://api.github.com/search/repositories?q=tom+followers%3A%3E1000&per_page=100", "status_code": 200}, "recorded_at": "2013-12-27T04:32:38"}], "recorded_with": "betamax"}
1+
{"http_interactions": [{"request": {"body": "", "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.1"}, "method": "GET", "uri": "https://api.github.com/search/users?q=tom+followers%3A%3E1000&per_page=100"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA5WTzW6EIBSF34VkumrE/1GTSdNN36CrpjGIqDQKBtDp1My796LtdDqLNiQmELjf8XAuLMhIQ/qSykkYVAT3iBs2aFS8LKiXLReoQIN8k0MlEezVawmZiSGqnFQPu50xoy4wbtW27FE54G2Kw4TuaZCFYdRUcUhimhIW0Kyu0ibxm7x6qA8rvosed+ETfLxmwnAqhfZabrqpsmqwTmNK4jDKiF/lMIR+TWni5yRt9kkW55U3ivZOHd7B47eP0ppF/zkA4PcxyMivfo0nzZTGPwl0ZuhvD34xelXXyL6XR2Bviv+SxxcIXG1zLlp3AYAWLE3HoEVg/2xD4do4WVmBBdsBgrQSGlquWO1i5wsBM0cBPhas2ChXranSVPHRcOi0k+I1CEJStUTwD+IsBKAG3hpyMrACALIZLqoTuRELHhWfCT3ZGBSjjM+QqbvaDQpi5jQyuPDP0HGbMDzjktSDfcBGTQxWqFRQEPiJ5+dptD+/nj8BnkWGJP0DAAA=", "encoding": "utf-8"}, "headers": {"status": "200 OK", "x-ratelimit-remaining": "9", "x-github-media-type": "github.v3; param=full; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C4D9:5BD7:50C8F65:52F8D7DD", "content-encoding": "gzip", "vary": "Accept-Encoding", "server": "GitHub.com", "cache-control": "no-cache", "x-ratelimit-limit": "10", "access-control-allow-credentials": "true", "date": "Mon, 10 Feb 2014 13:45:01 GMT", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1392039961"}, "url": "https://api.github.com/search/users?q=tom+followers%3A%3E1000&per_page=100", "status_code": 200}, "recorded_at": "2014-02-10T13:45:01"}], "recorded_with": "betamax"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"http_interactions": [{"request": {"body": "", "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full.text-match+json", "User-Agent": "github3.py/0.8.0"}, "method": "GET", "uri": "https://api.github.com/search/repositories?q=tom+followers%3A%3E1000&per_page=100"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA7WaW2/bNhSA/4ohYNvDHOtu2QKK7gLsacOANXvZUBiURNtsdQNFJ02F/Pedo4slym5kiR5aNIrE8/GQIinyQ0tNZILEuzA7pULzraXGBE0Kzf+31Fik+aa9dtfedq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ItSdQvD027ZoVc76oUMl0blMFQCtV3OylUe5u7OCEX0rhJCVlOp4QwSDJC+LAzQnW6CkbIWTmuaQNT3Qg1GgbegoIRQjtz3QPhk74DchoDNNlcTc2zfy6UBBb875SRI+KVlkDQoCF2LbM+vv4Htl4ROs0nAAA=", "encoding": "utf-8"}, "headers": {"status": "200 OK", "x-ratelimit-remaining": "3", "x-github-media-type": "github.v3; param=full.text-match; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0D684:4E6A:A492C97:52BD02E6", "content-encoding": "gzip", "vary": "Accept-Encoding", "server": "GitHub.com", "cache-control": "no-cache", "x-ratelimit-limit": "5", "access-control-allow-credentials": "true", "date": "Fri, 27 Dec 2013 04:32:38 GMT", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1388118818"}, "url": "https://api.github.com/search/repositories?q=tom+followers%3A%3E1000&per_page=100", "status_code": 200}, "recorded_at": "2013-12-27T04:32:38"}], "recorded_with": "betamax"}
1+
{"http_interactions": [{"request": {"body": "", "headers": {"Accept-Charset": "utf-8", "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full.text-match+json", "User-Agent": "github3.py/0.8.1"}, "method": "GET", "uri": "https://api.github.com/search/users?q=tom+followers%3A%3E1000&per_page=100"}, "response": {"body": {"base64_string": "H4sIAAAAAAAAA5WT32vbMBDH/5Vh6J6yyPGPJA6Udi973sPGHkYJsny2VSzJSOe0mcn/vpO9tkkoKwKDzOm+X310pxsjNMi7vTCDxmi3WkQSQblo93uMOtNIHe0iZR6NKk1Ee9WUwg8cud0PtqPdFrF3O8YaO4eXwig2/7IkFxux2iZJWpdZwjOx5rAS26pc13lcF+VddTvJb9KvN8k3+mQFGqUw2i0bie1QejeKi0zwLEm3PC4LWpK4EiKPC76uN/k2K8plr5vP9vaZGF849h42+oiABJfX4L08O5oNDqxjbxVoUXXXF38FPcurTdeZJ9JeJf/Pnr2KiGr+l7oJNyDRyAy2QC0i/JMvinQYhDIJRuYXKqS3cNRyC1UIzj8JwTxp4hiZhd5MXkPphJU9Sup0kOO5kIyMbbiWf3iwEQkd6T1QEMAkICEc6KEGKWfFyHorD1wcfRksCJAHqmm425WUzPDYAz34n9RxX2Ea4z2vlB9gtANQRBhLCas4X8bFOt2QAp5xrziKFuaBN+UjCAzoh+/ArLk8vbemB4tH4gHFZUd5teWNoppRCI26f5tu2jtn8FBzDm1IXUkxwcWL9OH0cFqMLwcGTe1HkJoruGT8YdSn7xYcGv3lF1h6vu9zUt57nJ71L4UGbX5bBQAA", "encoding": "utf-8"}, "headers": {"status": "200 OK", "x-ratelimit-remaining": "8", "x-github-media-type": "github.v3; param=full.text-match; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0C4D9:5BD7:50C9047:52F8D7DD", "content-encoding": "gzip", "vary": "Accept-Encoding", "server": "GitHub.com", "cache-control": "no-cache", "x-ratelimit-limit": "10", "access-control-allow-credentials": "true", "date": "Mon, 10 Feb 2014 13:45:02 GMT", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1392039961"}, "url": "https://api.github.com/search/users?q=tom+followers%3A%3E1000&per_page=100", "status_code": 200}, "recorded_at": "2014-02-10T13:45:02"}], "recorded_with": "betamax"}

tests/integration/helper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import betamax
23
import github3
34
import os
@@ -30,3 +31,20 @@ def cassette_name(self, method, cls=None):
3031
def described_class(self):
3132
class_name = self.__class__.__name__
3233
return class_name[4:]
34+
35+
36+
class CustomHeadersMatcher(betamax.BaseMatcher):
37+
name = 'gh3-headers'
38+
39+
def on_init(self):
40+
self.headers_matcher = betamax.matchers.HeadersMatcher()
41+
42+
def match(self, request, recorded_request):
43+
request = request.copy()
44+
recorded_request = copy.deepcopy(recorded_request)
45+
request.headers.pop('User-Agent', None)
46+
recorded_request['headers'].pop('User-Agent', None)
47+
return self.headers_matcher.match(request, recorded_request)
48+
49+
50+
betamax.Betamax.register_request_matcher(CustomHeadersMatcher)

tests/integration/test_github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class TestGitHub(IntegrationHelper):
20-
match_on = ['method', 'uri', 'headers']
20+
match_on = ['method', 'uri', 'gh3-headers']
2121

2222
def test_create_gist(self):
2323
"""Test the ability of a GitHub instance to create a new gist"""

tests/integration/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_two_factor_authentication_works(self):
1212
cassette_name = self.cassette_name('two_factor_authentication')
1313
assert isinstance(self.session, github3.session.GitHubSession)
1414

15-
match = ['method', 'uri', 'headers']
15+
match = ['method', 'uri', 'gh3-headers']
1616
with self.recorder.use_cassette(cassette_name,
1717
match_requests_on=match):
1818
r = self.session.get('https://api.github.com/users/sigmavirus24')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy