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


Python TrelloClient.list_boards方法代码示例

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


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

示例1: connectionJASON

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
class connectionJASON():
    
    def setUp(self):
        self._trello = TrelloClient(api_key='f8fd231446c1fd27f49e0d8f933252f3',
                                api_secret='338b8eef2cc489ce5cfc9f2252c73f5cf51b44a41cc6cb790be20feb9ed19f2d',
                                token='8004f00bc94627ac6eb98333492a76315821ed06e9d04eec4b6480d1f575758b',
                                token_secret='a528cdd05a0dd7314f45995fdf457c45')
                                
    def getCards(self):
        boards = [board for board in self._trello.list_boards() if 'Proy Industria' in str(board.name) ]
        board = boards[0]
        cards = board.get_cards()
        return cards


    def arrangeCards(self,cards):
        resultTree = AVLTree();
        for i in cards:
            if resultTree.rootNode == None:
                resultTree.insert(i,0)
            else:
                #resultTree.rootNode.text
                currentNode = resultTree.rootNode
                done = True
                while(done):
                    moreImportant = (input(str(i)+" is more important than "+str(currentNode.text)+" y/n "))
                    if moreImportant == "y":
                        if(currentNode.rightChild == None):
                            resultTree.add_as_child2(i,currentNode,1)
                            done = False
                        else:
                            currentNode = currentNode.rightChild
                    else:
                        if(currentNode.leftChild == None):
                            resultTree.add_as_child2(i,currentNode,0)
                            done = False
                        else:
                            currentNode = currentNode.leftChild
                print(resultTree.as_list(1))
                #print(resultTree.rebalance_count)
                #print (resultTree.out())
        return resultTree

    def sendCards(self,cards):
        boards = [board for board in self._trello.list_boards() if 'Proy Industria' in str(board.name) ]
        board = boards[0]
        cards = board.get_cards()
        return cards
开发者ID:marsanem,项目名称:arbolAVL,代码行数:50,代码来源:avltree.py

示例2: TrelloWrapper

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
class TrelloWrapper():
    def __init__(self, api_key, api_token):
        self.tc = TrelloClient(api_key, api_token)


    def add_card(self, list_target, card_name, card_due, desc=None):
        """
            Add card to list with a due date
            card_due: time.stuct_time object,
            use time.localtime()
        """
        try:
            # Convert to UTC datetime object
            card_due_utc = time.gmtime(time.mktime(card_due))
            due_str = time.strftime("%Y-%m-%dT%H:%M", card_due_utc)
            json_obj = list_target.client.fetch_json(
                '/lists/' + list_target.id + '/cards',
                http_method='POST',
                post_args={'name': card_name, 'due': due_str,
                    'idList': list_target.id, 'desc': desc}, )
        except Exception as e:
            print(str(e))


    def smart_add_card(self, sentence):
        """Check date keywords in the sentence,
        and use as card's due date."""
        # TODO Life/Inbox as default, move to config
        target_default = ("Life", "Inbox")
        t_curr = time.time()
        p = parser.Parser(t_curr)

        target = p.parse_list(sentence)
        if target is None:
            target = target_default
        due = p.parse_due_time(sentence)

        list_target = self.find_list(target[0],
                target[1])

        if list_target is None:
            return False

        self.add_card(list_target, sentence, due.timetuple())
        return True


    def find_list(self, board_name, list_name):
        """ Return list specified by board_name/list_name"""
        for b in self.tc.list_boards():
            if b.name != board_name:
                continue

            for l in b.open_lists():
                if l.name != list_name:
                    continue

                return l

        return None
开发者ID:zzdoo,项目名称:trello-service,代码行数:62,代码来源:trello_wrapper.py

示例3: __init__

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
 def __init__(self):
     # API = "9cc1470c039f9f1bf8fe3ce35689a127"
     # TOKEN = "2093b976115e83e07b33321b359aa53a74d612aeec6373218d15796bd78a45b1"
     API = get_credentials()["api"]
     TOKEN = get_credentials()["token"]
     client = TrelloClient(api_key=API,
                           token=TOKEN)
     self.boards = client.list_boards()
开发者ID:hypha,项目名称:work,代码行数:10,代码来源:board_api.py

