Skip to content

Commit

Permalink
FIX saner way to deal with circular import between list/card
Browse files Browse the repository at this point in the history
  • Loading branch information
nMustaki committed Jul 18, 2015
1 parent 89ba89a commit ec9dba3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions trello/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dateutil import parser as dateparser
from checklist import Checklist
from label import Label
import trellolist


class Card(object):
Expand Down Expand Up @@ -76,7 +77,7 @@ def __init__(self, parent, card_id, name=''):
:trello_list: reference to the parent list
:card_id: ID for this card
"""
if isinstance(parent, List):
if isinstance(parent, trellolist.List):
self.trello_list = parent
self.board = parent.board
else:
Expand Down Expand Up @@ -155,7 +156,7 @@ def fetch_comments(self):

def get_list(self):
obj = self.client.fetch_json('/lists/' + self.idList)
return List.from_json(board=self, json_obj=obj)
return trellolist.List.from_json(board=self, json_obj=obj)

def get_comments(self):
comments = []
Expand Down Expand Up @@ -378,6 +379,3 @@ def _post_remote_data(self, attribute, files=None, **kwargs):
http_method='POST',
files=files,
post_args=kwargs)


from trellolist import List
3 changes: 1 addition & 2 deletions trello/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def __repr__(self):

def fetch(self):
"""Fetch all attributes for this label"""
json_obj = self.client.fetch_json(
'/labels/' + self.id)
json_obj = self.client.fetch_json('/labels/' + self.id)
self.name = json_obj['name'].encode('utf-8')
self.color = json_obj['color']
return self
6 changes: 3 additions & 3 deletions trello/trellolist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
from __future__ import with_statement, print_function
from card import Card
import card


class List(object):
Expand Down Expand Up @@ -44,7 +44,7 @@ def fetch(self):
def list_cards(self):
"""Lists all cards in this list"""
json_obj = self.client.fetch_json('/lists/' + self.id + '/cards')
return [Card.from_json(self, c) for c in json_obj]
return [card.Card.from_json(self, c) for c in json_obj]

def add_card(self, name, desc=None, labels=[], due="null"):
"""Add a card to this list
Expand All @@ -61,7 +61,7 @@ def add_card(self, name, desc=None, labels=[], due="null"):
'/cards',
http_method='POST',
post_args={'name': name, 'idList': self.id, 'desc': desc, 'idLabels': labels_str[:-1], 'due': due})
return Card.from_json(self, json_obj)
return card.Card.from_json(self, json_obj)

def archive_all_cards(self):
self.client.fetch_json(
Expand Down

0 comments on commit ec9dba3

Please sign in to comment.