当前位置: 首页>>代码示例>>Python>>正文


Python TrelloClient.get_board方法代码示例

本文整理汇总了Python中trello.TrelloClient.get_board方法的典型用法代码示例。如果您正苦于以下问题:Python TrelloClient.get_board方法的具体用法?Python TrelloClient.get_board怎么用?Python TrelloClient.get_board使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trello.TrelloClient的用法示例。


在下文中一共展示了TrelloClient.get_board方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_to_trello

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
    def save_to_trello(self):
        # print clean_form_data
        api_key = settings.TRELLO_KEY
        secret = settings.TRELLO_SECRET
        token = settings.TRELLO_TOKEN
        board = settings.TRELLO_REQUEST_BOARD

        c = TrelloClient(api_key, secret, token)
        b = c.get_board(board)

        # Currently we default to adding card to first list
        l = b.all_lists()[0]
        label_list = b.get_labels()

        ds_name = "%s - %s" % (self.dataset_name, self.dataset_source)

        ds_description = "%s\n%s\nRequested by: %s %s, %s" % \
            (self.dataset_name,
            self.dataset_description,
            self.user_first_name,
            self.user_last_name,
            self.user_email)

        try:
            label_to_add = next(x for x in label_list if x.name == 'Request')
        except StopIteration:
            label_to_add = b.add_label('Request', "lime")

        try:
            card = l.add_card(ds_name, ds_description, [label_to_add])
            self.trello_id = card.id
        except Exception:
            pass
开发者ID:CT-Data-Collaborative,项目名称:dataset-requests,代码行数:35,代码来源:models.py

示例2: post

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
    def post(self):
        """ Collect data from the HTML form to fill in a Trello card.

        That card will be uploaded to Suggestion Box board, on the corresponding
        list, determined by the "System" attribute given in the form.
        """
        # Get form data
        date = datetime.now()
        title = self.get_argument('title')
        area = self.get_argument('area')
        system = self.get_argument('system')
        importance = self.get_argument('importance')
        difficulty = self.get_argument('difficulty')
        user = self.get_current_user_name()
        description = self.get_argument('description')
        suggestion = self.get_argument('suggestion')

        client = TrelloClient(api_key = self.application.trello_api_key,
                              api_secret = self.application.trello_api_secret,
                              token = self.application.trello_token)

        # Get Suggestion Box board
        boards = client.list_boards()
        suggestion_box = None
        for b in boards:
            if b.name == 'Suggestion Box':
                suggestion_box = client.get_board(b.id)
                break

        # Get the board lists (which correspond to System in the form data) and
        # concretely get the list where the card will go
        lists = b.all_lists()
        card_list = None
        for l in lists:
            if l.name == system:
                card_list = l
                break

        # Create new card using the info from the form
        new_card = card_list.add_card(TITLE_TEMPLATE.format(title=title, area=area))
        new_card.set_description(DESCRIPTION_TEMPLATE.format(date = date.ctime(),
                                                             area=area,
                                                             system=system,
                                                             importance=importance,
                                                             difficulty=difficulty,
                                                             user=user,
                                                             description=description,
                                                             suggestion=suggestion))

        # Save the information of the card in the database
        self.application.suggestions_db.create({'date': date.isoformat(),
                                                'card_id': new_card.id,
                                                'description': new_card.description,
                                                'name': new_card.name,
                                                'url': new_card.url,
                                                'archived': False})

        self.set_status(200)
开发者ID:guillermo-carrasco,项目名称:status,代码行数:60,代码来源:suggestion_box.py

示例3: get_trello_cards

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
def get_trello_cards():
    """
    Makes an API call to Trello to get all of the cards from Weird Canada's
    New Canadiana board. Requires an OAuth key.
    :return: list of trello cards
    """
    trello_client = TrelloClient(
        api_key=os.environ.get('TRELLO_API_KEY'),
        api_secret=os.environ.get('TRELLO_API_SECRET'),
        token=os.environ.get('TRELLO_OAUTH_KEY'),
        token_secret=os.environ.get('TRELLO_OAUTH_SECRET')
    )

    new_canadiana_board_id = os.environ.get('BOARD_ID')
    new_canadiana_board = trello_client.get_board(new_canadiana_board_id)

    return new_canadiana_board.open_cards()
