From 57479fa55d4566b10ef16c776f1253fbfcb0b17e Mon Sep 17 00:00:00 2001 From: Benjamin Foster Date: Tue, 11 Aug 2015 22:07:28 +0100 Subject: Updated add_comment() to support line ranges add_comment() now supports 'ranges' as described by the gerrit API, by using the keyword 'range' instead of 'line', and a dict with the four required keys. Closes #31 Change-Id: Iaa7004e4f94794df8546a153227375e7be4b06bb --- pygerrit/rest/__init__.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'pygerrit') diff --git a/pygerrit/rest/__init__.py b/pygerrit/rest/__init__.py index 31e5b3e..49cc434 100644 --- a/pygerrit/rest/__init__.py +++ b/pygerrit/rest/__init__.py @@ -248,15 +248,29 @@ class GerritReview(object): 'line': 10, 'message': 'inline message'}]) + add_comments([{'filename': 'Makefile', + 'range': {'start_line': 0, + 'start_character': 1, + 'end_line': 0, + 'end_character': 5}, + 'message': 'inline message'}]) + """ for comment in comments: - if 'filename' and 'line' and 'message' in comment.keys(): - line_msg = {"line": comment['line'], - "message": comment['message']} - file_comment = {comment['filename']: [line_msg]} + if 'filename' and 'message' in comment.keys(): + msg = {} + if 'range' in comment.keys(): + msg = {"range": comment['range'], + "message": comment['message']} + elif 'line' in comment.keys(): + msg = {"line": comment['line'], + "message": comment['message']} + else: + continue + file_comment = {comment['filename']: [msg]} if self.comments: if comment['filename'] in self.comments.keys(): - self.comments[comment['filename']].append(line_msg) + self.comments[comment['filename']].append(msg) else: self.comments.update(file_comment) else: -- cgit v1.2.1