Skip to content

Commit

Permalink
Merge pull request #207 from diegojromerolopez/master
Browse files Browse the repository at this point in the history
Fix Python2 support, TrelloBase import and stats by card
  • Loading branch information
sarumont committed May 17, 2017
2 parents 9cebb71 + 5c13756 commit baa6035
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions trello/attachments.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
from dateutil import parser as dateparser

from trello import TrelloBase
from trello.base import TrelloBase


class Attachments(TrelloBase):
"""
https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink-attachments
"""
def __init__(self, id, bytes, date, edge_color, idMember, is_upload, mime_type, name, previews, url):
super().__init__()
super(Attachments, self).__init__()
self.id = id
self.bytes = bytes
self.date = dateparser.parse(date)
Expand Down
2 changes: 1 addition & 1 deletion trello/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, client=None, board_id=None, organization=None, name=''):
:board_id: ID for this board
"""
super().__init__()
super(Board, self).__init__()
if organization is None:
self.client = client
else:
Expand Down
14 changes: 10 additions & 4 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, parent, card_id, name=''):
:parent: reference to the parent trello list
:card_id: ID for this card
"""
super().__init__()
super(Card, self).__init__()
if isinstance(parent, List):
self.trello_list = parent
self.board = parent.board
Expand Down Expand Up @@ -424,6 +424,11 @@ def change_cmp(change1, change2):
source_list_id = source_list["id"]

time_from_last_list_change = seconds_to_time_unit((change_datetime - last_action_datetime).total_seconds())

# In case the source or destination list is not a list of this board, ignore them
if source_list_id not in stats_by_list or not destination_list["id"] not in stats_by_list:
continue

stats_by_list[source_list_id]["time"] += time_from_last_list_change

# Count if the change is to move forward or backwards
Expand All @@ -441,9 +446,10 @@ def change_cmp(change1, change2):

# Adding the number of seconds the card has been in its last column (until now)
# only if the last column is not "Done" column
if done_list and last_list["id"] != done_list.id:
time_card_has_spent_in_list_until_now = seconds_to_time_unit((datetime.datetime.now(tz) - last_action_datetime).total_seconds())
stats_by_list[last_list["id"]]["time"] += time_card_has_spent_in_list_until_now
if done_list and last_list and last_list["id"] and last_list["id"] in stats_by_list and\
last_list["id"] != done_list.id:
time_card_has_spent_in_list_until_now = seconds_to_time_unit((datetime.datetime.now(tz) - last_action_datetime).total_seconds())
stats_by_list[last_list["id"]]["time"] += time_card_has_spent_in_list_until_now

return stats_by_list

Expand Down
2 changes: 1 addition & 1 deletion trello/checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Checklist(TrelloBase):
"""

def __init__(self, client, checked, obj, trello_card=None):
super().__init__()
super(Checklist, self).__init__()
self.client = client
self.trello_card = trello_card
self.id = obj['id']
Expand Down
2 changes: 1 addition & 1 deletion trello/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Label(TrelloBase):
Class representing a Trello Label.
"""
def __init__(self, client, label_id, name, color=""):
super().__init__()
super(Label, self).__init__()
self.client = client
self.id = label_id
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion trello/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Member(TrelloBase):
"""

def __init__(self, client, member_id, full_name=''):
super().__init__()
super(Member, self).__init__()
self.client = client
self.id = member_id
self.full_name = full_name
Expand Down
2 changes: 1 addition & 1 deletion trello/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Organization(TrelloBase):
Class representing an organization
"""
def __init__(self, client, organization_id, name=''):
super().__init__()
super(Organization, self).__init__()
self.client = client
self.id = organization_id
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion trello/trellolist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, board, list_id, name=''):
:board: reference to the parent board
:list_id: ID for this list
"""
super().__init__()
super(List, self).__init__()
self.board = board
self.client = board.client
self.id = list_id
Expand Down

0 comments on commit baa6035

Please sign in to comment.