开发者ID:kdazzle,项目名称:weird-bandcamp,代码行数:19,代码来源:import_submissions.py

示例4: TrelloManager

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class TrelloManager(object):
    def __init__(self):
        trello_config = Config.open_api.trello

        self.client = TrelloClient(
            api_key=trello_config.API_KEY,
            api_secret=trello_config.API_SECRET,
            token=trello_config.TOKEN,
        )
        self.board = self.client.get_board(trello_config.BOARD)

    def get_list_by_name(self, name):
        for l in self.board.all_lists():
            if l.name == name:
                return l
        return None

    def get_card_count_by_list_name(self, name):
        l = self.get_list_by_name(name)
        if l is None:
            raise ValueError(f"there is no {name} list in trello board.")

        return len(l.list_cards())

    def get_random_card_name(self, list_name: str = "Inbox"):
        l = self.get_list_by_name(list_name)
        if l is None or len(l.list_cards()) == 0:
            return None
        return random.choice(l.list_cards()).name

    def add_card(self, list_name: str, card_name):
        l = self.get_list_by_name(list_name)
        l.add_card(card_name)

    def archive_all_cards(self, list_name):
        l = self.get_list_by_name(list_name)
        l.archive_all_cards()

    def clean_board(self, except_list_name=None):
        l_list = self.board.all_lists()
        for l in l_list:
            if except_list_name is not None and l.name in except_list_name:
                pass
            else:
                l.archive_all_cards()
开发者ID:DongjunLee,项目名称:stalker-bot,代码行数:47,代码来源:trello.py

示例5: sync

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
def sync(events, token):
    trello = TrelloClient(api_key=TRELLO_KEY, token=token)
    board = trello.get_board('55f7167c46760fcb5d68b385')

    far_away, less_2_months, less_1_month, less_1_week, today, past = board.all_lists()

    all_cards = {card_id(c): c for c in board.all_cards()}

    date_today = datetime.date.today()

    for e in events:
        card = all_cards.get(e.id)

        if not card:
            card = create_card(e, far_away)
            create_checklist(card)

        #fetch card to get due date
        try:
            card.fetch()
        except ResourceUnavailable:
            print("Oopsie: too many requests! Let's wait 10 seconds!")
            time.sleep(10)
            card.fetch()

        if e.date != card.due_date.date():
            print('Changing due date of {} to {}'.format(e.city, e.date))
            card.set_due(e.date)

        distance = (e.date - date_today).days
        if distance < 0:
            right_list = past
        elif distance == 0:
            right_list = today
        elif distance < 7:
            right_list = less_1_week
        elif distance < 30:
            right_list = less_1_month
        elif distance < 60:
            right_list = less_2_months
        else:
            right_list = far_away

        ensure_card_in_list(card, right_list)
开发者ID:GracedBuilder,项目名称:djangogirls,代码行数:46,代码来源:sync_events_dashboard.py

示例6: sync

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
def sync(events, token):
    trello = TrelloClient(api_key=TRELLO_KEY, token=token)
    board = trello.get_board("55f7167c46760fcb5d68b385")

    far_away, less_2_months, less_1_month, less_1_week, today, past = board.all_lists()

    all_cards = {card_id(c): c for c in board.all_cards()}

    date_today = datetime.date.today()

    for e in events:
        card = all_cards.get(e.id)

        if not card:
            card = create_card(e, far_away)
            create_checklist(card)

        # fetch card to get due date
        card.fetch()

        if e.date != card.due_date.date():
            print("Changing due date of {} to {}".format(e.city, e.date))
            card.set_due(e.date)

        distance = (e.date - date_today).days
        if distance < 0:
            right_list = past
        elif distance == 0:
            right_list = today
        elif distance < 7:
            right_list = less_1_week
        elif distance < 30:
            right_list = less_1_month
        elif distance < 60:
            right_list = less_2_months
        else:
            right_list = far_away

        ensure_card_in_list(card, right_list)
