Skip to content

Commit

Permalink
fix #66 - strings are encoded with UTF-8 to be compatible with python…
Browse files Browse the repository at this point in the history
… 2 and decoded with utf-8 to be compatible with python 3
  • Loading branch information
mehdy committed Dec 3, 2015
1 parent 93d8110 commit 11945ea
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
15 changes: 8 additions & 7 deletions trello/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ def from_json(cls, trello_client=None, organization=None, json_obj=None):
:json_obj: the json board object
"""
if organization is None:
board = Board(client=trello_client, board_id=json_obj['id'], name=json_obj['name'].encode('utf-8'))
board = Board(client=trello_client, board_id=json_obj['id'], name=json_obj['name'].encode('utf-8').decode('utf-8'))
else:
board = Board(organization=organization, board_id=json_obj['id'], name=json_obj['name'].encode('utf-8'))
board = Board(organization=organization, board_id=json_obj['id'], name=json_obj['name'].encode('utf-8').decode('utf-8'))

board.description = json_obj.get('desc', '').encode('utf-8')
board.description = json_obj.get('desc', '').encode('utf-8').decode(
'utf-8')
board.closed = json_obj['closed']
board.url = json_obj['url']

Expand Down Expand Up @@ -277,13 +278,13 @@ def get_members(self, filters=None):
members = list()
for obj in json_obj:
m = Member(self.client, obj['id'])
m.status = obj.get('status', '').encode('utf-8')
m.status = obj.get('status', '').encode('utf-8').decode('utf-8')
m.id = obj.get('id', '')
m.bio = obj.get('bio', '')
m.url = obj.get('url', '')
m.username = obj['username'].encode('utf-8')
m.full_name = obj['fullName'].encode('utf-8')
m.initials = obj.get('initials', '').encode('utf-8')
m.username = obj['username'].encode('utf-8').decode('utf-8')
m.full_name = obj['fullName'].encode('utf-8').decode('utf-8')
m.initials = obj.get('initials', '').encode('utf-8').decode('utf-8')
members.append(m)

return members
Expand Down
4 changes: 2 additions & 2 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def from_json(cls, parent, json_obj):
raise Exception("key 'id' is not in json_obj")
card = cls(parent,
json_obj['id'],
name=json_obj['name'].encode('utf-8'))
name=json_obj['name'].encode('utf-8').decode('utf-8'))
card.desc = json_obj.get('desc', '')
card.closed = json_obj['closed']
card.url = json_obj['url']
Expand All @@ -127,7 +127,7 @@ def fetch(self, eager=True):
'/cards/' + self.id,
query_params={'badges': False})
self.id = json_obj['id']
self.name = json_obj['name'].encode('utf-8')
self.name = json_obj['name'].encode('utf-8').decode('utf-8')
self.desc = json_obj.get('desc', '')
self.closed = json_obj['closed']
self.url = json_obj['url']
Expand Down
4 changes: 2 additions & 2 deletions trello/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def from_json(cls, board, json_obj):
"""
label = Label(board.client,
label_id=json_obj['id'],
name=json_obj['name'].encode('utf-8'),
name=json_obj['name'].encode('utf-8').decode('utf-8'),
color=json_obj['color'])
return label

Expand All @@ -36,6 +36,6 @@ def __repr__(self):
def fetch(self):
"""Fetch all attributes for this label"""
json_obj = self.client.fetch_json('/labels/' + self.id)
self.name = json_obj['name'].encode('utf-8')
self.name = json_obj['name'].encode('utf-8').decode('utf-8')
self.color = json_obj['color']
return self
6 changes: 3 additions & 3 deletions trello/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def from_json(cls, trello_client, json_obj):
:json_obj: the member json object
"""

member = Member(trello_client, json_obj['id'], full_name=json_obj['fullName'].encode('utf-8'))
member.username = json_obj.get('username', '').encode('utf-8')
member.initials = json_obj.get('initials', '').encode('utf-8')
member = Member(trello_client, json_obj['id'], full_name=json_obj['fullName'].encode('utf-8').decode('utf-8'))
member.username = json_obj.get('username', '').encode('utf-8').decode('utf-8')
member.initials = json_obj.get('initials', '').encode('utf-8').decode('utf-8')
# cannot close an organization
# organization.closed = json_obj['closed']
return member
4 changes: 2 additions & 2 deletions trello/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def from_json(cls, trello_client, json_obj):
:trello_client: the trello client
:json_obj: the board json object
"""
organization = Organization(trello_client, json_obj['id'], name=json_obj['name'].encode('utf-8'))
organization.description = json_obj.get('desc', '').encode('utf-8')
organization = Organization(trello_client, json_obj['id'], name=json_obj['name'].encode('utf-8').decode('utf-8'))
organization.description = json_obj.get('desc', '').encode('utf-8').decode('utf-8')
# cannot close an organization
# organization.closed = json_obj['closed']
organization.url = json_obj['url']
Expand Down
2 changes: 1 addition & 1 deletion trello/trellolist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def from_json(cls, board, json_obj):
:board: the board object that the list belongs to
:json_obj: the json list object
"""
list = List(board, json_obj['id'], name=json_obj['name'].encode('utf-8'))
list = List(board, json_obj['id'], name=json_obj['name'].encode('utf-8').decode('utf-8'))
list.closed = json_obj['closed']
return list

Expand Down

0 comments on commit 11945ea

Please sign in to comment.