Skip to content

Commit 9a50db7

Browse files
committed
Merge pull request #1 from pnpnpn/python3
Python3
2 parents baa0aaa + 1a69a48 commit 9a50db7

File tree

7 files changed

+11
-17
lines changed

7 files changed

+11
-17
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: python
22
python:
33
- "2.7"
4+
- "3.4"
45
# does not have headers provided, please ask https://launchpad.net/~pypy/+archive/ppa
56
# maintainers to fix their pypy-dev package.
6-
- "pypy"
7+
#- "pypy"
78
# command to install dependencies
89
install:
910
- pip install -r requirements.txt

buffpy/api.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,26 @@ def access_token(self, value):
3535
self.session.access_token = value
3636

3737
def get(self, url, parser=None):
38-
if parser is None:
39-
parser = json.loads
40-
4138
if not self.session.access_token:
4239
raise ValueError('Please set an access token first!')
4340

4441
response = self.session.get(url=BASE_URL % url)
4542

46-
return parser(response.content)
43+
return response.json()
4744

4845
def post(self, url, parser=None, **params):
49-
if parser is None:
50-
parser = json.loads
51-
5246
if not self.session.access_token:
5347
raise ValueError('Please set an access token first!')
5448

5549
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
5650

5751
#Check if posting data and if data is unicode, encoding it as utf-8
58-
if 'data' in params and isinstance(params['data'], unicode):
59-
params['data'] = params['data'].encode('utf-8')
60-
52+
#if 'data' in params and isinstance(params['data'], str):
53+
# params['data'] = params['data'].encode('utf-8')
6154

6255
response = self.session.post(url=BASE_URL % url, headers=headers, **params)
6356

64-
return parser(response.content)
57+
return response.json()
6558

6659
@property
6760
def info(self):

buffpy/managers/updates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def new(self, text, shorten=None, now=None, top=None, media=None, when=None):
124124
if media:
125125
media_format = "media[%s]=%s&"
126126

127-
for media_type, media_item in media.iteritems():
127+
for media_type, media_item in sorted(media.items(), reverse=True):
128128
post_data += media_format % (media_type, media_item)
129129

130130
response = self.api.post(url=url, data=post_data)

buffpy/models/profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def schedules(self, schedules):
4343
data_format = "schedules[0][%s][]=%s&"
4444
post_data = ""
4545

46-
for format_type, values in schedules.iteritems():
46+
for format_type, values in schedules.items():
4747
for value in values:
4848
post_data += data_format % (format_type, value)
4949

buffpy/models/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def edit(self, text, media=None, utc=None, now=None):
6060
if media:
6161
media_format = "media[%s]=%s&"
6262

63-
for media_type, media_item in media.iteritems():
63+
for media_type, media_item in media.items():
6464
post_data += media_format % (media_type, media_item)
6565

6666
response = self.api.post(url=url, data=post_data)

buffpy/tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_api_info():
8585
mocked_session = MagicMock()
8686

8787
mocked_response = MagicMock()
88-
mocked_response.content = json.dumps({'status': 'ok'})
88+
mocked_response.json.return_value = {'status': 'ok'}
8989
mocked_session.get.return_value = mocked_response
9090

9191
mocked_oauth2.return_value = mocked_session

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ coverage==3.7.1
33
mock==1.0.1
44
nose==1.3.0
55
rauth==0.6.2
6-
requests==1.2.3
6+
requests==2.7.0

0 commit comments

Comments
 (0)