开发者ID:MadSkittles,项目名称:djangogirls,代码行数:41,代码来源:sync_events_dashboard.py

示例7: __init__

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class TrelloCli:

    def __init__(self, file='config.yml'):
        """ Load Trello api keys from yaml file"""
        with open(file, 'r') as stream:
            try:
                config = yaml.safe_load(stream)
                self.__client = TrelloClient(
                    api_key = config['key'],
                    api_secret = config['token']
                )
            except yaml.YAMLError as exc:
                    print(exc)

    def get_board(self, board_name):
        """ Get the board from the board name """
        boards = self.__client.list_boards()
        for board in boards:
            if board.name == board_name:
                return self.__client.get_board(board.id)

    def get_list(self, board, list_name):
        lists = board.all_lists()
        for list in lists:
            if list.name == list_name:
                return board.get_list(list.id)

    def get_member(self, board, member_name):
        members = board.all_members()
        for member in members:
            if member.full_name == member_name:
                return member

    def display_cards(self, trello_list):
        cards = trello_list.list_cards()
        for card in cards:
            print(card.name)
开发者ID:julian-labuschagne,项目名称:trellocli,代码行数:39,代码来源:main.py

示例8: TrelloPlugin

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class TrelloPlugin(DIBasePlugin, DIPluginDashboardMixin):

    platform = "trello"
    platform_url = "http://www.trello.com/"

    #created for "create" actions
    #added for "add" actions
    #updated for "update" actions
    #commented for card "comment" actions
    xapi_verbs = ['created', 'added', 'updated', 'commented', 'closed', 'opened']

    #Note for "commented" actions
    #Task for "created", "added", "updated", and "commented" actions
    #Collection for any "created", "added", "updated" List actions (tentative use)
    xapi_objects = ['Note', 'Task', 'Collection', 'Person', 'File', 'checklist-item', 'checklist']

    user_api_association_name = 'Trello UID' # eg the username for a signed up user that will appear in data extracted via a social API
    unit_api_association_name = 'Board ID' # eg hashtags or a group name

    config_json_keys = ['consumer_key', 'consumer_secret']

    #from DIPluginDashboardMixin
    xapi_objects_to_includein_platformactivitywidget = ['Note']
    xapi_verbs_to_includein_verbactivitywidget = ['created', 'shared', 'liked', 'commented']

    #for OAuth1 authentication
    token_request_url = ''

    def __init__(self):
       pass

    #retreival param is the user_id
    def perform_import(self, retreival_param, course_code, token=None):
        #from clatoolkit.models import ApiCredentials
        #Set up trello auth and API
        #self.usercontext_storage_dict = json.load(ApiCredentials.objects.get(platform=retreival_param).credentials_json)

        self.TrelloCient = TrelloClient(
            api_key=os.environ.get("TRELLO_API_KEY"),
            #api_secret=self.api_config_dict['api_secret'],
            token=token
        )

        #Get user-registered board in trello
        trello_board = self.TrelloCient.get_board(retreival_param)

        #Get boards activity/action feed
        trello_board.fetch_actions('all') #fetch_actions() collects actions feed and stores to trello_board.actions

        #self.key = trello_board.api_key
        #self.token = trello_board.resource_owner_key

        self.import_TrelloActivity(trello_board.actions, course_code)

    def import_TrelloActivity(self, feed, course_code):
        #User needs to sign up username and board (board can be left out but is needed)
        #TODO: RP
        print 'Beginning trello import!'

        for action in list(feed):
            #print 'action: %s' % (action)
            #action = json.load(action)

            #We need to connect this with our user profile somewhere when they initially auth
            u_id = action['idMemberCreator']
            author = action['memberCreator']['username']
            type = action['type'] #commentCard, updateCard, createList,etc
            data = action['data']
            date = action['date']
            board_name = data['board']['name']

            print 'got action type: %s' % (type)

            #print 'is action comment? %s' % (type == 'commentCard')
            #Get all 'commented' verb actions
            if (type == 'commentCard'):
                #do stuff
                target_obj_id = data['card']['id']
                #date
                comment_from_uid = u_id
                comment_from_name = author
                comment_message = data['text']
                comment_id = action['id']

                if username_exists(comment_from_uid, course_code, self.platform):
                    usr_dict = get_userdetails(comment_from_uid, self.platform)
                    insert_comment(usr_dict, target_obj_id, comment_id,
                                   comment_message, comment_from_uid,
                                   comment_from_name, date, course_code,
                                   self.platform, self.platform_url)
                    print 'Inserted comment!'

            #print 'is action card creation? %s' % (type == 'createCard')
            #Get all 'create' verb actions
            if (type == 'createCard'): #, 'createList']):
                #date
                #list_id = data['list']['id']
                task_id = data['card']['id']
                task_name = data['card']['name']