示例4: post

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [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

示例5: CardListDatasource

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
class CardListDatasource(object):
    '''

    '''
    METHODS = {
        'title': 'get_card_title',
        'members': 'get_card_members',
        'duration': 'get_card_duration'
    }

    def __init__(self, api_key, api_secret, token_key, token_secret):
        self.client = TrelloClient(api_key, api_secret, token_key, token_secret)

    def get_board(self, board_name):
        '''
            Return board by name
        '''
        boards = self.client.list_boards()
        for board in boards:
            if board.name == board_name:
                return board
        return None

    def get_cards(self, board):
        return board.all_cards()

    def parse_key(self, key):
        key = key[1:-1] # remove {}
        method = key.split('[')[0]
        try:
            param = re.match(r"[^[]*\[([^]]*)\]", key).groups()[0]
        except AttributeError:
            param = None
        return (method, param)

    def get_row(self, card, keys):
        row = {}
        for key in keys:
            parsed_key = self.parse_key(key)
            method = parsed_key[0]
            column = parsed_key[1]
            kwargs = {
                'card' : card
            }
            if column:
                kwargs['column'] = column
            value = getattr(self, self.METHODS[method])(**kwargs)
            row[key] = value
        return row
        
    def get_card_duration(self, card, column=None):
        '''
            Return card duration, with called column arg
            return card duration inside column
        '''
        history = card.listCardMove_date()
        pass
开发者ID:paulojoao,项目名称:TrelloDatasource,代码行数:59,代码来源:datasource.py

示例6: get_trello_boards

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
def get_trello_boards():
    """ Get all Trello boards """
    logger.info('Fetching Trello boards ...')
    trello_client = TrelloClient(
        api_key=trello_api_key,
        api_secret=trello_api_secret,
        token=trello_token,
        token_secret=trello_token_secret)
    logger.info('... done')
    return trello_client.list_boards()
开发者ID:jean,项目名称:trellowarrior,代码行数:12,代码来源:trellowarrior.py

示例7: main

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
def main(api_key, token):
    """List out the boards for our client"""
    trello_client = TrelloClient(
        api_key=api_key,
        token=token,
    )
    print('Boards')
    print('-----')
    print('Name: Id')
    for board in trello_client.list_boards():
        print('{board.name}: {board.id}'.format(board=board))
开发者ID:underdogio,项目名称:slack-to-trello,代码行数:13,代码来源:list-trello-boards.py

示例8: get_trello_list

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
def get_trello_list():
    # connect to trello
    trello_api_key = 'xxxx'
    trello_api_secret = 'xxxx'
    # this oauth token and secret are fetched using trello_oauth_util.py
    trello_oauth_token = "xxxx"
    trello_oauth_token_secret = "xxxx"
    trello_client = TrelloClient(api_key=trello_api_key, api_secret=trello_api_secret, token=trello_oauth_token,
                                 token_secret=trello_oauth_token_secret)
    # fetch the desired board
    # noinspection PyTypeChecker
    for board in trello_client.list_boards():
        if TRELLO_BOARD_NAME == board.name:
            for board_list in board.all_lists():
                if TRELLO_LIST_NAME == board_list.name:
                    return board_list
开发者ID:knoxxs,项目名称:evernote_to_trello_exporter,代码行数:18,代码来源:exporter.py

示例9: make_trello_board

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
    def make_trello_board(self):
        client = TrelloClient(
            api_key=self.auth["trello"]["api_key"],
            api_secret=self.auth["trello"]["api_secret"],
            token=self.auth["trello"]["token"],
            token_secret=self.auth["trello"]["token_secret"],
        )

        boards = client.list_boards()
        template = None

        for board in boards:
            if board.name == self.trello_template:
                template = board

        new_board = client.add_board(
            "DP: " + self.params["title"],
            source_board=template,
            permission_level="private"
        )
        self.params["trello_url"] = new_board.url
        print("Created Trello board - " + new_board.url)
开发者ID:tangledhelix,项目名称:dp_pp_utils,代码行数:24,代码来源:make_project.py

示例10: __init__

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [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

示例11: main

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
def main():
    try:
        parser = argparse.ArgumentParser(description="Webhook helpers")
        parser.add_argument('--cleanup', dest='cleanup', action='store_true', help='delete webhook from your SETTINGS.')
        parser.add_argument('--update', dest='update', action='store_true', help='upsert webhook from your SETTINGS.')
        parser.add_argument('--init', dest='init', action='store_true', help='delete and create webhook from your SETTINGS.')

        args = parser.parse_args()
        if not args.cleanup and not args.update and not args.init:
            print parser.print_help()
            sys.exit(0)

        client = TrelloClient(api_key=SETTINGS['trello_api_key'], token=SETTINGS['trello_api_token'])
        trello_boards = client.list_boards()

        boards_name = [slugify(b['name']) for b in SETTINGS.get('boards', {}).values()]

        # cleanup part
        if args.cleanup or args.init:
            result = [h.delete() for h in client.list_hooks()]
            LOGGING.info('delete {} webhook'.format(len(result)))

        # update / init part
        if args.update or args.init:
            for board in trello_boards:
                board_name = slugify(board.name)
                if board_name not in boards_name:
                    continue

                LOGGING.info('try to create webhook board :: {}'.format(board_name))
                url = SETTINGS['callback_url'] + '/trelloCallbacks/'
                result = client.create_hook(url, board.id)
                LOGGING.info('create webhook board :: {} :: {}'.format(board_name, result))
    except Exception as e:
        LOGGING.error('unable init webhook :: {}'.format(e))
        sys.exit(1)
开发者ID:GhostLyrics,项目名称:matterllo,代码行数:38,代码来源:helper.py

示例12: TrelloCmd

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [as 别名]
class TrelloCmd(Command):
    "Update trello board from launchpad filters"

    log = logging.getLogger(__name__)

    def get_parser(self, prog_name):
        parser = super(TrelloCmd, self).get_parser(prog_name)
        parser.add_argument(
            '--filter', type=str, action='append', required=True,
            help="List of params for searchTasks",
        )
        parser.add_argument(
            '--project', type=str, action='append', required=True,
            help="Project"
        )
        parser.add_argument(
            '--board', type=str, required=True,
            help="Trello board name"
        )
        parser.add_argument(
            '--trello-key', type=str, required=False,
            help="You can get one at https://trello.com/app-key"
        )
        parser.add_argument(
            '--trello-secret', type=str, required=False,
            help="You can get one at https://trello.com/app-key"
        )
        parser.add_argument(
            '--trello-token', type=str, required=False,
            help="You can get one at https://trello.com/1/connect?" +
                 "key=YOUR_TRELLO_KEY&name=bugfix-app&response_type=token&" +
                 "scope=read,write&expiration=never"
        )
        parser.add_argument(
            '--trello-token-secret', type=str, required=False,
        )
        parser.add_argument(
            '--create-board', action='store_true',
            help='Create Trello board if not exists'
        )
        parser.add_argument(
            '--use-labels', nargs='+',
            help='Labels for cards', default=[
                'tricky', 'low-hanging-fruit', 'tech-debt'
            ]
        )
        return parser

    def take_action(self, parsed_args):
        err_count = 0
        logging.getLogger("requests").setLevel(logging.WARNING)
        self.log.info('Connecting to Launchpad')
        self.lp = Launchpad.login_with(
            'lp-report-bot', 'production', version='devel')
        self.tr = TrelloClient(
            api_key=parsed_args.trello_key,
            api_secret=parsed_args.trello_secret,
            token=parsed_args.trello_token,
            token_secret=parsed_args.trello_token_secret)
        try:
            self.board = [
                board for board in self.tr.list_boards()
                if board.name == parsed_args.board
            ][0]
        except IndexError:
            if parsed_args.create_board:
                self.board = self.tr.add_board(parsed_args.board)
                # for label in self.board.all_lists():
                #    #label.delete()
                #    #                    self.client.fetch_json(
                #    #            '/cards/' + self.id,
                #    #            http_method='DELETE')
                for list in self.board.open_lists():
                    list.close()
            else:
                raise Exception(
                    "Board {0} doesn't exist. Use --create-board argument" +
                    " in order to create it".format(parsed_args.board))
        self.log.info("Working with board {0}".format(self.board))
        self.tag_labels = parsed_args.use_labels
        self.cards = dict()
        self.untouched_cards = dict()
        for card in self.board.open_cards():
            groups = re.search('(\d+)', card.name)
            if not (groups is None):
                bug_id = groups.group(0)
                if bug_id not in self.cards:
                    self.untouched_cards[bug_id] = card
                    self.log.debug(
                        "Found existing card for bug {0}".format(bug_id))
                    self.cards[bug_id] = card
                else:
                    self.log.info(
                        "Killing duplicate card for bug {0}".format(bug_id))
                    card.delete()
        self.log.info("Found {0} existing cards".format(
            len(self.untouched_cards)))

        for prj_name in parsed_args.project:
            prj = self.lp.projects[prj_name]
#.........这里部分代码省略.........
开发者ID:dmi-try,项目名称:lpgrabber,代码行数:103,代码来源:trellocmd.py

示例13: ServiceTrello

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [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

示例14: TrelloCollector

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_boards [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

示例15: TrelloWarehouse

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

    def __init__(self):
        self.logger = logging.getLogger("sysengreporting")
        self.client = TrelloClient(api_key = os.environ['TRELLO_API_KEY'],
                                   api_secret = os.environ['TRELLO_API_SECRET'],
                                   token = os.environ['TRELLO_TOKEN'],
                                   token_secret = os.environ['TRELLO_TOKEN_SECRET'])

        for board in self.client.list_boards():
            if board.name == 'Systems Engineering Assignments'.encode('utf-8'):
                self.logger.debug('found Systems Engineering Assignments: %s' % (board.id))
                self.syseng_assignments = board
            elif board.name == 'Private e2e Product Integration'.encode('utf-8'):
                self.logger.debug('found e2e Assignments: %s' % (board.id))
                self.e2e_board = board
            elif board.name == 'Systems Design and Engineering Projects'.encode('utf-8'):
                self.logger.debug('found Systems Design and Engineering Projects: %s' % (board.id))
                self.sysdeseng_projects = board

        self.syseng_members = self.syseng_assignments.all_members()
        self.e2e_members = self.e2e_board.all_members()

        for list in self.sysdeseng_projects.all_lists():
            if list.name == 'In Progress'.encode('utf-8'):
                self.sysdeseng_projects_cards = self.sysdeseng_projects.get_list(list.id).list_cards()

        self.projects = dict()
        self.assignments = dict()

    def _get_title(self, short_url_id):
        return "UNKNOWN" # TODO get titel of card identified by short_url_id

    def _add_project(self, project):
        pass

    def _add_assignment(self, assignment):
        pass

    def get_projects(self):
        self.projects.clear()

        # check if there are some SysDesEng projects at all
        if self.sysdeseng_projects_cards is not None:
            # and for each project
            for _project in self.sysdeseng_projects_cards:
                self.logger.debug('fetching card: %s' % (_project.name))
                _project.fetch(True) # get the details from trello.com

                _p = project.Project('Systems Engineering', _project.name, _project.id  )
                self.projects[_project.id] = _p

                self.logger.debug('new project: %s' % str(_p))

                # if the project's card has a checklist
                if _project.checklists is not None:
                    # it is per definition, the list of assignments
                    for item in _project.checklists[0].items:
                        try: # lets try to convert it into an Assignment
                            _aid = item['name'].split('/')[4]
                            self.assignments[_aid] = assignment.Assignment(_aid, self._get_title(item['name']), _p)

                            self.logger.debug("new assignment %s" % str(self.assignments[_aid]))
                        except IndexError: # if there is no URL in there...
                            self.logger.warning("Assignment '%s' did not link back to a trello card." % (item['name']))
                            pass
        else:
            self.logger.error('sysdeseng_projects_cards was None')

        return self.projects

    def get_all_assignment_ids(self):
        """function returns a list of IDs of all assignments"""

        return self.assignments.keys()

    def get_unrelated_assignments(self):
        """function to filter out any assignment that is not related to a project"""

        _assignments = []
        result = dict()

        all_known_assignments = self.get_all_assignment_ids()

        # lets find the SysEng 'In Progress' list and all its cards
        self.logger.debug('adding SysEng assignments')
        for list in self.syseng_assignments.all_lists():
            if list.name == 'In Progress'.encode('utf-8'):
                _assignments = _assignments + self.syseng_assignments.get_list(list.id).list_cards()

        # and append the E2E 'In Progress' list's cards
        self.logger.debug('adding E2E assignments')
        for list in self.e2e_board.all_lists():
            if list.name == 'In Progress'.encode('utf-8'):
                _assignments = _assignments + self.syseng_assignments.get_list(list.id).list_cards()

        # and get all cards aka assignments
#.........这里部分代码省略.........
开发者ID:goern,项目名称:mo-reporting,代码行数:103,代码来源:trello_warehouse.py


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