Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Handler for chrome/app/policy/policy_templates.json | 5 """Handler for chrome/app/policy/policy_templates.json |
| 6 | 6 |
| 7 This handler examines changes to the policy_templates.json file and posts | 7 This handler examines changes to the policy_templates.json file and posts |
| 8 comments with checklists for the patch author and reviewer to go through to | 8 comments with checklists for the patch author and reviewer to go through to |
| 9 avoid common pitfalls. | 9 avoid common pitfalls. |
| 10 """ | 10 """ |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 REVIEW_MESSAGE_TEMPLATE = 'review_message.txt' | 25 REVIEW_MESSAGE_TEMPLATE = 'review_message.txt' |
| 26 ADDITION_COMMENT_TEMPLATE = 'addition_comment.txt' | 26 ADDITION_COMMENT_TEMPLATE = 'addition_comment.txt' |
| 27 MODIFICATION_COMMENT_TEMPLATE = 'modification_comment.txt' | 27 MODIFICATION_COMMENT_TEMPLATE = 'modification_comment.txt' |
| 28 | 28 |
| 29 | 29 |
| 30 JINJA_ENVIRONMENT = jinja2.Environment( | 30 JINJA_ENVIRONMENT = jinja2.Environment( |
| 31 loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) | 31 loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) |
| 32 | 32 |
| 33 | 33 |
| 34 def prepare_address_list(addr, email_list): | |
| 35 """Prepares |email_list| for use as rietveld query parameter. | |
| 36 | |
| 37 Canonicalizes the entries in |email_list|, removes any occurrences of |addr|, | |
| 38 joins the entries with commas and returns the result. | |
| 39 """ | |
| 40 return ','.join([item for canonicalized in map(util.get_emails, email_list) | |
| 41 for item in canonicalized | |
|
agable
2013/08/27 14:49:19
Double-nested fors in list comprehensions are ugly
Mattias Nissler (ping if slow)
2013/08/27 15:08:41
Note that the nesting also flattens the list of li
agable
2013/08/27 15:56:26
Ah, I'd missed the nesting from get_emails. Seems
Mattias Nissler (ping if slow)
2013/08/27 16:07:23
Done.
| |
| 42 if item != addr]) | |
| 43 | |
| 44 | |
| 34 def process(addr, message, review, rietveld): | 45 def process(addr, message, review, rietveld): |
| 35 """Handles reviews for chrome/app/policy/policy_templates.json. | 46 """Handles reviews for chrome/app/policy/policy_templates.json. |
| 36 | 47 |
| 37 This looks at the patch to identify additions/modifications to policy | 48 This looks at the patch to identify additions/modifications to policy |
| 38 definitions and posts comments with a checklist intended for the author and | 49 definitions and posts comments with a checklist intended for the author and |
| 39 reviewer to go through in order to catch common mistakes. | 50 reviewer to go through in order to catch common mistakes. |
| 40 """ | 51 """ |
| 41 | 52 |
| 42 if POLICY_TEMPLATES_FILE not in review.latest_patchset.files: | 53 if POLICY_TEMPLATES_FILE not in review.latest_patchset.files: |
| 43 return | 54 return |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 71 continue | 82 continue |
| 72 | 83 |
| 73 rietveld.add_inline_comment( | 84 rietveld.add_inline_comment( |
| 74 review.issue_id, review.latest_patchset.patchset, | 85 review.issue_id, review.latest_patchset.patchset, |
| 75 review.latest_patchset.files[POLICY_TEMPLATES_FILE].id, | 86 review.latest_patchset.files[POLICY_TEMPLATES_FILE].id, |
| 76 line, side, template.render(review=review, chunk=chunk)) | 87 line, side, template.render(review=review, chunk=chunk)) |
| 77 | 88 |
| 78 # Finally, post all inline comments. | 89 # Finally, post all inline comments. |
| 79 if len(chunks) > 0: | 90 if len(chunks) > 0: |
| 80 template = JINJA_ENVIRONMENT.get_template(REVIEW_MESSAGE_TEMPLATE) | 91 template = JINJA_ENVIRONMENT.get_template(REVIEW_MESSAGE_TEMPLATE) |
| 81 rietveld.post_comment(review.issue_id, template.render(review=review), True) | 92 rietveld.publish_inline_comments( |
| 93 review.issue_id, template.render(review=review), | |
| 94 prepare_address_list(addr, review.issue_data.reviewers), | |
| 95 prepare_address_list(addr, review.issue_data.cc), | |
| 96 send_mail=False) | |
|
agable
2013/08/27 14:49:19
send_mail defaults to False.
Mattias Nissler (ping if slow)
2013/08/27 15:08:41
Done.
| |
| OLD | NEW |