#.........这里部分代码省略.........
开发者ID:zwaters,项目名称:CLAtoolkit,代码行数:103,代码来源:cladi_plugin.py

示例9: ServiceTrello

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class ServiceTrello(ServicesMgr):

    # Boards own Lists own Cards

    def __init__(self, token=None):
        # app name
        self.app_name = DjangoThConfig.verbose_name
        # expiration
        self.expiry = "30days"
        # scope define the rights access
        self.scope = 'read,write'

        base = 'https://www.trello.com'
        self.AUTH_URL = '{}/1/OAuthAuthorizeToken'.format(base)
        self.REQ_TOKEN = '{}/1/OAuthGetRequestToken'.format(base)
        self.ACC_TOKEN = '{}/1/OAuthGetAccessToken'.format(base)
        self.consumer_key = settings.TH_TRELLO['consumer_key']
        self.consumer_secret = settings.TH_TRELLO['consumer_secret']
        if token:
            token_key, token_secret = token.split('#TH#')
            self.trello_instance = TrelloClient(self.consumer_key,
                                                self.consumer_secret,
                                                token_key,
                                                token_secret)

    def read_data(self, token, trigger_id, date_triggered):
        """
            get the data from the service
            as the pocket service does not have any date
            in its API linked to the note,
            add the triggered date to the dict data
            thus the service will be triggered when data will be found
            :param trigger_id: trigger ID to process
            :param date_triggered: the date of the last trigger
            :type trigger_id: int
            :type date_triggered: datetime
            :return: list of data found from the date_triggered filter
            :rtype: list
        """
        data = list()
        cache.set('th_trello_' + str(trigger_id), data)

    def process_data(self, trigger_id):
        """
            get the data from the cache
            :param trigger_id: trigger ID from which to save data
            :type trigger_id: int
        """
        cache_data = cache.get('th_trello_' + str(trigger_id))
        return PublishingLimit.get_data('th_trello_', cache_data, trigger_id)

    def save_data(self, token, trigger_id, **data):
        """
            let's save the data

            :param trigger_id: trigger ID from which to save data
            :param **data: the data to check to be used and save
            :type trigger_id: int
            :type **data:  dict
            :return: the status of the save statement
            :rtype: boolean
        """
        from th_trello.models import Trello

        title = ''
        content = ''
        status = False

        title = self.set_card_title(data)
        content = self.set_card_content(data)

        if len(title):
            # get the data of this trigger
            t = Trello.objects.get(trigger_id=trigger_id)

            # 1 - we need to search the list and board where we will
            # store the card so ...

            # 1.a search the board_id by its name
            # by retreiving all the boards
            boards = self.trello_instance.list_boards()

            board_id = ''
            my_board = ''
            my_list = ''
            for board in boards:
                if t.board_name == board.name.decode('utf-8'):
                    board_id = board.id
                    break

            if board_id:
                # 1.b search the list_id by its name
                my_board = self.trello_instance.get_board(board_id)
                lists = my_board.open_lists()
                # just get the open list ; not all the archive ones
                for list_in_board in lists:
                    # search the name of the list we set in the form
                    if t.list_name == list_in_board.name.decode('utf-8'):
                        # return the (trello) list object
                        # to be able to add card at step 3
