mozreviewpulse: cleanup batchreview style (
Bug 1287537). r?mars
MozReview-Commit-ID: Bmc6S5XudOp
--- a/mozreviewpulse/mozreviewpulse/batchreview.py
+++ b/mozreviewpulse/mozreviewpulse/batchreview.py
@@ -5,37 +5,37 @@ import json
import logging
from rbtools.api.errors import APIError
class BatchReview(object):
"""Create a review and comments with a single API call
- Using BatchReview is much faster than creating a review and comments
- with individual API calls.
+ Using BatchReview is much faster than creating a review and comments
+ with individual API calls.
"""
def __init__(self, api_root, review_request_id, diff_revision,
max_comments=100, logger=None):
"""Initialize BatchReview
- The ``api_root`` is the result of calling get_root on a Reviewboard
- client.
+ The ``api_root`` is the result of calling get_root on a Reviewboard
+ client.
- The ``review_request_id`` is the integer identifier of the review
- request on which to leave the review.
+ The ``review_request_id`` is the integer identifier of the review
+ request on which to leave the review.
- The ``diff_revision`` is the integer identifier of the diff
- revision for which to leave the review.
+ The ``diff_revision`` is the integer identifier of the diff
+ revision for which to leave the review.
- The ``max_comments`` provides a limit on the number of comments
- which can be made as part of the BatchReview.
+ The ``max_comments`` provides a limit on the number of comments
+ which can be made as part of the BatchReview.
- The ``logger`` object is a logger to be used.
+ The ``logger`` object is a logger to be used.
"""
self.api_root = api_root
self.review_request_id = review_request_id
self.diff_revision = diff_revision
self.max_comments = max_comments
self.comments = []
@@ -47,19 +47,20 @@ class BatchReview(object):
self._destfile_to_file = {}
self._file_to_diffdata = {}
def destfile_to_file(self, destfile):
"""Map a path to a file object"""
if not self._destfile_to_file:
start = 0
while True:
- files = self.api_root.get_files(review_request_id=self.review_request_id,
- diff_revision=self.diff_revision,
- start=start)
+ files = self.api_root.get_files(
+ review_request_id=self.review_request_id,
+ diff_revision=self.diff_revision,
+ start=start)
for f in files:
self._destfile_to_file[f.dest_file] = f
start += files.num_items
if files.num_items == 0 or start >= files.total_results:
break
return self._destfile_to_file.get(destfile)
@@ -137,12 +138,13 @@ class BatchReview(object):
batch_reviews.create(
review_request_id=self.review_request_id,
ship_it=ship_it,
body_top=body_top,
body_bottom=body_bottom,
diff_comments=json.dumps(self.comments))
except APIError as e:
- self.logger.error('batchreview: could not publish review: %s' % str(e))
+ self.logger.error(
+ 'batchreview: could not publish review: %s' % str(e))
return False
return True