本文整理汇总了Python中kallithea.model.meta.Session.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Session.filter方法的具体用法?Python Session.filter怎么用?Python Session.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kallithea.model.meta.Session
的用法示例。
在下文中一共展示了Session.filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_inline_comments
# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import filter [as 别名]
def get_inline_comments(self, repo_id, revision=None, pull_request=None):
q = Session().query(ChangesetComment)\
.filter(ChangesetComment.repo_id == repo_id)\
.filter(ChangesetComment.line_no != None)\
.filter(ChangesetComment.f_path != None)\
.order_by(ChangesetComment.comment_id.asc())\
if revision:
q = q.filter(ChangesetComment.revision == revision)
elif pull_request:
pull_request = self.__get_pull_request(pull_request)
q = q.filter(ChangesetComment.pull_request == pull_request)
else:
raise Exception('Please specify revision or pull_request_id')
comments = q.all()
paths = defaultdict(lambda: defaultdict(list))
for co in comments:
paths[co.f_path][co.line_no].append(co)
return paths.items()
示例2: _get_comments
# 需要导入模块: from kallithea.model.meta import Session [as 别名]
# 或者: from kallithea.model.meta.Session import filter [as 别名]
def _get_comments(self, repo_id, revision=None, pull_request=None, inline=False):
"""
Gets comments for either revision or pull_request_id, either inline or general.
"""
q = Session().query(ChangesetComment)
if inline:
q = q.filter(ChangesetComment.line_no != None) \
.filter(ChangesetComment.f_path != None)
else:
q = q.filter(ChangesetComment.line_no == None) \
.filter(ChangesetComment.f_path == None)
if revision is not None:
q = q.filter(ChangesetComment.revision == revision) \
.filter(ChangesetComment.repo_id == repo_id)
elif pull_request is not None:
pull_request = PullRequest.guess_instance(pull_request)
q = q.filter(ChangesetComment.pull_request == pull_request)
else:
raise Exception('Please specify either revision or pull_request')
return q.order_by(ChangesetComment.created_on).all()