#.........这里部分代码省略.........
开发者ID:sidaga,项目名称:django-th,代码行数:103,代码来源:my_trello.py

示例10: TrelloBoardTestCase

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]

#.........这里部分代码省略.........
        self.assertIsInstance(self._board.all_cards(), list)
        self.assertIsInstance(self._board.open_cards(), list)
        self.assertIsInstance(self._board.closed_cards(), list)

    def test52_add_card_set_due(self):
        name = "Testing from Python"
        description = "Description goes here"
        card = self._list.add_card(name, description)

        # Set the due date to be 3 days from now
        today = datetime.today()
        day_detla = timedelta(3)
        due_date = today + day_detla
        card.set_due(due_date)
        expected_due_date = card.due
        # Refresh the due date from cloud
        card.fetch()
        actual_due_date = card.due[:10]
        self.assertEquals(expected_due_date, actual_due_date)
        # Note that set_due passes only the date, stripping time
        self.assertEquals(card.due_date.date(), due_date.date())

    def test53_checklist(self):
        name = "Testing from Python"
        description = "Description goes here"
        card = self._list.add_card(name, description)

        name = 'Checklists'
        checklist = card.add_checklist(name,
                                       ['item1', 'item2'])
        self.assertIsNotNone(checklist, msg="checklist is None")
        self.assertIsNotNone(checklist.id, msg="id not provided")
        self.assertEquals(checklist.name, name)
        checklist.rename('Renamed')
        self.assertEquals(checklist.name, 'Renamed')

    def test54_set(self):
        name = "Testing from Python"
        description = "Description goes here"
        card = self._list.add_card('noname')
        card.set_name(name)
        card.set_description(description)
        self.assertEquals(card.name, name)
        self.assertEquals(card.description, description)

    def test55_set_pos(self):
        card_names = lambda: [c.name for c in self._list.list_cards()]
        self._list.add_card('card1')
        card2 = self._list.add_card('card2')
        names = card_names()
        self.assertGreater(names.index('card2'), names.index('card1'))

        card2.set_pos('top')
        names = card_names()
        self.assertGreater(names.index('card1'), names.index('card2'))

        card2.set_pos('bottom')
        names = card_names()
        self.assertGreater(names.index('card2'), names.index('card1'))

    def test60_delete_cards(self):
        cards = self._board.get_cards()
        for card in cards:
            card.delete()

    def test70_all_members(self):
        self.assertTrue(len(self._board.all_members()) > 0)

    def test71_normal_members(self):
        self.assertTrue(len(self._board.normal_members()) >= 0)

    def test72_admin_members(self):
        self.assertTrue(len(self._board.admin_members()) > 0)

    def test73_owner_members(self):
        members = self._board.owner_members()
        self.assertTrue(len(members) > 0)
        member = members[0].fetch()
        self.assertNotEqual(member.status, None)
        self.assertNotEqual(member.id, None)
        self.assertNotEqual(member.bio, None)
        self.assertNotEqual(member.url, None)
        self.assertNotEqual(member.username, None)
        self.assertNotEqual(member.full_name, None)
        self.assertNotEqual(member.initials, None)
        member2 = self._trello.get_member(member.id)
        self.assertEqual(member.username, member2.username)

    def test80_unauthorized(self):
        client = TrelloClient('a')
        self.assertRaises(Unauthorized,
                          client.list_boards)

    def test81_resource_unavailable(self):
        self.assertRaises(ResourceUnavailable,
                          self._trello.get_card, '0')

    def test90_get_board(self):
        board = self._trello.get_board(self._board.id)
        self.assertEqual(self._board.name, board.name)
开发者ID:AlfiyaZi,项目名称:py-trello,代码行数:104,代码来源:test_trello.py

示例11: getTableros

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
def getTableros(filtro=""):
    filtroPasado = filtro
    tableros = client.list_boards(board_filter=filtroPasado)
    lista = []
    
    registros = [(tn.name, tn.id) for tn in tableros]
    for f in registros:
        campos = ['nombre_tablero', 'id_tablero']
        convertir = dict(zip(campos, f))
        lista.append(convertir)
    tablerosDevolver = json.dumps(lista)
    return tablerosDevolver

