Skip to content

Commit aa3928a

Browse files
Version Bump v1.1.3
1 parent 7c4491b commit aa3928a

12 files changed

Lines changed: 244 additions & 202 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ target/
6565
venv/
6666
.python-version
6767
cleanup.sh
68-
*_example.py
68+
*_example.py
69+
.idea

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.1.3] - 2016-02-29
6+
### Fixed
7+
- Various standardizations for commenting, syntax, pylint
8+
- Thanks to [Ian Douglas](https://github.com/iandouglas)!
9+
510
## [1.1.2] - 2016-02-29
611
### Fixed
712
- Fixed TypeError in Python 3+ for data encoding

CONTRIBUTING.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The GitHub issue tracker is the preferred channel for library feature requests,
2828

2929
Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
3030

31-
A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report.
31+
A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report.
3232

3333
Before you decide to create a new issue, please try the following:
3434

@@ -88,9 +88,7 @@ Update your settings in `.env`
8888

8989
##### Execute: #####
9090

91-
```
9291
See the [examples folder](https://github.com/sendgrid/python-http-client/tree/master/examples) to get started quickly.
93-
```
9492

9593
<a name="understanding_the_codebase"></a>
9694
## Understanding the Code Base
@@ -101,7 +99,7 @@ Working examples that demonstrate usage.
10199

102100
**client.py**
103101

104-
An HTTP client with a fluent interface using method chaining and reflection. By returning self on [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) and [_()](https://github.com/sendgrid/python-http-client/blob/master/client.py#L70), we can dynamically build the URL using method chaining and [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) allows us to dynamically receive the method calls to achieve reflection.
102+
An HTTP client with a fluent interface using method chaining and reflection. By returning self on [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) and [_()](https://github.com/sendgrid/python-http-client/blob/master/client.py#L70), we can dynamically build the URL using method chaining and [__getattr__](https://github.com/sendgrid/python-http-client/blob/master/client.py#L74) allows us to dynamically receive the method calls to achieve reflection.
105103

106104
This allows for the following mapping from a URL to a method chain:
107105

@@ -114,9 +112,9 @@ Loads the environment variables.
114112
<a name="testing"></a>
115113
## Testing
116114

117-
All PRs require passing tests before the PR will be reviewed.
115+
All PRs require passing tests before the PR will be reviewed.
118116

119-
All test files are in the `[tests](https://github.com/sendgrid/python-http-client/tree/master/tests)` directory.
117+
All test files are in the `[tests](https://github.com/sendgrid/python-http-client/tree/master/tests)` directory.
120118

121119
For the purposes of contributing to this repo, please update the [`test_unit.py`](https://github.com/sendgrid/python-http-client/blob/master/tests/test_unit.py) file with unit tests as you modify the code.
122120

@@ -131,18 +129,19 @@ For Python 2.7.* and up:
131129
<a name="testing_multiple_versoins_of_python"></a>
132130
## Testing Multiple Versions of Python
133131

134-
All PRs require passing tests before the PR will be reviewed.
132+
All PRs require passing tests before the PR will be reviewed.
135133

136134
### Prequisites: ###
137135

138136
The above local "Initial setup" is complete
139137

140138
* [pyenv](https://github.com/yyuu/pyenv)
141139
* [tox](https://pypi.python.org/pypi/tox)
142-
140+
143141
### Initial setup: ###
144142

145-
Add eval "$(pyenv init -)" to your .profile after installing tox, you only need to do this once.
143+
Add ```eval "$(pyenv init -)"``` to your shell environment (.profile, .bashrc, etc) after installing tox, you only need to do this once.
144+
146145
```
147146
pyenv install 2.6.9
148147
pyenv install 2.7.11
@@ -230,4 +229,3 @@ Please run your code through [pyflakes](https://pypi.python.org/pypi/pyflakes) a
230229
with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
231230

232231
If you have any additional questions, please feel free to [email](mailto:[email protected]) us or create an issue in this repo.
233-

README.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@ Here is a quick example:
88

99
```python
1010
import python_http_client
11-
global_headers = {'Authorization': 'Basic XXXXXXX'}
11+
global_headers = {"Authorization": "Basic XXXXXXX"}
1212
client = Client(host='base_url', request_headers=global_headers)
1313
client.your.api._(param).call.get()
1414
print response.status_code
1515
print response.response_headers
16-
print response.response_body
16+
print response.response_body
1717
```
1818

1919
`POST /your/api/{param}/call` with headers, query parameters and a request body with versioning.
2020

2121
```python
2222
import python_http_client
23-
global_headers = {'Authorization': 'Basic XXXXXXX'}
23+
global_headers = {"Authorization": "Basic XXXXXXX"}
2424
client = Client(host='base_url', request_headers=global_headers)
25-
query_params={'hello':0, 'world':1}
26-
request_headers={'X-Test': 'test'}
27-
data={'some': 1, 'awesome', 2, 'data', 3}
25+
query_params={"hello":0, "world":1}
26+
request_headers={"X-Test": "test"}
27+
data={"some": 1, "awesome", 2, "data", 3}
2828
response = client.your.api._(param).call.post(request_body=data,
2929
query_params=query_params,
3030
request_headers=request_headers)
3131
print response.status_code
3232
print response.response_headers
33-
print response.response_body
33+
print response.response_body
3434
```
3535

3636
# Installation
3737

38-
`pip install python_http_client`
38+
`pip install python_http_client`
3939

4040
or
4141

@@ -57,7 +57,7 @@ path_to_env = os.path.abspath(os.path.dirname(__file__))
5757
python_http_client.Config(path_to_env)
5858
host = os.environ.get('HOST')
5959
api_key = os.environ.get('SENDGRID_API_KEY')
60-
request_headers = {'Authorization': 'Bearer ' + api_key, 'Content-Type': 'application/json'}
60+
request_headers = {"Authorization": 'Bearer {0}'.format(api_key), "Content-Type": "application/json"}
6161
version = 3 # note that we could also do client.version(3) to set the version for each endpoint
6262
client = python_http_client.Client(host=host,
6363
request_headers=request_headers,
@@ -68,13 +68,14 @@ response = client.api_keys.get()
6868

6969
# POST
7070
data = {
71-
'name': 'My API Key',
72-
'scopes': [
73-
'mail.send',
74-
'alerts.create',
75-
'alerts.read'
76-
]
77-
}
71+
"name": "My API Key",
72+
"scopes": [
73+
"mail.send",
74+
"alerts.create",
75+
"alerts.read"
76+
]
77+
}
78+
7879
response = client.api_keys.post(request_body=data)
7980
json_response = json.loads(response.response_body)
8081
api_key_id = json_response['api_key_id']
@@ -84,18 +85,18 @@ response = client.api_keys._(api_key_id).get()
8485

8586
# PATCH
8687
data = {
87-
'name': 'A New Hope'
88-
}
88+
"name": "A New Hope"
89+
}
8990
response = client.api_keys._(api_key_id).patch(request_body=data)
9091

9192
# PUT
9293
data = {
93-
'name': 'A New Hope',
94-
'scopes': [
95-
'user.profile.read',
96-
'user.profile.update'
97-
]
98-
}
94+
"name": "A New Hope",
95+
"scopes": [
96+
"user.profile.read",
97+
"user.profile.update"
98+
]
99+
}
99100
response = client.api_keys._(api_key_id).put(request_body=data)
100101

101102
# DELETE
@@ -130,5 +131,3 @@ We were inspired by the work done on [birdy](https://github.com/inueni/birdy) an
130131
python-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:[email protected]).
131132

132133
python-http-client is maintained and funded by SendGrid, Inc. The names and logos for python-http-client are trademarks of SendGrid, Inc.
133-
134-

cleanup.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
2+
23
rm *.pyc
34
rm tests/*.pyc
45
rm python_http_client/*.pyc
56
rm -rf __pycache__/
67
rm -rf tests/__pycache__/
78
rm -rf python_http_client/__pycache__/
8-
rm -rf *.egg-info
9+
rm -rf *.egg-info

examples/example.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
import os
2+
23
if __name__ == '__main__' and __package__ is None:
34
from os import sys, path
45
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
56
from python_http_client.client import Client
67
from python_http_client.config import Config
78

89

9-
path = os.path.abspath(os.path.dirname(__file__)) + "/.."
10-
Config(path)
10+
local_path = '{0}/..'.format(os.path.abspath(os.path.dirname(__file__)))
11+
Config(local_path)
1112
api_key = os.environ.get('SENDGRID_API_KEY')
1213
request_headers = {
13-
'X-Mock': 200,
14-
'Content-Type': 'application/json',
15-
'Authorization': 'Bearer ' + api_key
16-
}
14+
"Authorization": 'Bearer {0}'.format(api_key),
15+
"Content-Type": "application/json"
16+
}
1717
client = Client(host=os.environ.get('MOCK_HOST'),
1818
request_headers=request_headers,
1919
version=3)
2020

21-
request_headers = {'X-Mock': 200}
2221
response = client.version(3).api_keys.get()
2322
print(response.response_headers)
2423
print(response.status_code)
2524
print(response.response_body)
2625

27-
request_headers = {'X-Mock': 200}
26+
request_headers = {
27+
'X-Mock': 200
28+
}
2829
query_params = {'limit': 100}
2930
response = client.api_keys.get(query_params=query_params,
3031
request_headers=request_headers)
31-
print("\nGET Mocked Example")
32+
print('\nGET Mocked Example')
3233
print(response.response_headers)
3334
print(response.status_code)
3435
print(response.response_body)
@@ -37,36 +38,35 @@
3738
request_headers = {'X-Mock': 201}
3839
response = client.api_keys.post(request_body=data,
3940
request_headers=request_headers)
40-
print("\nPOST Mocked Example")
41+
print('\nPOST Mocked Example')
4142
print(response.response_headers)
4243
print(response.status_code)
4344
print(response.response_body)
4445

4546
data = {'sample': 'data'}
4647
request_headers = {'X-Mock': 200}
47-
api_key_id = "test_url_param"
48+
api_key_id = 'test_url_param'
4849
response = client.api_keys._(api_key_id).put(request_body=data,
4950
request_headers=request_headers)
50-
print("\nPUT Mocked Example")
51+
print('\nPUT Mocked Example')
5152
print(response.response_headers)
5253
print(response.status_code)
5354
print(response.response_body)
5455

5556
data = {'sample': 'data'}
5657
request_headers = {'X-Mock': 200}
57-
api_key_id = "test_url_param"
58+
api_key_id = 'test_url_param'
5859
response = client.api_keys._(api_key_id).patch(request_body=data,
5960
request_headers=request_headers)
60-
print("\nPATCH Mocked Example")
61+
print('\nPATCH Mocked Example')
6162
print(response.response_headers)
6263
print(response.status_code)
6364
print(response.response_body)
6465

6566
request_headers = {'X-Mock': 204}
66-
api_key_id = "test_url_param"
67-
response = client.api_keys._(api_key_id).delete(
68-
request_headers=request_headers)
69-
print("\nDELETE Mocked Example")
67+
api_key_id = 'test_url_param'
68+
response = client.api_keys._(api_key_id).delete(request_headers=request_headers)
69+
print('\nDELETE Mocked Example')
7070
print(response.response_headers)
7171
print(response.status_code)
7272
print(response.response_body)

0 commit comments

Comments
 (0)