Skip to content

Commit 82cbfb8

Browse files
authored
Merge pull request #38 from jaredhobbs/master
Synchronize repo with PyPI package v2.1
2 parents dbf7014 + d78b731 commit 82cbfb8

File tree

14 files changed

+254
-200
lines changed

14 files changed

+254
-200
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
tags
22
*.py[co]
3+
.*
4+
MANIFEST
5+
dist/*
36
agithub.egg-info/
47
agithub.egg-info/
58
build/

agithub/DigitalOcean.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from agithub.base import *
3+
from agithub.base import API, ConnectionProperties, Client
4+
45

56
class DigitalOcean(API):
6-
'''
7+
"""
78
Digital Ocean API
8-
'''
9+
"""
910
def __init__(self, token=None, *args, **kwargs):
1011
props = ConnectionProperties(
11-
api_url = 'api.digitalocean.com',
12-
url_prefix = '/v2',
13-
secure_http = True,
14-
extra_headers = {
15-
'authorization' : self.generateAuthHeader(token)
16-
})
12+
api_url='api.digitalocean.com',
13+
url_prefix='/v2',
14+
secure_http=True,
15+
extra_headers={
16+
'authorization': self.generateAuthHeader(token)
17+
},
18+
)
1719
self.setClient(Client(*args, **kwargs))
1820
self.setConnectionProperties(props)
1921

agithub/Facebook.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from agithub.base import *
3+
from agithub.base import API, ConnectionProperties, Client
4+
45

56
class Facebook(API):
6-
'''
7+
"""
78
Facebook Graph API
89
910
The following example taken from
@@ -13,12 +14,13 @@ class Facebook(API):
1314
>>> fb.facebook.picture.get(redirect='false')
1415
{u'data': {u'is_silhouette': False,
1516
u'url':
16-
u'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/p50x50/1377580_10152203108461729_809245696_n.png'}})
17-
'''
17+
u'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/
18+
t1.0-1/p50x50/1377580_10152203108461729_809245696_n.png'}})
19+
"""
1820
def __init__(self, *args, **kwargs):
1921
props = ConnectionProperties(
20-
api_url = 'graph.facebook.com'
21-
, secure_http = True
22-
)
22+
api_url='graph.facebook.com',
23+
secure_http=True,
24+
)
2325
self.setClient(Client(*args, **kwargs))
2426
self.setConnectionProperties(props)

agithub/GitHub.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from agithub.base import *
3+
import base64
4+
5+
from agithub.base import API, ConnectionProperties, Client
6+
47

58
class GitHub(API):
6-
'''
9+
"""
710
The agnostic GitHub API. It doesn't know, and you don't care.
811
>>> from agithub import GitHub
912
>>> g = GitHub('user', 'pass')
@@ -28,29 +31,35 @@ class GitHub(API):
2831
NOTE: It is up to you to spell things correctly. A GitHub object
2932
doesn't even try to validate the url you feed it. On the other hand,
3033
it automatically supports the full API--so why should you care?
31-
'''
32-
def __init__(self, username=None, password=None, token=None, *args, **kwargs):
33-
extraHeaders = {'accept' : 'application/vnd.github.v3+json'}
34+
"""
35+
def __init__(self, username=None, password=None, token=None,
36+
*args, **kwargs):
37+
extraHeaders = {'accept': 'application/vnd.github.v3+json'}
3438
auth = self.generateAuthHeader(username, password, token)
35-
if auth != None:
39+
if auth is not None:
3640
extraHeaders['authorization'] = auth
3741
props = ConnectionProperties(
38-
api_url = kwargs.pop('api_url', 'api.github.com'),
39-
secure_http = True,
40-
extra_headers = extraHeaders
41-
)
42+
api_url=kwargs.pop('api_url', 'api.github.com'),
43+
secure_http=True,
44+
extra_headers=extraHeaders
45+
)
4246

4347
self.setClient(Client(*args, **kwargs))
4448
self.setConnectionProperties(props)
4549

4650
def generateAuthHeader(self, username=None, password=None, token=None):
4751
if token is not None:
4852
if password is not None:
49-
raise TypeError("You cannot use both password and oauth token authenication")
53+
raise TypeError(
54+
"You cannot use both password and oauth token "
55+
"authenication"
56+
)
5057
return 'Token %s' % token
5158
elif username is not None:
5259
if password is None:
53-
raise TypeError("You need a password to authenticate as " + username)
60+
raise TypeError(
61+
"You need a password to authenticate as " + username
62+
)
5463
self.username = username
5564
return self.hash_pass(password)
5665

agithub/Maven.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from agithub.base import *
3+
from agithub.base import API, Client, ConnectionProperties
4+
45

56
class Maven(API):
6-
'''
7+
"""
78
Maven Search API
8-
'''
9+
"""
910
def __init__(self, *args, **kwargs):
1011
props = ConnectionProperties(
11-
api_url = 'search.maven.org'
12-
, url_prefix = '/solrsearch'
13-
, secure_http = True
14-
)
12+
api_url='search.maven.org',
13+
url_prefix='/solrsearch',
14+
secure_http=True,
15+
)
1516
self.setClient(Client(*args, **kwargs))
1617
self.setConnectionProperties(props)

agithub/OpenWeatherMap.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# See COPYING for license details
33
from agithub.base import API, ConnectionProperties, Client
44

5+
56
class OpenWeatherMap(API):
6-
'''
7+
"""
78
Open Weather Map API
8-
'''
9+
"""
910
def __init__(self, *args, **kwargs):
1011
props = ConnectionProperties(
11-
api_url = 'api.openweathermap.org'
12-
, secure_http = False
13-
)
12+
api_url='api.openweathermap.org',
13+
secure_http=False,
14+
)
1415
self.setClient(Client(*args, **kwargs))
1516
self.setConnectionProperties(props)

agithub/SalesForce.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
# See COPYING for license details
33
from agithub.base import API, ConnectionProperties, Client
44

5+
56
class SalesForce(API):
6-
'''
7+
"""
78
SalesForce.com REST API
89
910
Example taken from
10-
http://www.salesforce.com/us/developer/docs/api_rest/index_Left.htm#CSHID=quickstart_code.htm|StartTopic=Content%2Fquickstart_code.htm|SkinName=webhelp
11+
http://www.salesforce.com/us/developer/docs/api_rest/
12+
index_Left.htm#CSHID=quickstart_code.htm|
13+
StartTopic=Content%2Fquickstart_code.htm|SkinName=webhelp
1114
1215
>>> from SalesForce import SalesForce
1316
>>> sf = SalesForce()
@@ -29,11 +32,11 @@ class SalesForce(API):
2932
3033
NB: XML is not automically decoded or de-serialized. Patch the
3134
ResponseBody class to fix this.
32-
'''
35+
"""
3336
def __init__(self, *args, **kwargs):
3437
props = ConnectionProperties(
35-
api_url = 'na1.salesforce.com'
36-
, secure_http = True
37-
)
38+
api_url='na1.salesforce.com',
39+
secure_http=True,
40+
)
3841
self.setClient(Client(*args, **kwargs))
3942
self.setConnectionProperties(props)

agithub/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from functools import partial, update_wrapper
43
from agithub.base import VERSION, STR_VERSION
54

6-
__all__ = [ "VERSION", "STR_VERSION" ]
5+
__all__ = ["VERSION", "STR_VERSION"]

agithub/agithub_test.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import mock
77
import unittest
88

9+
910
class TestGitHubObjectCreation(unittest.TestCase):
1011
def test_user_pw(self):
1112
gh = GitHub('korfuri', '1234')
@@ -23,8 +24,7 @@ def test_token(self):
2324

2425
def test_token_password(self):
2526
with self.assertRaises(TypeError):
26-
gh = GitHub(
27-
username='korfuri', password='1234', token='deadbeef')
27+
GitHub(username='korfuri', password='1234', token='deadbeef')
2828

2929

3030
class TestIncompleteRequest(unittest.TestCase):
@@ -39,31 +39,30 @@ def test_pathByGetAttr(self):
3939

4040
def test_callMethodDemo(self):
4141
rb = self.newIncompleteRequest()
42-
self.assertEqual(rb.path.demo(),
43-
{ "methodName" : "demo"
44-
, "args" : ()
45-
, "params" : { "url" : "/path" }
46-
})
42+
self.assertEqual(
43+
rb.path.demo(),
44+
{
45+
"methodName": "demo",
46+
"args": (),
47+
"params": {"url": "/path"}
48+
}
49+
)
50+
4751
def test_pathByGetItem(self):
4852
rb = self.newIncompleteRequest()
4953
rb["hug"][1]["octocat"]
5054
self.assertEqual(rb.url, "/hug/1/octocat")
5155

52-
def test_callMethodDemo(self):
53-
rb = self.newIncompleteRequest()
54-
self.assertEqual(rb.path.demo(),
55-
{ "methodName" : "demo"
56-
, "args" : ()
57-
, "params" : { "url" : "/path" }
58-
})
59-
6056
def test_callMethodTest(self):
6157
rb = self.newIncompleteRequest()
62-
self.assertEqual(rb.path.test(),
63-
{ "methodName" : "test"
64-
, "args" : ()
65-
, "params" : { "url" : "/path" }
66-
})
58+
self.assertEqual(
59+
rb.path.demo(),
60+
{
61+
"methodName": "demo",
62+
"args": (),
63+
"params": {"url": "/path"}
64+
}
65+
)
6766

6867
if __name__ == '__main__':
6968
unittest.main()

0 commit comments

Comments
 (0)