# Obtener un tablero por su ID
tablero = client.get_board('57581f7d6a945e2f6630a793')
print(tablero)

# Obtener todas las listas de un tablero
print( tablero.all_lists() )

# Obtener de un tablero una lista o columna por su ID
lista = tablero.get_list('57582109bba4b95e66dbf4e1')

# Obtener de una lista la cantidad de tarjetas que posee
lista.cardsCnt()

# Obtener todas las tarjetas que posee
lista.list_cards()

# Listar los tableros Abiertos
开发者ID:foxcarlos,项目名称:trelar,代码行数:32,代码来源:pruebaCliente.py

示例12: TrelloCollector

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class TrelloCollector(object):
    """
    Class representing all Trello information required to do the SysDesEng reporting.
    """

    def __init__(self, report_config, trello_secret):
        self.logger = logging.getLogger(__name__)
        self.client = TrelloClient(api_key = trello_secret[':consumer_key'],
                                   api_secret = trello_secret[':consumer_secret'],
                                   token = trello_secret[':oauth_token'],
                                   token_secret = trello_secret[':oauth_token_secret'])

        #Extract report configuration parameters
        trello_sources = report_config[':trello_sources'];
        #self.report_parameters = report_config[':output_metadata'];
        gen_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        self.content = { ':output_metadata' : {
                              ':gen_date': gen_date, #Report name is built as :report_name + gen_date (where :report_name is taken from the config)
                              ':trello_sources': {
                                 ':boards':{},
                                 ':lists': {},
                                 ':cards': [] }}}

        self.load_config(trello_sources, self.content[':output_metadata'][':trello_sources'])
        self.logger.debug("Report output metadata: %s" % (self.content[':output_metadata']))

    def load_config(self, config_src, report_metadata):
        """ load all config data related to trello sources and structure them in the report_metadata"""
        for card_type in config_src.keys(): #card_type is project|assignment|epic
            for board_t in config_src[card_type].keys():
                board_id = config_src[card_type][board_t][':board_id']
                if not board_id in report_metadata: # initialize if the board wasn't present during the iterations over other card_type's
                    if not board_id in report_metadata[':boards']:
                        report_metadata[':boards'][board_id] = {};
                    report_metadata[':boards'][board_id][':board_id'] = config_src[card_type][board_t][':board_id'] #copy board id
                    report_metadata[':boards'][board_id][':board_name'] = board_t
                    if not ':lists' in report_metadata[':boards'][board_id]:
                        report_metadata[':boards'][board_id][':lists'] = []

                #iterate through all the lists and populate them
                for list_t in config_src[card_type][board_t][':lists'].keys():
                    self.logger.debug("Adding board %s, list %s to the report" % (config_src[card_type][board_t][':board_id'], config_src[card_type][board_t][':lists'][list_t]))
                    list_id = config_src[card_type][board_t][':lists'][list_t]
                    report_metadata[':lists'][list_id] = {};
                    report_metadata[':lists'][list_id][':list_id'] = list_id
                    report_metadata[':lists'][list_id][':completed'] = False;
                    report_metadata[':lists'][list_id][':card_type'] = card_type;
                    report_metadata[':lists'][list_id][':board_id'] = board_id
                    report_metadata[':boards'][board_id][':lists'].append(list_id)
                if ':done_lists' in config_src[card_type][board_t]:
                    for list_t in config_src[card_type][board_t][':done_lists'].keys():
                        self.logger.debug("Adding board %s, Done list %s to the report" % (config_src[card_type][board_t][':board_id'], config_src[card_type][board_t][':done_lists'][list_t]))
                        list_id = config_src[card_type][board_t][':done_lists'][list_t]
                        report_metadata[':lists'][list_id] = {};
                        report_metadata[':lists'][list_id][':list_id'] = list_id
                        report_metadata[':lists'][list_id][':completed'] = True;
                        report_metadata[':lists'][list_id][':card_type'] = card_type;
                        report_metadata[':lists'][list_id][':board_id'] = board_id
                        report_metadata[':boards'][board_id][':lists'].append(list_id)

    def list_boards(self):
        syseng_boards = self.client.list_boards()
        for board in syseng_boards:
            for tlist in board.all_lists():
                self.logger.info('board name: %s is here, board ID is: %s; list %s is here, list ID is: %s' % (board.name, board.id, tlist.name, tlist.id)) 

    def parse_trello(self, deep_scan):
        """
        :deep_scan: If deep_scan is True the scan will traverse actions, otherwise just a light scan(much faster)
        Main function to parse all Trello boards and lists.
        """
        trello_sources = self.content[':output_metadata'][':trello_sources'];
        self.logger.debug('The sources are %s' % (trello_sources))

        for board_id in trello_sources[':boards'].keys():
            tr_board = self.client.get_board(board_id);
            tr_board.fetch(); # get all board properties
            members = [ (m.id, m.full_name) for m in tr_board.get_members()];
            trello_sources[':boards'][board_id][':members'] = members;
            self.logger.info('----- querying board %s -----' % (trello_sources[':boards'][board_id][':board_name']))
            self.logger.debug('Board members are %s' % (trello_sources[':boards'][board_id][':members']))

            #trello_sources[board_id][':cards'] = []
            cards = tr_board.get_cards();

    
            for card in cards:
                card_content = {}
                card_content[':name'] = card.name
                card_content[':id'] = card.id
                card_content[':members'] = []
                card_content[':board_id'] = tr_board.id
                for member_id in card.member_ids:
                    for (m_id, m_full_name) in members:
                        if member_id == m_id :
                           card_content[':members'].append((m_id,m_full_name))
                card_content[':desc'] = card.desc
                card_content[':short_url'] = card.url
                card_content[':labels'] = [(label.name,label.color) for label in card.labels]
