當前位置: 首頁>>代碼示例>>Python>>正文


Python operations.OperationQuery類代碼示例

本文整理匯總了Python中gerrymander.operations.OperationQuery的典型用法代碼示例。如果您正苦於以下問題:Python OperationQuery類的具體用法?Python OperationQuery怎麽用?Python OperationQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OperationQuery類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate

    def generate(self):
        needFiles = False
        if len(self.files) > 0:
            needFiles = True

        query = OperationQuery(self.client,
                               {
                                   "project": self.projects,
                                   "status": [ OperationQuery.STATUS_OPEN ],
                                   "branch": self.branches,
                                   "topic": self.topics,
                                   "reviewer": self.reviewers,
                               },
                               patches=OperationQuery.PATCHES_ALL,
                               approvals=True,
                               files=needFiles)

        def match_files(change):
            if len(self.files) == 0:
                return True
            for filere in self.files:
                for patch in change.patches:
                    for file in patch.files:
                        if re.search(filere, file.path):
                            return True
            return False

        table = self.new_table("Changes To Do List")
        def querycb(change):
            if self.filter(change) and match_files(change):
                table.add_row(change)

        query.run(querycb)

        return table
開發者ID:djipko,項目名稱:gerrymander,代碼行數:35,代碼來源:reports.py

示例2: generate

    def generate(self):
        # We could query all projects at once, but if we do them
        # individually it means we get better hit rate against the
        # cache if the report is re-run for many different project
        # combinations
        reviewers = {}
        now = time.time()
        for project in self.projects:
            query = OperationQuery(self.client,
                                   {
                                       "project": [project],
                                   },
                                   patches=OperationQuery.PATCHES_ALL,
                                   approvals=True)


            def querycb(change):
                for patch in change.patches:
                    for approval in patch.approvals:
                        if approval.action == ModelApproval.ACTION_VERIFIED:
                            continue

                        user = approval.user
                        if user is None or user.username is None:
                            continue
                        username = user.username

                        if username not in reviewers:
                            reviewers[username] = { "total": 0}

                        agesecs = approval.get_age(now)
                        ageweeks = int(agesecs / (60 * 60 * 24 * 7)) + 1
                        key = "week%d" % ageweeks

                        if key not in reviewers[username]:
                            reviewers[username][key] = 0

                        reviewers[username][key] = reviewers[username][key] + 1

                        if ageweeks <= 52:
                            reviewers[username]["total"] = reviewers[username]["total"] + 1

            query.run(querycb)

        table = self.new_table("Daily review rates per week")

        for reviewer in reviewers.keys():
            userteam = ""
            for team in self.teams.keys():
                if reviewer in self.teams[team]:
                    userteam = team

            table.add_row([reviewer, userteam, reviewers[reviewer]])

        return table
開發者ID:timello,項目名稱:gerrymander,代碼行數:55,代碼來源:reports.py

示例3: run

    def run(self, config, client, options):
        change = options.change

        query = OperationQuery(
            client, {"change": [change]}, patches=OperationQuery.PATCHES_ALL, approvals=True, files=True, comments=True
        )

        if options.all:
            bots = []
        else:
            bots = config.get_organization_bots()

        def mycb(change):
            self.format_change(change, bots, options.color, options.current, int(options.patch))

        query.run(mycb, limit=1)
開發者ID:russellb,項目名稱:gerrymander,代碼行數:16,代碼來源:commands.py

示例4: generate

    def generate(self):
        query = OperationQuery(self.client,
                               {
                                   "project": self.projects,
                                   "status": [ OperationQuery.STATUS_OPEN ],
                                   "reviewer": self.reviewers,
                               },
                               patches=OperationQuery.PATCHES_ALL,
                               approvals=True)

        table = self.new_table("Changes To Do List")
        def querycb(change):
            if self.filter(change):
                table.add_row(change)

        query.run(querycb)

        return table
開發者ID:patlachance,項目名稱:gerrymander,代碼行數:18,代碼來源:reports.py


注:本文中的gerrymander.operations.OperationQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。