本文整理汇总了Python中trello.TrelloClient.get_list方法的典型用法代码示例。如果您正苦于以下问题:Python TrelloClient.get_list方法的具体用法?Python TrelloClient.get_list怎么用?Python TrelloClient.get_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trello.TrelloClient
的用法示例。
在下文中一共展示了TrelloClient.get_list方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_list [as 别名]
class Trello:
COMMENT_PREFIX = "external_id="
log = logging.getLogger(__name__)
def __init__(self):
self.config = load_config("config/trello-config.yaml")
self.cards_with_external_ids = []
self.labels = {}
app_key = self.config['app_key']
token = self.config['token']
board_id = self.config['board_id']
self.board = TrelloClient(api_key=app_key, token=token).get_board(board_id)
self.classify_board()
self.log.debug("Connecting to Trello board {0}".format(board_id))
def classify_board(self):
cards = self.board.all_cards()
self.log.debug("Classifying Trello board, contains {0} cards".format(len(cards)))
for label in self.board.get_labels():
self.labels[label.name] = label
for card in cards:
if card.closed:
self.log.info("Ignoring closed card {0} ({1})".format(card.name, card.id))
else:
self.log.debug("Looking for external id in {0}".format(card.name))
self.cards_with_external_ids.append(Trello.get_external_id(card))
@staticmethod
def get_external_id(card):
external_id = None
card.fetch()
comments = card.comments
if comments:
for comment in comments:
text = comment['data']['text']
if Trello.COMMENT_PREFIX in text:
external_id = re.sub(Trello.COMMENT_PREFIX, '', text)
return external_id
def clear_board(self):
for card in self.board.all_cards():
self.log.info("Deleting {0} {1}".format(card.name, card.id))
card.delete()
def card_exists(self, identifier):
return identifier in self.cards_with_external_ids
def add_cards(self, cards):
default_list = self.board.get_list(self.config['default_list'])
self.log.info("Adding {0} cards to lane {1} ({2})".format(len(cards), default_list.name,
default_list.id))
for card in cards:
name = card['name']
identifier = card['identifier']
card_type = card['type']
note = card['note']
card = default_list.add_card(name)
if note is not None:
card.set_description(note)
card.comment("{0}{1}".format(Trello.COMMENT_PREFIX, identifier))
try:
card.add_label(self.labels[card_type])
self.log.info("Creating card with details: name={0} id={1} type={2}".
format(name, identifier, card_type))
except KeyError:
self.log.info("Can't find card type {0} configured in Trello".format(card_type))
self.log.info("Creating card with details: name={0} id={1} type=default".
format(name, identifier))
def find_completed_card_ids(self):
completed_lists = self.config['completed_lists']
self.log.info("Looking for cards in completed lanes: {0}".format(completed_lists))
cards = []
for list_id in completed_lists:
completed_list = self.board.get_list(list_id)
cards.extend([Trello.get_external_id(card) for card in completed_list.list_cards()])
# [cards.extend([card.external_card_id for card in self.trello.lane.get(lane).cards
# if len(card.external_card_id) > 1]) for lane in lanes]
self.log.info("Found {0} completed cards on the board".format(len(cards)))
self.log.debug("External ids: {0}".format(cards))
return cards
示例2: main
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_list [as 别名]
def main():
usage = '%prog (load|rebuild|commit|push|test|config|update)'\
' [options] args... are you ready?'
parser = OptionParser(usage)
parser.add_option('-i', '--id',
type='int',
dest='id')
parser.add_option('-u', '--user',
dest='user')
parser.add_option('-c', '--comment',
dest='comment')
parser.add_option('-g', '--gitpath',
default=realpath(__file__),
dest='gitpath')
parser.add_option('-p', '--params',
dest='params')
parser.add_option('-t', '--title',
dest='title')
parser.add_option('-d', '--description',
dest='description',
default="")
(options, args) = parser.parse_args()
repo = Repo(options.gitpath)
conf_path = join(expanduser("~"), '.gitr.json')
if not len(args):
handle_error(msg='Some action are required', handle=parser)
if not isfile(conf_path):
conf_src = join(dirname(realpath(__file__)), 'gitr.json')
shutil.copy(conf_src, conf_path)
with open(conf_path, 'r') as infile:
json_data = json.load(infile)
BOARD_ID = json_data['BOARD_ID']
CREATE_LIST_ID = json_data['CREATE_LIST_ID']
DONE_LIST_ID = json_data['DONE_LIST_ID']
MEMBERS = json_data['MEMBERS']
USER = MEMBERS[int(json_data['USER'])]
client = TrelloClient(api_key=json_data['API_KEY'],
token=json_data['TOKEN'],
api_secret=json_data['API_SECRET'])
if ('update' in args):
create_list = client.get_list(CREATE_LIST_ID)
card = get_current_card(repo, create_list)
if options.description:
card._set_remote_attribute('description', options.description)
if options.title or options.params:
def sub_match(match):
match_args = [arg for arg in match.groups()]
if options.title:
match_args[4] = options.title
if options.params:
params = check_params(options.params)
if (len(params) > 2):
match_args[2] = params[2]
elif (len(params) == 2):
match_args[1] = params[1]
match_args[3] = params[0]
return '#%s. %sº (%s,%s) %s' % tuple(match_args)
name = re.sub('#(\d+).(\d+)º \((\d+),(\d+)\) (.*)', sub_match, card.name)
card._set_remote_attribute('name', name)
elif ('members' in args):
for idx, member_id in enumerate(MEMBERS):
member = client.get_member(member_id)
logging.info("*%s %d. %s (%s)" % ((USER == member_id) and '*' or '',
idx, member.username, member.full_name))
elif ('config' in args):
if options.params:
params = options.params.split(',')
for param in params:
try:
key, value = param.split(':')
#.........这里部分代码省略.........
示例3: TrelloClient
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_list [as 别名]
from trello import TrelloClient
from github import GitHub
from pprint import pprint
from datetime import date, timedelta
from time import strptime, mktime
from os import getenv
trello_client = TrelloClient(
api_key=getenv("TRELLO_API_KEY"),
api_secret=getenv("TRELLO_API_SECRET"),
token=getenv("TRELLO_TOKEN")
)
github_client = GitHub(access_token=getenv("GITHUB_ACCESS_TOKEN"))
backlog = trello_client.get_list(list_id='5361b7091b0f3942310ab040')
backlog.client = trello_client
issues = github_client.repos('freedomofpress')('securedrop').issues.get(state='open')
pprint(issues[0])
pprint(backlog)
# a_month_ago = date.today() - timedelta(weeks=4)
#
# for issue in issues:
# time_struct = strptime(issue['updated_at'], u"%Y-%m-%dT%H:%M:%SZ")
# issue.date_time = mktime(time_struct)
#
# relevant_issues = [issue for issue in issues if date.fromtimestamp(issue.date_time) > a_month_ago]
#
# for issue in relevant_issues:
# pprint(issue['updated_at'])