#.........这里部分代码省略.........
开发者ID:t0ffel,项目名称:trello-reporter,代码行数:103,代码来源:trello_collector.py

示例13: build_file

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
def build_file():
    client = TrelloClient(**trello_creds.CREDS)
    sales_board = client.get_board(dsa_config.SALES_BOARD_ID)
    moves_list_dict = get_moves_list_dict(sales_board)
    pickle.dump(moves_list_dict, open("moves_list_dict.p","wb"))
    pp.pprint(moves_list_dict)
开发者ID:michaelmoliterno,项目名称:trello-sales-pipeline,代码行数:8,代码来源:connect.py

示例14: ServiceTrello

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class ServiceTrello(ServicesMgr):
    """
        Serivce Trello
    """
    # Boards own Lists own Cards

    def __init__(self, token=None, **kwargs):
        super(ServiceTrello, self).__init__(token, **kwargs)
        # app name
        self.app_name = DjangoThConfig.verbose_name
        # expiration
        self.expiry = "30days"
        # scope define the rights access
        self.scope = 'read,write'
        self.oauth = 'oauth1'
        self.service = 'ServiceTrello'

        base = 'https://www.trello.com'
        self.AUTH_URL = '{}/1/OAuthAuthorizeToken'.format(base)
        self.REQ_TOKEN = '{}/1/OAuthGetRequestToken'.format(base)
        self.ACC_TOKEN = '{}/1/OAuthGetAccessToken'.format(base)
        self.consumer_key = settings.TH_TRELLO_KEY['consumer_key']
        self.consumer_secret = settings.TH_TRELLO_KEY['consumer_secret']
        if token:
            token_key, token_secret = token.split('#TH#')
            try:
                self.trello_instance = TrelloClient(self.consumer_key,
                                                    self.consumer_secret,
                                                    token_key,
                                                    token_secret)
            except ResourceUnavailable as e:
                us = UserService.objects.get(token=token)
                logger.error(e.msg, e.error_code)
                update_result(us.trigger_id, msg=e.msg, status=False)

    def read_data(self, **kwargs):
        """
            get the data from the service

            :param kwargs: contain keyword args : trigger_id at least
            :type kwargs: dict
        """
        trigger_id = kwargs.get('trigger_id')
        data = list()
        kwargs['model_name'] = 'Trello'
        kwargs['app_label'] = 'th_trello'
        super(ServiceTrello, self).read_data(**kwargs)
        cache.set('th_trello_' + str(trigger_id), data)
        return data

    def save_data(self, trigger_id, **data):
        """
            let's save the data

            :param trigger_id: trigger ID from which to save data
            :param data: the data to check to be used and save
            :type trigger_id: int
            :type data:  dict
            :return: the status of the save statement
            :rtype: boolean
        """
        data['output_format'] = 'md'
        title, content = super(ServiceTrello, self).save_data(trigger_id, **data)
        if len(title):
            # get the data of this trigger
            t = Trello.objects.get(trigger_id=trigger_id)
            # footer of the card
            footer = self.set_card_footer(data, t)
            content += footer

            # 1 - we need to search the list and board where we will
            # store the card so ...

            # 1.a search the board_id by its name
            # by retrieving all the boards
            boards = self.trello_instance.list_boards()

            board_id = ''
            my_list = ''
            for board in boards:
                if t.board_name == board.name:
                    board_id = board.id
                    break

            if board_id:
                # 1.b search the list_id by its name
                my_board = self.trello_instance.get_board(board_id)
                lists = my_board.open_lists()
                # just get the open list ; not all the archive ones
                for list_in_board in lists:
                    # search the name of the list we set in the form
                    if t.list_name == list_in_board.name:
                        # return the (trello) list object to be able to add card at step 3
                        my_list = my_board.get_list(list_in_board.id)
                        break
                # we didnt find the list in that board -> create it
                if my_list == '':
                    my_list = my_board.add_list(t.list_name)
            else:
                # 2 if board_id and/or list_id does not exist, create it/them
