本文整理汇总了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
示例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
示例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)
示例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