예제 #1
0
파일: list.py 프로젝트: i077/trcli
def list_boards():
    boards_response = request.get('1/members/me/boards', {'filter': 'open'})
    boards = []

    for board_data in boards_response:
        boards.append(Board(board_data))

    print('Open boards for {}{}{}:'.format(
        attr(1),
        request.get('1/members/me', {'fields': 'username'})['username'],
        attr(0)))
    for board in boards:
        with indent():
            board.short_print()
예제 #2
0
def labels_according_to_legend(key, token, board_id):
    """
    Coloring of existed cards according to legend
    """

    client = TrelloClient(key, token)
    board = Board(client=client, board_id=board_id)
    list_of_lists = board.list_lists(list_filter='open')
    creators = my_get_members(key, token, board_id)
    legend_id = ''
    legend_labels = {}
    list_of_cards = []

    for list in range(len(list_of_lists)):
        if list_of_lists[list].name == 'Legend':
            legend_id = list_of_lists[list].id
            list_of_lists.pop(list)
            break

    for card in my_get_cards(legend_id, key, token).keys():
        for label in my_get_label(key, token,
                                  my_get_cards(legend_id, key, token)[card]):
            legend_labels[creators[card]] = my_get_label(
                key, token,
                my_get_cards(legend_id, key, token)[card])[label]

    for i in list_of_lists:
        for j in i.list_cards():
            list_of_cards.append(j)

    for card_id in list_of_cards:
        id = card_id.id
        url = f"https://api.trello.com/1/cards/{id}/actions"
        params_key_and_token = {
            'key': key,
            'token': token,
            'filter': ['updateCard', 'createCard']
        }
        response = requests.get(url, params=params_key_and_token)
        client = Cards(key, token)
        try:
            client.new_idLabel(
                id, legend_labels[response.json()[0]['idMemberCreator']])
        except:
            pass
예제 #3
0
    def search(self,
               query,
               partial_match=False,
               models=[],
               board_ids=[],
               org_ids=[],
               card_ids=[]):
        """
        Search trello given a query string.

        :param str query: A query string up to 16K characters
        :param bool partial_match: True means that trello will look for
                content that starts with any of the words in your query.
        :param list models: Comma-separated list of types of objects to search.
                This can be 'actions', 'boards', 'cards', 'members',
                or 'organizations'.  The default is 'all' models.
        :param list board_ids: Comma-separated list of boards to limit search
        :param org_ids: Comma-separated list of organizations to limit search
        :param card_ids: Comma-separated list of cards to limit search

        :return: All objects matching the search criterial.  These can
            be Cards, Boards, Organizations, and Members.  The attributes
            of the objects in the results are minimal; the user must call
            the fetch method on the resulting objects to get a full set
            of attributes populated.
        :rtype list:
        """

        query_params = {'query': query}

        if partial_match:
            query_params['partial'] = 'true'

        # Limit search to one or more object types
        if models:
            query_params['modelTypes'] = models

        # Limit search to a particular subset of objects
        if board_ids:
            query_params['idBoards'] = board_ids
        if org_ids:
            query_params['idOrganizations'] = org_ids
        if card_ids:
            query_params['idCards'] = card_ids

        # Request result fields required to instantiate class objects
        query_params['board_fields'] = ['name,url,desc,closed']
        query_params['member_fields'] = ['fullName,initials,username']
        query_params['organization_fields'] = ['name,url,desc']

        json_obj = self.fetch_json('/search', query_params=query_params)
        if not json_obj:
            return []

        results = []
        board_cache = {}

        for board_json in json_obj.get('boards', []):
            # Cache board objects
            if board_json['id'] not in board_cache:
                board_cache[board_json['id']] = Board.from_json(
                    self, json_obj=board_json)
            results.append(board_cache[board_json['id']])

        for card_json in json_obj.get('cards', []):
            # Cache board objects
            if card_json['idBoard'] not in board_cache:
                board_cache[card_json['idBoard']] = Board(
                    self, card_json['idBoard'])
                # Fetch the board attributes as the Board object created
                # from the card initially result lacks a URL and name.
                # This Board will be stored in Card.parent
                board_cache[card_json['idBoard']].fetch()
            results.append(
                Card.from_json(board_cache[card_json['idBoard']], card_json))

        for member_json in json_obj.get('members', []):
            results.append(Member.from_json(self, member_json))

        for org_json in json_obj.get('organizations', []):
            org = Organization.from_json(self, org_json)
            results.append(org)

        return results
예제 #4
0
from trello.base import TrelloBase
from trello.trelloclient import TrelloClient
from trello.board import Board
from trello.trellolist import List
from trello.label import Label

from . import enums as e

trello_client = TrelloClient(
    api_key='8c38f7619e8c0dbd0af427a6f145538f',
    api_secret='01d89258fa41a284468d9983eaec2a1f',
    token='46a437ceea33ce9c130d9ad4aea6bda1b7262225be966a858753d26f50bf4a8a',
    token_secret=
    '1af4d3041e6caa4165cfe1bace2115749db8d060d7e9dd67218a9e9667d0f8c3')

board = Board(client=trello_client, board_id=e.Board.INSTAGRAM.value)

list_complaints = List(board=board, list_id=e.List.COMPLAINTS.value)
list_on_progress = List(board=board, list_id=e.List.ON_PROGRESS.value)
list_done = List(board=board, list_id=e.List.DONE.value)

labels = {
    'transaksi': Label(trello_client, e.Label.TRANSAKSI.value, 'Transaksi'),
    'produk': Label(trello_client, e.Label.PRODUCT.value, 'Product'),
    'pengiriman': Label(trello_client, e.Label.PENGIRIMAN.value, 'Pengiriman'),
    'servis': Label(trello_client, e.Label.SERVICE.value, 'Service'),
    'pertanyaan': Label(trello_client, e.Label.PERTANYAAN.value, 'Pertanyaan'),
    'misuh': Label(trello_client, e.Label.MISUH.value, 'Misuh'),
    'lainnya': Label(trello_client, e.Label.LAINNYA.value, 'Lainnya')
}
"""
Created on Mon Jan  4 12:47:50 2021

@author: krish
"""

from trello import TrelloClient
import random, requests
from trello.board import Board
from trello.base import TrelloBase
from trello.compat import force_str

api_key = '**************************************'
api_secret = '**********************************************************'

trelloboard = Board(name='python_trial')
#print(trelloboard.__repr__.__str__)
print(trelloboard.__repr__)


class Boards(TrelloBase):
    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return force_str(u'<Board %s>' % self.name)


client = TrelloClient(api_key=api_key, api_secret=api_secret)

all_boards = client.list_boards(board_filter='python_trial')
예제 #6
0
from trello.member import Member
from trello.label import Label
from trello.board import Board
import trellovariables
import re
import sys
import argparse

#SETUP
client = TrelloClient(
    api_key=trellovariables.trello_api['api_key'],
    api_secret=trellovariables.trello_api['api_secret'],
)

#Get Board
it_board = Board(client, trellovariables.ITBOARD)

#Constants time position in card
TIME_SPEND = 1
TIME_ESTIMATED = 2


def getCardTime(name, typetime):
    e = re.search("^.*?\((\d+)\/(\d+)\).*$", name)
    if e:
        return int(e.group(typetime))
    return 0


def getMemberName(client, member_id):
    m = Member(client, member_id)