#.........这里部分代码省略.........
开发者ID:foxmask,项目名称:django-th,代码行数:103,代码来源:my_trello.py

示例15: __init__

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import get_board [as 别名]
class Trello:
    client = None

    def __init__(self):
        self.client = TrelloClient(
            api_key=os.environ.get("trello_api_key"),
            api_secret=os.environ.get("trello_api_secret"),
            token=os.environ.get("trello_token"),
        )

    def get_project_list(self):
        projects = []
        for b in self.client.list_boards():
            projects.append({"name": b.name.decode("utf-8"), "id": b.id})
        return projects

    def get_sprints(self, trell_project):

        board = self.client.get_board(trell_project)

        sprints = []

        for l in board.all_lists():
            m = re.search("Sprint (.*?) - Done", l.name.decode("utf-8"))
            if m is not None:
                sprints.append({"sprint": m.group(1)})

        return sprints

    def get_story_list(self, trell_project, sprint):

        board = self.client.get_board(trell_project)

        stories = []

        list = board.all_lists()
        for l in board.all_lists():
            type = None
            if l.name.decode("utf-8") == "Sprint " + sprint + " - Backlog":
                type = "Backlog"
            elif l.name.decode("utf-8") == "Sprint " + sprint + " - Doing":
                type = "Doing"
            elif l.name.decode("utf-8") == "Sprint " + sprint + " - Done":
                type = "Done"

            if type is not None:
                for c in l.list_cards():
                    if type == "Done":
                        if len(c.listCardMove_date()) > 0:
                            # Convert DateTime to Epoch
                            card_date = time.mktime(parser.parse(str(c.latestCardMove_date)).timetuple())
                        else:
                            # Convert DateTime to Epoch
                            card_date = time.mktime(c.create_date().timetuple())
                    else:
                        card_date = None

                    split = c.name.decode("utf-8").split("(")
                    points = split[len(split) - 1].replace(")", "")
                    del split[len(split) - 1]
                    name = "(".join(split)

                    stories.append(
                        {"status": type, "name": name, "id": c.id, "points": points, "date_completed": card_date}
                    )

        return stories
开发者ID:mooreandrew,项目名称:agile-reporting-api,代码行数:69,代码来源:trello.py


注:本文中的trello.TrelloClient.get_board方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。